apollographql / apollographql/apollo-client-integrations
useSuspenseQuery not sending cookies on Server Side query
- Dominant language
- TypeScript
- Stars
- 556
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
I may be missing something simple here but I have an apollo-provider that is pretty standard, however we use supabase auth and the session is set in cookies.
Obviously the cookie is present when the user refreshes the query page, but its not until the client re-initiates the query (which I don't think would happen if this issue was solved) that the server sees the cookies passed. The httpLink and client set up is as follows:
`
const isServer = typeof window === "undefined";
const httpLink = new HttpLink({
uri: GRAPHQL_URI,
credentials: "include"
});
return new NextSSRApolloClient({
cache: apolloCache,
link: isServer
? ApolloLink.from([new SSRMultipartLink({ stripDefer: true }), httpLink])
: httpLink,
});
};
`
I know the cookie is available because I can set it as an authorization header which does get fired in the query on the server side but I'd rather not have to "hack" it that way, Is there a way to ensure that even when query is processed on the server side that it includes the cookies?
Thanks in advance.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the shown NextSSRApolloClient setup, especially the server-side HttpLink and SSRMultipartLink path, and reproduce the useSuspenseQuery request during a page refresh. Trace whether the Supabase session cookie reaches the server query; done means server-side queries forward the cookie without manually copying it into an authorization header.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, next.js, supabase, typescript
- Domain
- api, authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100