Skip to content

Commit ccf4c8a

Browse files
committed
fix: edit format
1 parent 054202f commit ccf4c8a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

packages/openapi-react-query/src/index.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ import {
1414
useInfiniteQuery,
1515
} from "@tanstack/react-query";
1616
import type { ClientMethod, FetchResponse, MaybeOptionalInit, Client as FetchClient } from "openapi-fetch";
17-
import type { HttpMethod, MediaType, PathsWithMethod, RequiredKeysOf, ResponseObjectMap } from "openapi-typescript-helpers";
17+
import type {
18+
HttpMethod,
19+
MediaType,
20+
PathsWithMethod,
21+
RequiredKeysOf,
22+
ResponseObjectMap,
23+
} from "openapi-typescript-helpers";
1824

1925
export type UseQueryMethod<Paths extends Record<string, Record<HttpMethod, {}>>, Media extends MediaType> = <
2026
Method extends HttpMethod,
@@ -146,9 +152,9 @@ export default function createClient<Paths extends {}, Media extends MediaType =
146152
queryFn: async ({ pageParam = 0 }) => {
147153
const mth = method.toUpperCase() as keyof typeof client;
148154
const fn = client[mth] as ClientMethod<Paths, typeof method, Media>;
149-
155+
150156
const params = pageParam === 0 ? init : { ...init, page: pageParam };
151-
157+
152158
const { data, error } = await fn(path, params as any); // TODO: find a way to avoid as any
153159
if (error || !data) {
154160
throw error;

packages/openapi-react-query/test/index.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ describe("client", () => {
467467

468468
const { result } = renderHook(
469469
() => client.useInfiniteQuery("get", "/paginated-data", { params: { query: { limit: 3 } } }),
470-
{ wrapper }
470+
{ wrapper },
471471
);
472472

473473
await waitFor(() => expect(result.current.isSuccess).toBe(true));
@@ -489,7 +489,7 @@ describe("client", () => {
489489

490490
expect((result.current.data as any).pages).toHaveLength(2);
491491
expect((result.current.data as any).pages[1]).toEqual({ items: [4, 5, 6], nextPage: 2 });
492-
});
492+
});
493493

494494
it("should handle errors correctly", async () => {
495495
const fetchClient = createFetchClient<paths>({ baseUrl });
@@ -505,7 +505,7 @@ describe("client", () => {
505505

506506
const { result } = renderHook(
507507
() => client.useInfiniteQuery("get", "/paginated-data", { params: { query: { limit: 3 } } }),
508-
{ wrapper }
508+
{ wrapper },
509509
);
510510

511511
await waitFor(() => expect(result.current.isError).toBe(true));

0 commit comments

Comments
 (0)