Skip to content
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

Fixing panic when non array value is passed to array type #120

Merged
merged 2 commits into from
May 29, 2018
Merged

Fixing panic when non array value is passed to array type #120

merged 2 commits into from
May 29, 2018

Conversation

andrewmunro
Copy link

Encountered a panic similar to issue #110 when passing an object to an array type.

@imiskolee
Copy link

imiskolee commented May 25, 2018

@andrewmunro

can you share an example and detail?

@vektah
Copy link
Collaborator

vektah commented May 25, 2018

Thanks for the pr, a test would be the best way to give an example :)

@andrewmunro
Copy link
Author

👋 Added a test to the dataloader example to demonstrate this.

Essentially if you pass an object instead of an array in your query/mutation, gqlgen panics. Handling is not ideal as the field is now ignored with no errors, I imagine this will be fixed properly when @vektah introduces the new parser 🎉!

For now I hope this is sufficient to prevent app's from panic-ing with malformed input, without having some kind of middleware to recover the application...

@vektah
Copy link
Collaborator

vektah commented May 29, 2018

Yeah that definitely should be caught by validation and give a good message to the user, but the runtime shouldn't panic.

👍

@vektah vektah merged commit 94d5c89 into 99designs:master May 29, 2018
@andrewmunro
Copy link
Author

🎉 Thanks again @vektah

cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
…-invalid-array-type

Fixing panic when non array value is passed to array type
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.

3 participants