timhall / svelte-apollo

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

query() does not immediately write to cache #74

Open benwoodward opened 3 years ago

benwoodward commented 3 years ago

I'm not sure if this is an Apollo question, or svelte-apollo question.. ApolloClient seems to automatically write query results to the cache, but this is only triggered when navigating to a new route. It's strange to me that the query result is not immediately cached.

I'm using a reactive if statement as a 'workaround':

  const itemData = query(allItems, {});
  $: if ($itemData.data) {
    restore(allItems, {data: $cardData.data});
  }

Am I misunderstanding something here, or would it actually make sense to add a restore statement to the svelte-apollo query() function?