@@ -59,17 +59,25 @@ export function {{ method.hookName -}}<TData = {{ method.shortReturnType }}, {{
5959 const queryClient = useQueryClient();
6060 const { {{ configuredGroupVar }} } = useApi();
6161 return useMutation<{{ method.shortReturnType }}, TError, {{ method.shortInputType }}, TContext>({
62- mutationFn: ({% if not method.isVoidShortInputType %}content{% endif %}) => {{ configuredGroupVar -}}.{{- controller.fieldName -}}.{{- method.methodName -}}({% if method.isVoidShortInputType %} {} {% else %} content {% endif %}),
63- {% if method.invalidateKeysPrepared('content.', 'data.') is not empty %}
64- onSuccess: async (data, content{% if reactQueryVersion.number >= 5 %}, onMutateResult{% endif %}, context) => {
65- const invalide = async () => await Promise.all([{% for ik in method.invalidateKeysPrepared('content.', 'data.') %}
62+ mutationFn: ({% if not method.isVoidShortInputType %}content: {{ method.shortInputType }}{% endif %}) => {{ configuredGroupVar -}}.{{- controller.fieldName -}}.{{- method.methodName -}}({% if method.isVoidShortInputType %} {} {% else %} content {% endif %}),
63+ {% if method.invalidateKeysPrepared('variables.', 'data.') is not empty %}
64+ {% if reactQueryVersion.number >= 5 %}
65+ onSuccess: async (data: {{ method.shortReturnType }}, variables: {{ method.shortInputType }}, onMutateResult: TContext | undefined, context: unknown) => {
66+ {% else %}
67+ onSuccess: async (data: {{ method.shortReturnType }}, variables: {{ method.shortInputType }}, context: TContext) => {
68+ {% endif %}
69+ const invalide = async () => await Promise.all([{% for ik in method.invalidateKeysPrepared('variables.', 'data.') %}
6670 queryClient.invalidateQueries(
6771 {% if reactQueryVersion.name equals "v5" %}{queryKey: [{% for k in ik %}`{{ k }}`{% if not loop.last %}, {% endif %}{% endfor %}]}
6872 {% else %}[{% for k in ik %}`{{ k }}`{% if not loop.last %}, {% endif %}{% endfor %}]{% endif %}
6973 ){% if not loop.last %}, {% endif %}{% endfor %}]);
7074
7175 if (onSuccess) {
72- const result = onSuccess(data, content{% if reactQueryVersion.number >= 5 %}, onMutateResult{% endif %}, context);
76+ {% if reactQueryVersion.number >= 5 %}
77+ const result = onSuccess(data, variables, onMutateResult, context);
78+ {% else %}
79+ const result = onSuccess(data, variables, context);
80+ {% endif %}
7381 if (result && Object.prototype.toString.call(result) === "[object Promise]") {
7482 await result;
7583 return invalide();
0 commit comments