timhall / svelte-apollo

Svelte integration for Apollo GraphQL
MIT License
947 stars 68 forks source link

[SAPPER] Routing between dynamic pages issue #59

Closed rodshtein closed 3 years ago

rodshtein commented 3 years ago

Faced a problem: when I navigate from a dynamic route to the same level page, the url is updated, the gql requests data, but the page is not redrawn. Only if I use hard reload.

Code example with the same issue: https://github.com/EddyVinck/sapper-graphql-template/blob/dev/src/routes/blog/%5Bslug%5D.svelte

The reason: https://github.com/sveltejs/sapper/issues/1278

timhall commented 3 years ago

Will track in #9

jdgamble555 commented 3 years ago

Faced a problem: when I navigate from a dynamic route to the same level page, the url is updated, the gql requests data, but the page is not redrawn. Only if I use hard reload.

Code example with the same issue: https://github.com/EddyVinck/sapper-graphql-template/blob/dev/src/routes/blog/%5Bslug%5D.svelte

The reason: sveltejs/sapper#1278

Your example loads the client from the cache, but how would a bot scanning your site load cache to get ssr meta data?

rodshtein commented 3 years ago

@jdgamble555

First of all - it's not my example, I just found a repository that represents the same issue 🤗

And the second one - when you get the first load Sapper will generate flat HTML and then hydrate it.
That controlled by Preload code section. The search bot loads every page from scratch.

jdgamble555 commented 3 years ago

@zamkevich Ok, thanks. I wasn't sure if it was cached on the actual server or not, as that would be useful for ssr search bot. Not sure how that is solved.

rodshtein commented 3 years ago

@jdgamble555 It's achieved by run preload function on BFF for the first load. The function get all data and put into HTML. After hydration, all next calls the Preload function will be run on the client. All requests must be isomorphic (works for Node and Browser environment).

jdgamble555 commented 3 years ago

@zamkevich Does it actually update the HTML before it is loaded or does it update it VIA javascript? For example: A search engine bot cannot read javascript, but it can read html/meta tags etc. Can I change the source html from the server this way?

rodshtein commented 3 years ago

@jdgamble555 Yes, you can.