Hey folks ,
I expected when setting up Apollo, while generating react-hooks for some queries to be able to cache results but this is not working. Any clue what am I missing?
I setup the client like this:
const apolloClient = new ApolloClient({
cache: new InMemoryCache(),
.... with a link setting
});
And then inside a component I am using a generated hook like this:
const { data: rawDbmss, error } = useDbmsTopologyQuery({
pollInterval: LOW_PULLING_FREQUENCY,
fetchPolicy: "cache-first",
});
I can see that in the first request I have a cache of:
{
"DBMS:F695FB610F5482B746742136D065813C2807B83F64023072FF718730E6A839DE": {
"__typename": "DBMS",
"id": "F695FB610F5482B746742136D065813C2807B83F64023072FF718730E6A839DE",
"name": "F695FB610F5482B746742136D065813C2807B83F64023072FF718730E6A839DE",
"type": "SINGLE_INSTANCE",
"instances": [
{
"__ref": "Instance:b256a902-72f1-42d0-94ea-133f82a442f8"
}
]
},
"ROOT_QUERY": {
"__typename": "Query",
"dbmsById({\"dbmsId\":\"F695FB610F5482B746742136D065813C2807B83F64023072FF718730E6A839DE\"})": {
"__ref": "DBMS:F695FB610F5482B746742136D065813C2807B83F64023072FF718730E6A839DE"
},
"dbms": [
{
"__ref": "DBMS:F695FB610F5482B746742136D065813C2807B83F64023072FF718730E6A839DE"
}
]
},
"Instance:b256a902-72f1-42d0-94ea-133f82a442f8": {
"__typename": "Instance",
"name": "single-instance",
"id": "b256a902-72f1-42d0-94ea-133f82a442f8",
"role": "SINGLE"
}
}
which is exactly the same with the second run, but still I can see a graphql request firing up, instead of reading from the cache.
Any clue what am I missing?