-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add more details to static errors raised after the query run #5241
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
Comments
Hey @sobrinho, we can probably improve this along those lines, or at least support a setup like you're suggesting. Here's where those errors are created: graphql-ruby/lib/graphql/execution/interpreter/runtime.rb Lines 475 to 477 in a5451ab
A couple options right off the bat:
I'll try to take a look at these soon but I thought I'd go ahead and mention them in case you want to give either one a try. |
Coincidentally this is related to #5239 |
Is your feature request related to a problem? Please describe.
Static errors that makes the query invalid points straight to the error location, i.e.:
But static errors such as non-nullable field does not, i.e.:
The problem is that it makes really hard to debug since you can have a query that return multiple nodes such as:
If you have 100 employees, which one did return an empty status?
Describe the solution you'd like
Would be nice to have the error wrapped pointing to the specific object that failed the validation, i.e.:
Describe alternatives you've considered
We built a
GraphQL::Schema::FieldExtension
to add this context to unhandled exceptions but it doesn't trigger for static errors.Be aware of the two kinds of static errors: on the query (missing argument, undefined field) and on the result (non-nullable fields).
While the first one doesn't have a backtrace, it does show the line and column on the query and the path.
The second one doesn't have a backtrace and points to the type/field that failed but not the object or a backtrace.
Could be interesting to have the backtrace as well like:
Probably the location is not trackable in all scenarios like when the object is a Hash, but we could have something designed for the other kinds where the field is not implemented on the type:
Additional context
While this extremely useful for debugging, it might leak important data if misused and rendered to the user.
What I'm thinking of is that those information would be added to
data.query.static_errors
anddata.context.errors
or conditionally rendered if theRails.env
isdevelopment
ortest
.Alternatively, it could be a feature flag or a
use GraphQL::DetailedStaticErrors unless Rails.env.production?
.The text was updated successfully, but these errors were encountered: