-
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
V3 InMemoryCache: Object Fieldname Characters too Restrictive #5746
Comments
According to the GraphQL Specification, field names cannot have hyphens. |
@dylanwulf - OK, thanks, I didn't know that. Do you have any feedback on the remaining points points (below)? I can create a separate issue for each if useful, but won't bother if these are also non-issues.
Thanks |
1: I don't know, sorry. You could create an issue for that, or maybe browse through #5116 to see if you find any useful information. |
You can evict specific fields with cache.evict(
cache.identify(object),
fieldName,
); but this only works if the object has an ID, so |
It's also fine to embed JSON data containing arbitrary keys in your query results. You just can't apply a nested selection set to that data, because that implies the data is a GraphQL object with a This may point to a problem with |
@benjamn - Thanks. I guess it is not my day, because I can't seem to get the evict working either, even for the parent object. When I run the following code, I would expect the second cache.readFragment to return undefined, which it doesn't:
Am I missing something obvious? In case relevant:
|
I would think that code should work, so there might be a bug here. That said, you shouldn't have to evict the whole user object, if you do Another way to inspect the cache after evicting data is to do |
I just added So now I am a bit stuck. I guess my next step is to create a small test project to see if I can reproduce this issue in a way I can share. Do you know of any resources for apollo-client v3 (boilerplate projects or codepens) that would make that rampup quicker? |
@ahrnee I just updated the error template with an AC3-based branch (called |
@benjamn - I haven't managed to recreate evict issue in the error template (yet), but I'll spend a little more time on it. In the meantime I have narrowed it down and also noticed a few of behaviours. I'm going to share now, in case it sheds any more light on the issue. I'll update this thread as/if I get further info:
I am aware that this thread has strayed a long way from the original subject. I can create new ticket(s) as needed. |
Folks testing AC3 have already reported some confusion about evicted data seeming to reappear in the context of optimistic mutation updates: #5746 (comment) To prevent this confusion, I think we need to honor the force implied by the word "evict" and remove all traces of the given dataId/fieldName from all layers the cache, rather than only evicting from the top layer of the cache (that is, this.optimisticData).
@ahrnee I think all of these problems can be solved by making the |
) Folks testing AC3 (👋 @ahrnee) have already reported some confusion about evicted data seeming to reappear in the context of optimistic mutation updates: #5746 (comment) To prevent this confusion, I think we need to honor the force implied by the word `evict` and remove all traces of the given `dataId`/`fieldName` from all layers the cache, rather than only evicting from the top layer of the cache (namely, `this.optimisticData`).
@ahrnee did #5773 help address things? Do you think this issue can be closed? |
@hwillson - yes, thanks, these are all resolved for me now as of v3.0.0-beta.24 |
I have a nested object that uses Guids as the fieldname:
I use cache.writeData to update the nestedObject:
Intended outcome:
I am expecting the imMemoryCache to update the User to the following value:
Actual outcome:
In actuality, the keys for the nested object get messed up (seem to get doubled):
How to reproduce the issue:
Follow steps above to reproduce
Notes
Versions
System:
OS: macOS 10.15.2
Binaries:
Node: 12.12.0 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.88
Safari: 13.0.4
npmPackages:
@apollo/client: ^3.0.0-beta.10 => 3.0.0-beta.16
@apollo/react-hooks: ^3.2.0-beta.0 => 3.2.0-beta.0
apollo-link-debounce: ^2.1.0 => 2.1.0
The text was updated successfully, but these errors were encountered: