Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipping cache on a per-type basis #84

Open
Tracked by #2331
lwasyl opened this issue Nov 28, 2019 · 0 comments
Open
Tracked by #2331

Skipping cache on a per-type basis #84

lwasyl opened this issue Nov 28, 2019 · 0 comments

Comments

@lwasyl
Copy link

lwasyl commented Nov 28, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant