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
{{ message }}
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
Is your feature request related to a problem? Please describe.
Apollo client needs to be given the fetch function during setup of the client while setting up the application. The fetch method still isn't actually called until executing the client during preload
Today there's no way to do that and so people are coming up with workarounds timhall/svelte-apollo#9:
Using isomorphic-fetch, isomorphic-unfetch, or cross-fetch in order to provide their own fetch function bypassing Sapper's provided functionality. But this won't pass headers (i.e. cookies and auth headers from the original request) and so requires a fair amount of work to make that actually work
Just using onMount and skipping SSR altogether
You can't create the Apollo client in layout's preload where this.fetch is available because then it will only get created on the server during initial page load and when you navigate to another page it won't have been created.
Describe the solution you'd like
I'm thinking it might be good to have some kind of init method that gets called at the beginning of the application on both the client and server in order to setup things like data fetchers and takes an object containing fetch as a parameter
Describe alternatives you've considered
I will probably try to use cross-fetch and not use Sapper's fetch. It's a bit of a Rube Goldberg making it all fit together though. I haven't figured out how I'll pass along cookies and auth headers on the server from my original request to the API server
How important is this feature to you?
There are probably workarounds. I've really been tearing my hair out trying to figure out how to get this wired up though.
GraphQL is extremely popular. It'd be nice if Sapper had better support for utilizing GraphQL clients.
Additional context
In addition to this issue, users also need to create per-request context on the server to hold the client. It took me quite a lot of investigation to find a solution seems doable. (#751 (comment))
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Apollo client needs to be given the
fetch
function during setup of the client while setting up the application. Thefetch
method still isn't actually called until executing the client duringpreload
Today there's no way to do that and so people are coming up with workarounds timhall/svelte-apollo#9:
fetch
function bypassing Sapper's provided functionality. But this won't pass headers (i.e. cookies and auth headers from the original request) and so requires a fair amount of work to make that actually workonMount
and skipping SSR altogetherYou can't create the Apollo client in layout's
preload
wherethis.fetch
is available because then it will only get created on the server during initial page load and when you navigate to another page it won't have been created.Describe the solution you'd like
I'm thinking it might be good to have some kind of
init
method that gets called at the beginning of the application on both the client and server in order to setup things like data fetchers and takes an object containingfetch
as a parameterDescribe alternatives you've considered
I will probably try to use
cross-fetch
and not use Sapper'sfetch
. It's a bit of a Rube Goldberg making it all fit together though. I haven't figured out how I'll pass along cookies and auth headers on the server from my original request to the API serverHow important is this feature to you?
There are probably workarounds. I've really been tearing my hair out trying to figure out how to get this wired up though.
GraphQL is extremely popular. It'd be nice if Sapper had better support for utilizing GraphQL clients.
Additional context
In addition to this issue, users also need to create per-request context on the server to hold the client. It took me quite a lot of investigation to find a solution seems doable. (#751 (comment))
The text was updated successfully, but these errors were encountered: