-
Notifications
You must be signed in to change notification settings - Fork 30
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
Rolling back cache due to error: InvalidPayloadError: unsupported transition from a non-entity value to an entity #311
Comments
So the error here is that you originally selected a field as a non-entity
(e.g. without an `id` field), but in a subsequent request, selected it as
an entity (with an `id`).
From the cache's point of view, this is an ambiguous update: it can't know
if the first value is the same, or a different entity (and whether it
should merge values, or replace them)
The only safe thing to do would be to replace, but that breaks assumptions
and potentially invalidates previously executed queries (if they selected
any fields not selected by the new fragment)
…---
TL;DR - make sure all fragments for that entity select the `id` field
On Fri, Feb 16, 2018, 8:32 AM Pat Finnigan ***@***.***> wrote:
*Summary*:
Encountered: Rolling back cache due to error: InvalidPayloadError:
unsupported transition from a non-entity value to an entity.
[image: 36220100-54186f2e-116e-11e8-91be-1bb49e629000]
<https://user-images.githubusercontent.com/1305608/36317597-5e409992-12f2-11e8-9a89-08aa7c48e859.png>
This occurred when refetching a different subfragment of a note under a
different query.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#311>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAChnUm88Bp_FpaL1oVeEk5PLX2gGA1fks5tVa2KgaJpZM4SIlwh>
.
|
TL;DR - make sure all fragments for that entity select the |
Let's leave this issue open as a reminder that that error could use some more documentation |
I'm seeing this error as well, but not for a cache rollback. I'm trying to writeFragment and change an entity that was a sub-entity of a larger query. A 'Game' object (fetched with a getGame query) has multiple Round objects in an array. I'm trying to writeFragment to one of the rounds with _key (id field), but adding the id field as suggested here does not work. Do I need to have a getRound query for each Round object and do a writeQuery instead? Seems like one fetch of a game and 12 rounds is more efficient. I just want to update this fragment of 'scores' key on the round object. A view of the cache is here: |
Hmm, @boorad, the cache generally doesn't care how you reach a given entity (via query, fragment, etc); for this error, I think what is likely is that you've queried an entity once without If possible, can you paste in the gql for the query that's executed, as well as the fragment passed to the writeFragment. You can probably boil this down to just those two calls triggering the error |
…also, wow, I really need to address #66 :( |
So, first, here's my cache config:
Then,
and fragment:
Perhaps the fragment has to use the key on Game, then on Round to get where we need? i.e. a more nested gql. |
And for the cache.writeFragment({
id: 'someroundid',
fragment: scoreFragment,
data: {…}
}); ? |
correct:
|
Welp, I think I'm going to call this one a bug! Thanks for the details here, I've got a reproduction case that hits this 👍 The cache is getting confused (ignoring) the fact that you've explicitly provided an id for that entity (the Round), but have not included the identity in the payload to merge. So, as a workaround for now, add fragment my_round on Round {
_key
scores
} (This may be pretty tricky to fix, without adding knowledge of schemas to Hermes, too) |
@nevir your work-around gets past the error, but doesn't update my UI's that are supposedly subscribed to the cache changes (I thought for |
@jamesreggio has convinced me that the current behavior is not desirable 👍 The main thing that pushed it over the edge is an example where the cache becomes, effectively, corrupt if you end up writing the wrong type of node to the cache first. Say you have a top level So, proposed new behavior is:
|
Here's a stawman implementation of what @nevir described above: jamesreggio@64eb2d8 I'll report back with how this performs. |
Hi @jamesreggio. I'm curious to hear how that change worked. We recently switched to Hermes and this behavior was somewhat surprising, so I'm considering applying it to our local fork. I'm also looking forward to hopefully contributing back to Hermes in the near future! |
Hi @samkline — no problems so far! |
@jamesreggio @nevir any update on getting the patch from 8/2/18 into master and released? Is this project dead or just in heavy sleep? |
Summary:
Encountered:
Rolling back cache due to error: InvalidPayloadError: unsupported transition from a non-entity value to an entity
.This occurred when refetching a different subfragment of a note under a different query.
The text was updated successfully, but these errors were encountered: