-
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
Fix watchFragment
reports complete=false
when from object is not identifiable
#12335
base: main
Are you sure you want to change the base?
Fix watchFragment
reports complete=false
when from object is not identifiable
#12335
Conversation
@ryo-manba: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
👷 Deploy request for apollo-client-docs pending review.Visit the deploys page to approve it
|
🦋 Changeset detectedLatest commit: 6dc4c34 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
❌ Docs preview failedThe preview failed to build. Build ID: ba84bc7fd4e44a0393adbc41 Errorsreact/api/react/components
|
Hey @ryo-manba 👋 Thanks for your patience! I'd actually like to dig a layer deeper and see if we can fix the issue at the root. It looks like anything having to do with a I can also reproduce the incorrect result using test.only("reports diffs incorrectly", async () => {
const cache = new InMemoryCache();
console.log(
cache.diff({
query: cache["getFragmentDoc"](gql`
fragment FooFragment on Foo {
foo
}
`),
id: cache.identify({}),
returnPartialData: true,
optimistic: true,
})
);
await new Promise((res) => {
const w = cache.watch({
query: cache["getFragmentDoc"](gql`
fragment FooFragment on Foo {
foo
}
`),
id: cache.identify({}),
returnPartialData: true,
immediate: true,
optimistic: true,
callback: (diff) => {
console.log("callback", diff);
res(void 0);
},
});
});
}); If you paste and run this, you'll notice that From what I can tell, that Let's see if we can fix it in the cache itself. Is this something you'd like to look into further? |
Thank you for the information! |
if (subFieldValue === void 0) { | ||
missing = missingMerger.merge(missing, { | ||
[subResultName]: `Can't find field '${ | ||
subSelection.name.value | ||
}' on ${ | ||
isReference(objectOrReference) ? | ||
objectOrReference.__ref + " object" | ||
: "object " + JSON.stringify(objectOrReference, null, 2) | ||
}`, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jerelmiller,
I’ve made a change to check if a field exists when handling FRAGMENT_SPREAD
.
The current implementation relies on complete: !missing
to determine if the result is complete:
However, some tests are failing due to this change.
Is there any issue with this approach? If you have any feedback, please let me know!
Closes #12003
Fixes an issue where
watchFragment
incorrectly reportedcomplete: true
when thefrom
object was not identifiable (cache.identify
returnedundefined
).This was created from the branch adds the failing test.
It might be better to merge that one first.