-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SvelteKit: Fragment stores become empty after hydration when using +page.server.ts server-side loading alongside +layout.gql #1314
Comments
Huh that's strange. Sorry for lagging on the reply here and thanks for taking the time to put together a reproduction. I'll try to find some time to look into it in the next few days |
Okay, I finally found the time and have a good idea of what's going on. Since you are loading your graphql query on the server, the client-side cache does not access to that data and so when the app hydrates and tries to hook up to the cache, it doesn't have anything. I'm not quite sure what the correct work around is for this just yet but I will keep thinking on it. Until then, the only real option is to either not load the data on a server file, or to not use the fragment. |
i'm going to close this in favor of #675 |
@AlecAivazis is there a way to manually inject data into the client side cache? |
I've decided to use the following workaround in all of my fragment components for this route nermolov/sveltekit-houdini-server-load@b39633a seems to work fine given that all of the relevant data is only loaded once for this route/there are no mutations. |
Describe the bug
On one page in my SvelteKit application, I need to conditionally call a private API based on the response of my GraphQL query, so I switched from using a
+page.gql
query to a manual server only load as described in the documentation. I still have a standard client/server query in my global+layout.gql
file. It seems that the combination of these two causes my page-level fragment stores to get cleared out after initial hydration, despite the fact that all of the data is still there.page.gql
:+page.server.ts
:+page.svelte
:AnimeTitle.svelte
:+layout.gql
:+layout.svelte
:SSR page/with javascript disabled/before hydration:
Page with javascript enabled/after hydration:
The above code is included in the linked minimal reproduction repository.
Reproduction
https://github.com/nermolov/sveltekit-houdini-server-load
The text was updated successfully, but these errors were encountered: