I have an interesting situation.
I want to initiate refresh token request USING Apollo itself (a.k.a to call a mutation)
Any idea, how to achieve something like this?
export default new ApolloClient({
link: ApolloLink.from([
onError(({ graphQLErrors, networkError, operation, forward }) => {
// useMutation(REFRESH_ACCESS_TOKEN)
}),
]),
new HttpLink({...}),
})
Basically I'm just trying to useMutation(REFRESH_ACCESS_TOKEN) inside onError while creating new ApolloClient instance.
The problem:
Invalid hook call. Hooks can only be called inside of the body of a function component.
Thanks.
axiosI would like to fetch it using graphql's mutation. As the backend itself provides the refresh as a mutation. Or in other words the main problem is that I'm trying to use React Hooks in the Class initialization basically. - Artur Subotkevič