onCompleted option not available for refetchQueries

Hi Team,

First of all, Thank you so much for coding a wonderful library.

Now coming to my question here,
I wanna execute a query on completion of a mutation [every time an action occurs/mutation is called].
now apollo provides an option to execute a GQL query after a mutation using refetchQueries option.

but I am looking for, How we can perform an action like updating the react context data [this shouldn’t be async] with the re-fetched query response?
After reading through docs, I found apollo client doesn’t provide an option to specify onCompleted callback for refetchQueries.

Can you please share some examples if this is possible? if not, is there a way we can achieve this with the current version of apollo-client??

@StephenBarlow appreciate it if you can assist here?

Hello! There are improvements coming to the process for refetching queries after a mutation in Apollo Client 3.4 that should address this case (here’s the PR that adds those improvements).

Until 3.4 releases, you might find some success with the solution in this discussion (instead of calling the refetchQueries function provided by useMutation, call the refetch function returned by useQuery inside the mutation’s onCompleted callback).

1 Like