-
Notifications
You must be signed in to change notification settings - Fork 1.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
ID! validation is returning an error of type string. #798
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Just adding another heartbeat here (to keep the stale bot reaper from killing this issue). |
@cfilby that probably will address the issue. Have those changes been released/tagged? I'll test and report back. |
@thedodd it's merged into master but hasn't yet been included in a tagged release. You could test it directly by using the latest master commit instead of a versioned release? |
I close this issue. if its still haven't solved, please mention to me. |
What happened?
When submitting a request where a literal integer is supplied by the client instead of a string literal for the
ID!
type, the framework's error handling is quite different. The error is presented to the error handler configured by the user, instead of just being flagged as a malformed request and returned as a 400 to the caller automatically.There appears to be a difference between the type validation of the high-level request object vs the validation of field parameters. This inconsistency complicates error handling, such that it is unclear where in the stack the error is coming from. Perhaps it would be good to use a more identifiable error type so that we can handle it appropriately in the error handler logic.
The question needs to be asked: "is this some unhandled error coming from bad business logic in my code (an ISE), or is this an error which can be presented as-is to the caller?"
What did you expect?
I expected consistency. This is a type validation error. The gqlgen stack should, arguably, be handling this error during the main validation phase and return an error before it ever leaves the gqlgen stack.
Minimal graphql.schema and models to reproduce
Then just query that field with an int instead of a string.
versions
gqlgen version
?v0.9.1
go version
?1.12.6
go modules
The text was updated successfully, but these errors were encountered: