Skip to content

[Breaking] fix(GraphQL): fix validation when we give non-string value in variable and expected type is string. #13

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
Feb 26, 2021

Conversation

JatinDev543
Copy link

@JatinDev543 JatinDev543 commented Feb 26, 2021

When we give variables in a request, then those are unmarshaled in dgraph code where any Int or Float is unmarshaled to json.Number.

While validating in gqlParser library we were checking Type.Kind() of these variables which is still string. So, we were not generating any error if we give Int or Float value and expected type is string. That is a bug and in our dgraph code it is giving a panic because we expected a string value but sometimes got Int or Float.

So now instead of Type.Kind() we compare Type().Name() of variable which will give Number if given variable is Int or Float.

This change will also make our implementation Graphql spec complaint.

@JatinDev543 JatinDev543 merged commit 6c9552e into master Feb 26, 2021
@JatinDev543 JatinDev543 deleted the jatin/Fix-stringPanic branch February 26, 2021 09:42
@JatinDev543 JatinDev543 changed the title fix(GraphQL): fix validation when we give non-string value in variable and expected type is string. fix(GraphQL): [Breaking] fix validation when we give non-string value in variable and expected type is string. Mar 11, 2021
@JatinDev543 JatinDev543 changed the title fix(GraphQL): [Breaking] fix validation when we give non-string value in variable and expected type is string. [Breaking] fix(GraphQL): fix validation when we give non-string value in variable and expected type is string. Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants