-
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
How to configure cache for Viewer Type in 3.0? #6663
Comments
Is there ever more than one |
@benjamn no, only one |
Ok, since it sounds like new InMemoryCache({
typePolicies: {
Viewer: {
// This means the singleton Viewer's identity does not depend on any of its
// fields (except for __typename), making the ID effectively constant.
keyFields: [],
},
},
}) Alternatively, the following tweak to the merge(existing, incoming, { mergeObjects }) {
return mergeObjects(existing, incoming);
} I'll leave this issue open in case those solutions don't work, or you have any other questions. |
Thanks @benjamn !
interestingly |
It doesn't sound like there is an outstanding issue here, so closing. Thanks! |
As of 3.0, the
Viewer
type in our schema throws theCache data may be lost...
warning in the console because it does not have anid
field, And I'm just not sure the best way to address it. I'm trying to determine the ideal solution here (other than removing the viewer type entirely).If I write a custom merge function on
Viewer
it would need need to be written for each field individually, which seems like a bad idea.I tried writing a custom merge on
Query
but that didn't seem to work:If I utilize
possibleTypes
and mapViewer
to the types of its fields (egUser
Product
AccountType
), it doesn't seem to fix the issue. Do I need to remove references to theviewer
in my queries to allow this to work?The only other option I can think of is adding
id
toViewer
, but trying to avoid that if I can.Any input is appreciated!
The text was updated successfully, but these errors were encountered: