OrcaBus / OrcaBus/orca-ui

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

Open
#20 0 comments 0 reactions 1 assignee View on GitHub

@raylrui is already working on this.

Since Aug 29, 2024.

backlog
Dominant language
TypeScript
Stars
1
Forks
0
Avg merge
49m
Merged PRs (30d)
4

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.