Closed schmt5 closed 1 week ago
I mean, we can't really tell you if it's an issue in your application without a reproduction 😅 you can look at the changes done in 7.1.1 which is only 1 and extrapolate that to your case https://github.com/urql-graphql/urql/blob/main/exchanges/graphcache/CHANGELOG.md i.e. are you writing an abstract/concrete type? Are you selecting that? .... We need more information that goes outside of "something breaks".
One thing we can derive from invariant 4 being thrown is that you are using schema-awareness.
EDIT: I think I know a possible fix is to change this line to isMatching || (currentOperation === 'write' && !ctx.store.schema)
trying that is probably your best bet 😅
In the same situation, only in query with union. Going back to version 7.1.0 there are no problems.
Invalid field: The field `activity` does not exist on `User`, but the GraphQL document expects it to exist.
Traversal will continue, however this may lead to undefined behavior!
(Caused At: "fetchNotificationGroups" query, "NotificationNodeCommon" Fragment, Inline Fragment on "User", "TeamCommon" Fragment)
https://bit.ly/2XbVrpR#4
Invalid undefined: The field at `activity` is `undefined`, but the GraphQL query expects a scalar (number, boolean, etc) for this field.
(Caused At: "fetchNotificationGroups" query, "NotificationNodeCommon" Fragment, Inline Fragment on "User", "TeamCommon" Fragment)
https://bit.ly/2XbVrpR#13
Invalid field: The field `viewerIsMember` does not exist on `User`, but the GraphQL document expects it to exist.
Traversal will continue, however this may lead to undefined behavior!
(Caused At: "fetchNotificationGroups" query, "NotificationNodeCommon" Fragment, Inline Fragment on "User")
https://bit.ly/2XbVrpR#4
Invalid undefined: The field at `viewerIsMember` is `undefined`, but the GraphQL query expects a scalar (number, boolean, etc) for this field.
(Caused At: "fetchNotificationGroups" query, "NotificationNodeCommon" Fragment, Inline Fragment on "User")
https://bit.ly/2XbVrpR#13
Invalid field: The field `threadId` does not exist on `User`, but the GraphQL document expects it to exist.
Traversal will continue, however this may lead to undefined behavior!
(Caused At: "fetchNotificationGroups" query, "NotificationNodeCommon" Fragment, Inline Fragment on "User", "CommentCommon" Fragment)
https://bit.ly/2XbVrpR#4
// ... and many other similar things
Same situation as above user.
query GetEmployee {
employee {
__typename
... on Employee {
email
name {
__typename
display
}
sso
}
... on EmployeeNotFound {
email
message
sso
}
}
}
Nets this output:
Invalid field: The field `message` does not exist on `Employee`, but the GraphQL document expects it to exist. Traversal will continue, however this may lead to undefined behavior! (Caused At: "GetEmployee" query, Inline Fragment on "Employee")
We are aware this could be an issue with our non compliant schema but posting just in case.
Thanks for the quick reply. I will see if I can provide a reproduction.
The possible solution is posted as a canary, in the future it would be much easier for someone to try the fix I posted 😅 you can do so now by installing the canary version of graphcache, for the record, if someone is encountering this without schema-awareness, we need a reproduction...
Describe the bug
After updating from
7.1.0
to version7.1.1
we encouter an error message invalid field (https://commerce.nearform.com/open-source/urql/docs/graphcache/errors/#4-invalid-field).Inside
exchanges > cacheExchange > updates > Mutation
a Mutation triggers a runtime error, because an entity isnull
.I'm not sure if this is a bug or a problem in our codebase, but this error only appears after updating to
7.1.1
.Thank's for a reply
Reproduction
I will not provide a reproduction in the first step, because I'm not sure if this is a real bug or a problem in our codebase.
Urql version
urql v4.1.0 @urql/exchange-graphcache v7.1.1
Validations