-
Notifications
You must be signed in to change notification settings - Fork 259
fix(gateway-js): Default variables to an empty object when not provided #167
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
Conversation
Given a query like this: query MyQuery($arg: Int) { myQuery(arg: $arg) } In case the arg variable is not provided on the GraphQL request, even though it's not required, the Gateway would crash, since it would try to coearce a nullish variables object. This behavior is not expected behavior, since the GraphQL-JS library handle this nicely [1]. In order to prevent further crashes, a check was added it will simple provide an empty object to the getVariablesValues(), just like the original implementationl. [1]: https://github.com/graphql/graphql-js/blob/d6e760cf7060217bd25fa934bd104ff2400aad96/src/execution/execute.js#L347
@cabelitos: 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/ |
Hey guys, sorry. I did not know that I had to sign the CLA contract. I've just signed. |
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.
lgtm
Hey guys, any news on this one? |
ReproductionGiventype Query {
plan(id: ID): String
} and query Testing($arg:ID) {
plan(id:$arg)
} Then$ curl 'http://endpoint/graphql' \
-H 'Content-Type: application/json' \
--data-binary '{
"query": "query Testing($arg:ID) { plan(id:$arg) }"
}' Yields{"errors":[{"message":"Cannot convert undefined or null to object","extensions":{"code":"INTERNAL_SERVER_ERROR"}}]} |
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.
LGTM. Thanks so much for the contribution/fix!
@abernix thank you for the support! |
Released in |
Given a query like this:
In case the arg variable is not provided on
the GraphQL request, even though it's not required,
the Gateway would crash, since it would try
to coearce a nullish variables object.
This behavior is not expected,
since the GraphQL-JS library handle this
nicely (see https://github.com/graphql/graphql-js/blob/d6e760cf7060217bd25fa934bd104ff2400aad96/src/execution/execute.js#L347).
In order to prevent further crashes, a check
was added it will simple provide an empty
object to the getVariablesValues(), just
like the original implementationl.
Closes #196