You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I’ve been working with React Query and Apollo Client across several projects, but I’ve never really settled on a good strategy for setting the authorization header when using JWT tokens in React Query. I like how Apollo Client handles it with links, but since TanStack Query doesn’t provide anything similar (as far as I know), I’m wondering if there’s a way to achieve something like that without too much extra work.
The main issue I run into is when handling token refresh. If I rely on a custom function to fetch the auth token, multiple simultaneous queries can cause the token refresh logic to run multiple times at once, which isn’t ideal. This does not seem to happen with the auth link in apollo client.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I’ve been working with React Query and Apollo Client across several projects, but I’ve never really settled on a good strategy for setting the authorization header when using JWT tokens in React Query. I like how Apollo Client handles it with links, but since TanStack Query doesn’t provide anything similar (as far as I know), I’m wondering if there’s a way to achieve something like that without too much extra work.
The main issue I run into is when handling token refresh. If I rely on a custom function to fetch the auth token, multiple simultaneous queries can cause the token refresh logic to run multiple times at once, which isn’t ideal. This does not seem to happen with the auth link in apollo client.
Beta Was this translation helpful? Give feedback.
All reactions