Skip to content

Using Cached Result between two Queries #3393

Answered by JoviDeCroock
ajtosh77 asked this question in Q&A
Discussion options

You must be logged in to vote

You could check whether you are querying me in the shouldUpgrade method of the requestPolicyExchange. Apart from that you would have to tell your normalized cache that user(id: $id) gives you user:id.

resolvers: {
  Query: { user: (parent, args, cache) => {
    return cache.resolve({ __typename: 'User', id: args.id }) ? cache.keyOfEntity({ __typename: 'User', id: args.id }) : undefined
  } }
}

This ensures that if the User:id is in cache that it will be retrieved from cache, as the normalized cache does not by default assume that Query.user(id: $id) links to User:id

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JoviDeCroock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants