-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Edits to reading and writing cached data #7864
Conversation
e381a70
to
de12147
Compare
de12147
to
a8ec20c
Compare
243b412
to
120b108
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with a few suggestions about explaining __typename
a bit better.
```json | ||
{ | ||
"data": { | ||
"allPeople": { | ||
"people": [ | ||
{ | ||
"id": "cGVvcGxlOjE=", | ||
"name": "Luke Skywalker", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the __typename: "Person"
(and "Planet"
) fields to this data, and add a note about Apollo Client automatically adding those fields to the query? Otherwise it may be hard to understand how the normalization makes use of the __typename
information.
const { todo } = client.readQuery({ | ||
{ | ||
todo: { | ||
__typename: 'Todo', // __typename is automatically included |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my previous comment, it might be good to explain how __typename
gets automatically included?
@@ -149,12 +224,14 @@ client.writeQuery({ | |||
}); | |||
``` | |||
|
|||
## `cache.modify` | |||
## Using `cache.modify` | |||
|
|||
The `modify` method of `InMemoryCache` enables you to directly modify the values of individual cached fields, or even delete fields entirely. | |||
|
|||
* Like `writeQuery` and `writeFragment`, `modify` triggers a refresh of all active queries that depend on modified fields (unless you override this behavior). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Like `writeQuery` and `writeFragment`, `modify` triggers a refresh of all active queries that depend on modified fields (unless you override this behavior). | |
* Like `writeQuery` and `writeFragment`, `modify` triggers a refresh of all active queries that depend on modified fields (unless you override this behavior by passing `broadcast: false`). |
Not critical, but I'm assuming this is what was originally meant by "override this behavior."
No description provided.