Skip to content

Commit 09c18d8

Browse files
committed
fix: react-query v5 corrected onSuccess
1 parent 04425e6 commit 09c18d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

commons-rest-openapi/src/main/resources/templates/hook/hook-template.pebble

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ export function {{ method.hookName -}}<TData = {{ method.shortReturnType }}, {{
6161
return useMutation<{{ method.shortReturnType }}, TError, {{ method.shortInputType }}, TContext>({
6262
mutationFn: ({% if not method.isVoidShortInputType %}content{% endif %}) => {{ configuredGroupVar -}}.{{- controller.fieldName -}}.{{- method.methodName -}}({% if method.isVoidShortInputType %} {} {% else %} content {% endif %}),
6363
{% if method.invalidateKeysPrepared('content.', 'data.') is not empty %}
64-
onSuccess: async (data, content, context) => {
64+
onSuccess: async (data, variables{% if reactQueryVersion.number >= 5 %}, onMutateResult{% endif %}, context) => {
6565
const invalide = async () => await Promise.all([{% for ik in method.invalidateKeysPrepared('content.', 'data.') %}
6666
queryClient.invalidateQueries(
6767
{% if reactQueryVersion.name equals "v5" %}{queryKey: [{% for k in ik %}`{{ k }}`{% if not loop.last %}, {% endif %}{% endfor %}]}
6868
{% else %}[{% for k in ik %}`{{ k }}`{% if not loop.last %}, {% endif %}{% endfor %}]{% endif %}
6969
){% if not loop.last %}, {% endif %}{% endfor %}]);
7070

7171
if (onSuccess) {
72-
const result = onSuccess(data, content, context);
72+
const result = onSuccess(data, variables{% if reactQueryVersion.number >= 5 %}, onMutateResult{% endif %}, context);
7373
if (result && Object.prototype.toString.call(result) === "[object Promise]") {
7474
await result;
7575
return invalide();

0 commit comments

Comments
 (0)