Skip to content

throw if it's impossible to coerce boolean value #15

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

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

olegrok
Copy link
Collaborator

@olegrok olegrok commented Jul 11, 2021

Graphql spec states:

Input Coercion
When expected as an input type, only boolean input values are accepted.
All other input values must raise a request error indicating an incorrect type.

(https://spec.graphql.org/draft/#sec-Boolean)

So we can't coerce string, numeric and enum values. And here we
faced main issue - because graphql parser considered "False" and
"True" as enum values (correct boolean values is "true" and
"false"). And if user passed "False" value to boolean argument it
silently converted to true. This patch check that passed node type
is boolean and raises if it's not so.

Closes #14

@olegrok olegrok requested a review from rosik July 12, 2021 18:34
Graphql spec states:
> Input Coercion
When expected as an input type, only boolean input values are accepted.
All other input values must raise a request error indicating an incorrect type.

(https://spec.graphql.org/draft/#sec-Boolean)

So we can't coerce string, numeric and enum values. And here we
faced main issue - because graphql parser considered "False" and
"True" as enum values (correct boolean values is "true" and
"false"). And if user passed "False" value to boolean argument it
silently converted to true. This patch check that passed node type
is boolean and raises if it's not so.

Closes #14
@olegrok olegrok force-pushed the 14-fix-boolean-coerce branch from b3eea77 to a2fc502 Compare July 13, 2021 06:29
Copy link
Member

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Totktonada Totktonada merged commit 6512d2b into master Sep 29, 2021
@Totktonada Totktonada deleted the 14-fix-boolean-coerce branch September 29, 2021 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect boolean validation
3 participants