How can I pass an authorization header to all queries and mutations
Hello
I have this code that allow to me pass my token to all my queries and it works fine. But I'd like this for my mutations too if possible.
This is a query example
But I'd like to do the same my my mutations:
1 Reply
afraid-scarlet•9mo ago
Something like
I think it'll work. I checked the types of query,
defaultOptions.queries
basically takes the same options as useQuery
, so defaultOptions mutations
has the same logic.
Unfortunately I don't think mutate
is able to take a mutation key
I'd probably make a mutationOptions
helper that takes in the mutationKey
and returns the options object with the mutation function.
What auth solution are you using btw?