diff --git a/src/createImports.mts b/src/createImports.mts index 62fa92a..b302ee0 100644 --- a/src/createImports.mts +++ b/src/createImports.mts @@ -43,6 +43,11 @@ export const createImports = ({ false, undefined, ts.factory.createNamedImports([ + ts.factory.createImportSpecifier( + true, + undefined, + ts.factory.createIdentifier("QueryClient") + ), ts.factory.createImportSpecifier( false, undefined, diff --git a/tests/__snapshots__/createSource.test.ts.snap b/tests/__snapshots__/createSource.test.ts.snap index c482300..afea9f7 100644 --- a/tests/__snapshots__/createSource.test.ts.snap +++ b/tests/__snapshots__/createSource.test.ts.snap @@ -11,7 +11,7 @@ export * from "./queries"; exports[`createSource > createSource 2`] = ` "// generated with @7nohe/openapi-react-query-codegen@1.0.0 -import { useQuery, useSuspenseQuery, useMutation, UseQueryResult, UseQueryOptions, UseMutationOptions, UseMutationResult } from "@tanstack/react-query"; +import { type QueryClient, useQuery, useSuspenseQuery, useMutation, UseQueryResult, UseQueryOptions, UseMutationOptions, UseMutationResult } from "@tanstack/react-query"; import { DefaultService } from "../requests/services.gen"; import { Pet, NewPet, Error, $OpenApiTs } from "../requests/types.gen"; export type DefaultServiceFindPetsDefaultResponse = Awaited>; @@ -41,7 +41,7 @@ exports[`createSource > createSource 3`] = ` "// generated with @7nohe/openapi-react-query-codegen@1.0.0 import * as Common from "./common"; -import { useQuery, useSuspenseQuery, useMutation, UseQueryResult, UseQueryOptions, UseMutationOptions, UseMutationResult } from "@tanstack/react-query"; +import { type QueryClient, useQuery, useSuspenseQuery, useMutation, UseQueryResult, UseQueryOptions, UseMutationOptions, UseMutationResult } from "@tanstack/react-query"; import { DefaultService } from "../requests/services.gen"; import { Pet, NewPet, Error, $OpenApiTs } from "../requests/types.gen"; /** @@ -119,7 +119,7 @@ exports[`createSource > createSource 4`] = ` "// generated with @7nohe/openapi-react-query-codegen@1.0.0 import * as Common from "./common"; -import { useQuery, useSuspenseQuery, useMutation, UseQueryResult, UseQueryOptions, UseMutationOptions, UseMutationResult } from "@tanstack/react-query"; +import { type QueryClient, useQuery, useSuspenseQuery, useMutation, UseQueryResult, UseQueryOptions, UseMutationOptions, UseMutationResult } from "@tanstack/react-query"; import { DefaultService } from "../requests/services.gen"; import { Pet, NewPet, Error, $OpenApiTs } from "../requests/types.gen"; /** @@ -164,7 +164,7 @@ exports[`createSource > createSource 5`] = ` "// generated with @7nohe/openapi-react-query-codegen@1.0.0 import * as Common from "./common"; -import { useQuery, useSuspenseQuery, useMutation, UseQueryResult, UseQueryOptions, UseMutationOptions, UseMutationResult } from "@tanstack/react-query"; +import { type QueryClient, useQuery, useSuspenseQuery, useMutation, UseQueryResult, UseQueryOptions, UseMutationOptions, UseMutationResult } from "@tanstack/react-query"; import { DefaultService } from "../requests/services.gen"; import { Pet, NewPet, Error, $OpenApiTs } from "../requests/types.gen"; /** diff --git a/tests/__snapshots__/generate.test.ts.snap b/tests/__snapshots__/generate.test.ts.snap index d08bee3..4ed7d5d 100644 --- a/tests/__snapshots__/generate.test.ts.snap +++ b/tests/__snapshots__/generate.test.ts.snap @@ -39,6 +39,7 @@ export * from "./queries"; exports[`generate > prefetch.ts 1`] = ` "// generated with @7nohe/openapi-react-query-codegen@1.0.0 +import { type QueryClient } from "@tanstack/react-query"; import { DefaultService } from "../requests/services.gen"; import * as Common from "./common"; /**