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
You can't use a hook outside a functional React component. You can use the client directly to make queries and mutations -- just bear in mind that any queries ran this way will not be observable (i.e. won't be updated if the cache changes).
const client = new ApolloClient({
link: ApolloLink.from([
onError(({ graphQLErrors, networkError, operation, forward }) => {
client.mutate({ mutation, variables })
.then(({ data }) => {
console.log(data)
})
.catch((error) => {
console.log(error)
})
}),
new HttpLink({...}),
]),
})
export default client