Here is a repo with the reproduced issue:
https://github.com/cvle/apollo-empty-query-error
It basically creates a new object in the cache, but omits a field that was previously
requested by a query.
After the update, the query data becomes empty without logging any errors.
This is debatable. Several ideas are:
! and fail! and omit missing fields from queryI personally tend to 4.
If I understand the issue correctly, you're doing an update, but the shape of the object you're inserting into the list does not have all the fields that another query is expecting. Is that correct?
Because Apollo Client won't read partial data, you get no result.
I don't think this should work, but I believe that this used to throw an error, so we should find out why errors are no longer thrown when this happens.
@cesarsolorzano would you like to run the reproduction and find out what's going on?
@helfer sure thing, I'll check it out soon!
@helfer so the reproduction isn't using readQuery to read the the data after it's updated (which would have thrown the error).
Therefore, the problem here is the same as discussed before: when reading from the store an error is thrown but since it's being catched here there's not warning or error message.
If I understand the issue correctly, you're doing an update, but the shape of the object you're inserting into the list does not have all the fields that another query is expecting. Is that correct?
Because Apollo Client won't read partial data, you get no result.
I don't think this should work
But the schema clearly allows that that field is optional, so I kinda expect that when I update the cache and don't include the field, it should be ok, as it is optional.
Just checked Modern Relay and they allow this kind of cache update, no matter if the field is required or optional.
@cvle if you don't want to provide a field when updating the cache, you must provide a null-like value instead of omitting it!
fixed in apollographql/apollo-client#1638
Most helpful comment
@helfer sure thing, I'll check it out soon!