@povio/openapi-codegen-cli 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generators/utils/generate/generate.query.utils.d.ts +0 -6
- package/dist/index.js +43 -43
- package/dist/sh.js +60 -60
- package/package.json +1 -1
- package/src/generators/templates/partials/query-keys.hbs +3 -5
- package/src/generators/templates/partials/query-use-mutation.hbs +3 -3
- package/src/generators/templates/queries.hbs +1 -1
package/package.json
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export const keys = {
|
|
2
|
-
{{
|
|
3
|
-
{{
|
|
4
|
-
{{
|
|
5
|
-
{{#each endpoints as | endpoint |}}
|
|
6
|
-
{{endpointName endpoint}}: ({{{genEndpointParams endpoint}}}) => [{{{commaSeparated (endpointPathQueryKeys endpoint ../endpoints)}}}, {{{endpointArgs endpoint}}}] as const,
|
|
2
|
+
all: ["{{namespace}}"] as const,
|
|
3
|
+
{{#each queryEndpoints as | endpoint |}}
|
|
4
|
+
{{endpointName endpoint}}: ({{{genEndpointParams endpoint}}}) => [...keys.all, "{{endpoint.path}}", {{{endpointArgs endpoint}}}] as const,
|
|
7
5
|
{{/each}}
|
|
8
6
|
};
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
* @statusCodes [{{commaSeparated endpoint.responseStatusCodes}}]
|
|
9
9
|
*/
|
|
10
10
|
export const {{queryName endpoint}} = (options?: AppMutationOptions<typeof {{importedEndpointName endpoint}}, { {{{genEndpointParams endpoint}}} }>) => {
|
|
11
|
-
{{#if
|
|
11
|
+
{{#if queryEndpoints}} const queryClient = useQueryClient();{{/if}}
|
|
12
12
|
|
|
13
13
|
return {{queryHook}}({
|
|
14
14
|
mutationFn: ({{#if (endpointParams endpoint)}} { {{{endpointArgs endpoint}}} } {{/if}}) => {{importedEndpointName endpoint}}({{{endpointArgs endpoint}}}),
|
|
15
|
-
...options, {{#if
|
|
15
|
+
...options, {{#if queryEndpoints}}
|
|
16
16
|
onSuccess: (...args) => {
|
|
17
17
|
if (options?.enableInvalidateAll) {
|
|
18
|
-
queryClient.invalidateQueries({ queryKey: keys.
|
|
18
|
+
queryClient.invalidateQueries({ queryKey: keys.all });
|
|
19
19
|
}
|
|
20
20
|
options?.onSuccess?.(...args);
|
|
21
21
|
},{{/if}}
|