Skip to content

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

Open
@raylrui

Description

@raylrui

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;
      },
    });
  };
}

Metadata

Metadata

Assignees

Labels

backlogdesired work that needs to be completed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions