Skip to content

[Feature Request] Provide separate endpoint data variables #313

@badsyntax

Description

@badsyntax

Using generateReactQueryComponents(), the following is generated:

export const fetchDeleteFile = (
  variables: DeleteFileVariables,
  signal?: AbortSignal,
) =>
  fetch<
    string,
    DeleteFileError,
    undefined,
    DeleteFileHeaders,
    {},
    DeleteFilePathParams
  >({
    url: '/v1/activities/file/{blobName}',
    method: 'delete',
    ...variables,
    signal,
  });

In the above code, there's no way for me to access the URL (/v1/activities/file/{blobName}) for that endpoint.

It would be very useful if we could do this instead:

export const deleteFileOperation = {
  url: '/v1/activities/file/{blobName}',
  method: 'delete',
};

export const fetchDeleteFile = (
  variables: DeleteFileVariables,
  signal?: AbortSignal,
) =>
  fetch<
    string,
    DeleteFileError,
    undefined,
    DeleteFileHeaders,
    {},
    DeleteFilePathParams
  >({
    ...deleteFileOperation,
    ...variables,
    signal,
  });

This allows me to access the endpoint metadata.

Use Case:

I need to build a custom react-query hook that uses XMLHttpRequest (for file uploads), but i have to hard code the endpoint URL, instead of referencing the URL in generated code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions