Open traik06 opened 2 months ago
If there is anything else I can add to help with my question please let me know!
I think the core problem that you have here is that makeClient
is only called once for the whole lifetime of your application - anything else would throw away your cache and require a lot of requests to be made again.
Instead of passing a token
into your makeClient
function, I would recommend that you work with defaultContext
as shown in this comment: https://github.com/apollographql/apollo-client-nextjs/issues/103#issuecomment-1790941212
One random observation:
Please don't use ssrMode
with this package. It's something that's sometimes made up by ChatGPT because it exists on the normal ApolloClient, but we don't show it anywhere in the docs for this package - you don't need it for streaming SSR and it might even be counterproductive.
Description
Hello all I'm relatively new to this so if this is a basic question please bear with me here. I am creating a nextjs14 app and I'm trying to implement apollo client into the application. the main part of the application is protected by a login that calls to my express backend to get a JWT token. I want to then pass the JWT token in as a header for the graphql queries.
Issue
apolloClient.ts
file which I will provide how I have it configured below but is not available to myApolloWrapper.tsx
file when trying to run a basic query after the re route to the dashboard.Observations / Questions
/dashboard
page is rendered or compiled that JWT is not accessible by the browser yet so it just sets it to undefined./dashboard
route?await
the rendering of the/dashboard
route until the JWT is available and be added to the headers in theApolloWrapper.tsx
file?I have some hardcoded
urls
and such just for testing and some logs in there that would be removed once I figure this outProject Versions
Folder Layout
apolloClient.ts
ApolloWrapper.tsx
Layout.tsx
: app/(root)/layout.tsx