Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backlog] add type assertion for client.query params when make api call #20

Open
raylrui opened this issue Aug 29, 2024 · 0 comments
Open
Assignees
Labels
backlog desired work that needs to be completed

Comments

@raylrui
Copy link
Contributor

raylrui commented Aug 29, 2024

Query client params type should be dynamically assigned through the openapi path params
Temporary we add // @ts-expect-error to suppress ts check.

In the future, we will find a way to pass right type assertion for query params.

this issue is for all createFetchingHook with @tanstack/react-query

function createMetadataFetchingHook<K extends keyof paths>(path: K) {
  return function ({ params, reactQuery }: UseSuspenseQueryOptions<paths[typeof path]['get']>) {
    return useSuspenseQuery({
      ...reactQuery,
      queryKey: [path, params],
      queryFn: async ({ signal }) => {
        // @ts-expect-error: params is dynamic type type for openapi-fetch
        const { data } = await client.GET(path, { params, signal });
        return data;
      },
    });
  };
}
@raylrui raylrui added the backlog desired work that needs to be completed label Aug 29, 2024
@raylrui raylrui self-assigned this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog desired work that needs to be completed
Projects
None yet
Development

No branches or pull requests

1 participant