@jsonpang/openapi-react-query-code-generator
Advanced tools
Comparing version 0.1.8 to 0.1.9
{ | ||
"name": "@jsonpang/openapi-react-query-code-generator", | ||
"description": "Uses openapi-typescript-codegen under the hood, and then analyzes the TypeScript AST of the generated files to create TanStack React Query hooks. Supports server-sided rendering w/ NextJS by using client instances of openapi-typescript-codegen.", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "@tanstack/react-query": "^5.17.15", |
@@ -113,2 +113,3 @@ "use strict"; | ||
useQuery, | ||
useQueryClient, | ||
} from "@tanstack/react-query"; | ||
@@ -130,3 +131,6 @@ ${modelsFileNames.map((fileName) => `import { ${fileName} } from "./models/${fileName}";`).join("\n")} | ||
export const QueryKey${(0, exports.capitalizeFirstLetter)(method.name)} = '${method.name}'; | ||
export const invalidateQuery${(0, exports.capitalizeFirstLetter)(method.name)} = async (params: { ${method.params.map((param) => `${param.name}?: ${param.type};`).join("\n ")} }) => { | ||
const queryClient = useQueryClient(); | ||
return queryClient.invalidateQueries({ queryKey: [QueryKey${(0, exports.capitalizeFirstLetter)(method.name)}, params] }); | ||
}; | ||
export const use${(0, exports.capitalizeFirstLetter)(method.name)} = < | ||
@@ -133,0 +137,0 @@ TData = Awaited<ReturnType<typeof DefaultService.prototype.${method.name}>>, |
{ | ||
"name": "@jsonpang/openapi-react-query-code-generator", | ||
"description": "Uses openapi-typescript-codegen under the hood, and then analyzes the TypeScript AST of the generated files to create TanStack React Query hooks. Supports server-sided rendering w/ NextJS by using client instances of openapi-typescript-codegen.", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "@tanstack/react-query": "^5.17.15", |
@@ -172,2 +172,3 @@ import { generate as openapiTypescriptCodegenWriter } from "openapi-typescript-codegen"; | ||
useQuery, | ||
useQueryClient, | ||
} from "@tanstack/react-query"; | ||
@@ -190,3 +191,6 @@ ${modelsFileNames.map((fileName) => `import { ${fileName} } from "./models/${fileName}";`).join("\n")} | ||
export const QueryKey${capitalizeFirstLetter(method.name)} = '${method.name}'; | ||
export const invalidateQuery${capitalizeFirstLetter(method.name)} = async (params: { ${method.params.map((param) => `${param.name}?: ${param.type};`).join("\n ")} }) => { | ||
const queryClient = useQueryClient(); | ||
return queryClient.invalidateQueries({ queryKey: [QueryKey${capitalizeFirstLetter(method.name)}, params] }); | ||
}; | ||
export const use${capitalizeFirstLetter(method.name)} = < | ||
@@ -193,0 +197,0 @@ TData = Awaited<ReturnType<typeof DefaultService.prototype.${method.name}>>, |
Sorry, the diff of this file is not supported yet
32136
709