I have a query with a @Connection
directive set. Now I want to clear only the cached results of this query. I can not find any examples of doing this. I tried to set the fieldName
to the @Connection
‘s key but this doesn’t work.
Can this be done in Apollo?
The query:
query getEventsList ($happenedBetween: DateRangeInput, $limit: Int = 999) {
me {
id
events(
happenedBetween: $happenedBetween
limit: $limit
)
@connection(key: "eventsList")
{
...ShowFragment
}
}
}
My function to clear this query cache:
const clearCache = (): void => {
client.cache.evict({
id: 'ROOT_QUERY',
fieldName: 'eventsList',
}
})
client.cache.gc()
}