Skip to content

Commit 136337c

Browse files
committed
refactor: optimize query function in React Query generator and tidy package.json
This commit includes: - Simplified the query function in the React Query generator by removing the async keyword, enhancing performance. - Ensured consistent formatting in package.json for improved readability.
1 parent 4cf63ed commit 136337c

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
"license": "MIT",
55
"description": "Generate Axios API clients and React Query options from OpenAPI specifications",
66
"exports": "./dist/index.js",
7-
"files": [
8-
"src",
9-
"dist"
10-
],
7+
"files": ["src", "dist"],
118
"author": {
129
"name": "Oliver Winter",
1310
"email": "[email protected]"

src/generator/reactQueryGenerator.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ export const ${namedQueryOptions} = (
4545
const enabled = ${hasData ? `hasDefinedProps(params, ${requiredParams.join(", ")})` : "true"};
4646
return queryOptions({
4747
queryKey: ['${camelCase(operationId)}', ${hasData ? "params" : "undefined"}],
48-
queryFn: enabled ? async () => {
49-
const response = await apiClient.${namedQuery}(${hasData ? "params" : "undefined"}, config);
50-
return response.data;
51-
} : skipToken,
48+
queryFn: enabled ? () => apiClient.${namedQuery}(${hasData ? "params" : "undefined"}, config) : skipToken,
5249
});
5350
};`;
5451
}

0 commit comments

Comments
 (0)