diff --git a/src/hook-file.ts b/src/hook-file.ts index 6dcae4b..0b5056d 100644 --- a/src/hook-file.ts +++ b/src/hook-file.ts @@ -160,10 +160,12 @@ export class HookFile extends ModuleBuilder { undefined, method.deprecated?.value, ); + const mutationKey = `['${method.name.value}']`; yield `export function ${name}(${optionsExpression}) {`; yield ` const queryClient = ${useQueryClient()}();`; yield ` const ${serviceName} = ${this.context.fn(serviceHookName)}()`; yield ` return ${useMutation()}({`; + yield ` mutationKey: ${mutationKey},`; yield ` mutationFn: async (${paramsExpression}) => {`; yield ` const res = await ${guard()}(${serviceName}.${camel( method.name.value, @@ -192,6 +194,8 @@ export class HookFile extends ModuleBuilder { yield ` ...options,`; yield ` });`; yield `}`; + + yield `${name}.mutationKey = ${mutationKey}`; } if (isGet && this.isRelayPaginated(method)) { @@ -480,7 +484,7 @@ export class HookFile extends ModuleBuilder { } if (options?.infinite) { - queryKey.push('{inifinite: true}'); + queryKey.push('{infinite: true}'); } return `[${queryKey.join(', ')}]${