Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/hook-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -192,6 +194,8 @@ export class HookFile extends ModuleBuilder {
yield ` ...options,`;
yield ` });`;
yield `}`;

yield `${name}.mutationKey = ${mutationKey}`;
}

if (isGet && this.isRelayPaginated(method)) {
Expand Down Expand Up @@ -480,7 +484,7 @@ export class HookFile extends ModuleBuilder {
}

if (options?.infinite) {
queryKey.push('{inifinite: true}');
queryKey.push('{infinite: true}');
}

return `[${queryKey.join(', ')}]${
Expand Down