-
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
Cache is replacing the objects within an array being stored #4025
Comments
This would have helped diagnose the cause of #4025, which is that query fields with non-scalar types (or list-of-non-scalar types) must have a selection set. In other words, given a schema like type Query { selectedMessageList: [SelectedMessage] } a query like query getSelectedMessageList { selectedMessageList @client } is invalid since it doesn't specify which fields of the SelectedMessage objects should be included in the list.
@MLDimitry The root of the problem seems to be that your query query getSelectedMessageList {
selectedMessageList @client
} needs to have a selection set after the However, it's definitely a bug that the cache did not throw an appropriate error, and instead exposed the internal I've submitted PR #4038 to make sure we throw a more helpful error. |
This would have helped diagnose the cause of #4025, which is that query fields with non-scalar types (or list-of-non-scalar types) must have a selection set. In other words, given a schema like type Query { selectedMessageList: [SelectedMessage] } a query like query getSelectedMessageList { selectedMessageList @client } is invalid since it doesn't specify which fields of the SelectedMessage objects should be included in the list.
This would have helped diagnose the cause of #4025, which is that query fields with non-scalar types (or list-of-non-scalar types) must have a selection set. In other words, given a schema like type Query { selectedMessageList: [SelectedMessage] } a query like query getSelectedMessageList { selectedMessageList @client } is invalid since it doesn't specify which fields of the SelectedMessage objects should be included in the list.
As requested by @jbaxleyiii: #4038 (comment)
Closing because I believe |
I am using Apollo Link State to store an array of "SelectedMessage" objects. Each "SelectedMessage" object should look like:
{ __typename : String!, messageId : String!, labels : [ String ] }
This stored array is fetched and updated any time a message is selected/unselected. It works like a toggle. If the message is already in the array, it should be filtered out. If it's not in the array, it's concat'd in. But that functionality is not working because the "messageId" field I am comparing on does not exist on the object that is returned within the array.
Intended outcome:
When I retrieve my selectedMessageList I expect it to be in the format
[ SelectedMessage ]
.Actual outcome:
But for some reason, when I retrieve this array using
cache.readQuery()
, the array being returned is some sort of[ NormalizedSelectedMessageObjectOrSomething ]
in the format of:{ type : String, id : String, generated : Boolean, }
Code and logging are below.
Code
toggleMailMessageIsSelectedResolver mutation on local cache
Logging
Chrome dev tools logs after clicking the toggle select button 3 times
How to reproduce the issue:
This Code Sandbox project reproduces the issue:
https://codesandbox.io/s/lpxqyv0z4z
Versions
System:
OS: macOS High Sierra 10.13.6
Binaries:
Node: 10.11.0 - /usr/local/bin/node
Yarn: yarn install v0.23.2
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.52s. - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Browsers:
Chrome: 69.0.3497.100
Firefox: 61.0.1
Safari: 12.0
npmPackages:
apollo-boost: ^0.1.13 => 0.1.16
react-apollo: ^2.1.11 => 2.2.4
The text was updated successfully, but these errors were encountered: