Skipping cache on a per-type basis
Some of our mutations return sensitive data, like access token. Their paths also contain sensitive data, like user email and password used for authorization mutation. We don't want to keep them in the normalized SQL cache on a disk, so right now we attach ApolloCacheHeaders.DO_NOT_STORE header, otherwise we see the path, access token etc. in the cache even when setting CacheKey.NO_KEY for these types in the CacheKeyResolver.
However, those mutations also return data that we would like to cache, like the general user profile. We can distinguish objects that we want to cache or not based on their __typename field, and they're not nested.
Is there any way to cache only specific objects from the mutation, without persisting mutation path (which contains email/password since they're parameters of the mutation) and unwanted parts of the response? For example for
mutation SignIn($email: String!, $password: String!) {
auth {
signIn(input: { email: $email, password: $password }) {
token
userData {
id
...userData
}
}
}
}
we'd like to only put userData under ID key in the normalized cache, and drop everything else, including token, email or password. The reason is we also have query UserData(id: Id) and we'd like to be able to execute it but only use cached data (which we'd update using other queries/mutations). Is this possible?