evictCache<T, U extends JsonSerializable> method
Evicts (removes) cached data for a specific query.
Use this after mutations to invalidate stale cache entries.
Example:
// After updating user
await client.execute(UpdateUserMutation(...));
await client.evictCache(GetUserQuery(variables: GetUserArguments(id: '123')));
Implementation
Future<void> evictCache<T, U extends JsonSerializable>(
GraphQLQuery<T, U> query,
) async {
final request = Request(
operation: Operation(
document: query.document,
operationName: query.operationName,
),
variables: query.getVariablesMap(),
);
final cacheKey = _cacheLink.generateCacheKey(request);
_cacheLink.evict(cacheKey);
}