-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Invalid non-nullable or required List Type variable should return UserInputError #6066
Conversation
@zeroshine: 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/ |
e.nodes[0].variable.name.value + | ||
'" of non-null type ".*!" must not be null.', | ||
), | ||
)) |
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.
Can you please use startsWith
?
Passing client-controlled values into RegExp is bad practice(even if they are sanitized by GraphQL parser) because it can lead to ReDoS.
Also can you please extract this check in separate function (e.g. isBadUserInputGraphQLError
) that checks if GraphQLError
matches?
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.
fix in 863fe02
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.
I think it's ok as a temporary solution until AS4 and ready to merge.
cc @glasser
Looks good. I rebased, added a test of another case I was curious about, and added a CHANGELOG. Hopefully we will eventually be able to rely on a fix to graphql/graphql-js#3169 instead of doing this heuristic. |
863fe02
to
5abf963
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 5abf963:
|
…rInputError (#6066) Co-authored-by: gchen02 <[email protected]> Co-authored-by: David Glasser <[email protected]>
The original way handle required or non-nullable UserInputError is not considering List Type variable. It returns
INTERNAL_SERVER_ERROR
instead ofBAD_USER_INPUT
The result of query
is
should be
check node type and replace
message.startWith
withmessage.match
to handle List type and single variable