Graphcache: Resolving partial data from the same entity #1747
-
Hello, I just started reading up on how normalized caching works so I don't fully understood what it do. Query 1: Returns file fields query File($id: ID!) {
file: File(id: $id) {
id
fileName
}
} Query 2: Returns file comment field, comments is a connection query FileComments($id: ID!) {
file: File(id: $id) {
id
comments { # type is FileCommentConnection
edges {
node {
id
text
}
}
}
}
} My question is on how to I resolve this so that the cache will merge the results from the queries to the same entity. Btw, I have introspection schema data enabled on the cacheExchange. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hey, Yes the cache will merge these two results so imagine the following scenario:
Then the cache will save the records Now when |
Beta Was this translation helpful? Give feedback.
Hey,
Yes the cache will merge these two results so imagine the following scenario:
Then the cache will save the records
File:1.id=1
, ... and save that File:1 links to the comments it has received, this is how normalized caching will handle this.Now when
comments
is marked as optional and you've done the first query you'll get apartial
result (recognizable by stale: true). This means that we'll give you the data from the first query while we resolve the additional fields (comments) from the second.