-
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 error message generation #10411
Fix error message generation #10411
Conversation
🦋 Changeset detectedLatest commit: 0268e49 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 |
The netlify action is failing with |
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.
This subtly changes error message generation behavior in that it sets the message
to 'Error message not found.'
once at the end if none of the merged graphQLErrors
and clientErrors
have a message property instead of appending a new "not found" for each error that lacks a message
.
We evidently don't have tests for this behavior since all tests are passing, but would prefer to make this a backward-compatible change in order to get it out in a patch release.
Would you be open to adding a test case for preventing the undefined
case you mentioned in the description, @lovasoa, as well as reinstating the old logic?
@alessbell , the old behavior is a bug, isn't it ? Is there any reason to have an error message that says |
|
Name | Link |
---|---|
🔨 Latest commit | 430f779 |
Hi @lovasoa 👋 Thought I'd check in and see if you're still interested in moving this PR forward? No problem at all if not, but it would be great to land this simplification/small reduction in code here! I agree it's hard to imagine anyone relying on that particular behavior, but we do want to be mindful of potentially breaking changes in a sensitive codepath like this, especially at a new patch version (and I have certainly seen stranger things 😅) We can extract the generic error message into something reusable, remove the isNonNullObject(err)
? (err.message || ERROR_MESSAGE_NOT_FOUND)
: ERROR_MESSAGE_NOT_FOUND With |
@alessbell : done ✅ |
@lovasoa looks great! I see you've pulled in the changes from your other PR: can we keep those separate in the interest of getting this one merged? We can't change the behavior of |
a142519
to
9a80c95
Compare
ApolloError.graphQLErrors is typed as an array of GraphQLError in typescript, but it can actually contain any value at runtime, including null. This is even explicitly tested: https://github.com/apollographql/apollo-client/blob/caba6c191dcb7bee265d62aba131727c5536f4ef/src/core/__tests__/QueryManager/index.ts#L369-L376 This PR simplifies error message generation, and prevents ever creating the string 'undefined' as an error message. See: apollographql#10394
@alessbell , sorry, I had accidentally rebased on the wrong branch. It's fixed now |
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.
Thanks @lovasoa! A nice improvement in functionality and readability while reducing a few bytes in the generated code 🎉
ApolloError.graphQLErrors is typed as an array of GraphQLError in typescript, but it can actually contain any value
at runtime, including null. This is even explicitly tested:
apollo-client/src/core/__tests__/QueryManager/index.ts
Lines 369 to 376 in caba6c1
This PR simplifies error message generation, and prevents ever creating the string 'undefined' as an error message.
See: #10394
Checklist: