This configuration creates behavior where data is refreshed only on full page refresh but it grabs data from cache if the page is opened through <NuxtLink to='/test' />
apollo.config.js
export default context => ({
httpEndpoint: 'https://test.hasura.app/v1/graphql',
getAuth () {
return context.store.state.auth.token ? `Bearer ${context.store.state.auth.token}` : null
},
})
test.vue
<template>
<div v-if="users">
users: <pre>{{ users }}</pre>
</div>
</template>
<script>
import testQuery from '~/apollo/queries/test.graphql'
export default {
apollo: {
users: {
query: testQuery,
prefetch: true,
},
},
}
</script>
testQuery.graphql
query testQuery {
users {
phone
}
}
The problem can be solved by using different fetch policy:
fetchPolicy: 'no-cache // doesn't cache the data'
fetchPolicy: 'netowrk-only' // executes query without checking the cache result gets stored in cache
however, that creates hydration problems even if prefetch: true
How should I prevent inconsistencies with the server data?