timhall / svelte-apollo

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

Sharing the store amongst pages #85

Open neiled opened 3 years ago

neiled commented 3 years ago

OK just trying to get my head in the right space sorry if it's a dumb question.

I have several 'pages' (Component siblings I guess, they are all top level) that all want to access 'Book's. What's the best way of sharing the query amongst multiple pages? I'd rather download the data once and then share the downloaded books store amongst the Pages. The only way I can think of doing this right now is to create the Books query at the App level and passing the store it creates to each page that is going to use it as a prop. Is that the right way?

flashspys commented 3 years ago

You could either rely on the Apollo Store or put the response of the query in a svelte store