-
Notifications
You must be signed in to change notification settings - Fork 318
Document how to customize global, request validation errors that prevent execution #487
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
In an interceptor, We can expand the reference docs a bit with this use case in mind. |
I appreciate the quick response! That sounds like it should work nicely. I will give that a go and report any problems or use cases that it does not cover. Thanks! |
I took a stab at using this approach. It mostly works, but I run into a problem where I don't have the information I need to create a good error message. For example, in the Is there a way to get the field name that is missing or invalid in the |
I think this is more of a GraphQL Java question now. You might want to ask there for further options. Feel free to comment here later with more information or a link to an external discussion. |
That makes sense. I created a ticket: graphql-java/graphql-java#2964 |
I apologize if I missed it, but I did a scrub of the documentation and I could not find anything about how to handle returning custom responses for request that don't pass schema validation.
Right now, I am seeing something like the following returned from this framework:
This does provide the relevant information for someone experienced with GraphQL because it mentioned the field
name
is aString!
. However, I would like to return a simplified message such as "Thename
field is required in theMyInputObject
when making the mutation someMutationCall", or something like that.I poked around the code base a bit and found that the
org.springframework.graphql.execution.DefaultExecutionGraphQlService
class has anexecute
method. If I create my own implementation and register it as a bean I see that the execute method is called and there I can transform the above error into something more beginner developer friendly.There are two problems with the above approach. First, the
DefaultExecutionGraphQlService#execute
method is final, so I can't just override it, I have to create a whole new custom implementation of the interface. Second, I don't really like handling this in theexecute
method. Instead, I really like the approach that was taken with theDataFetcherExceptionResolverAdapter
where we can just override thecom.opengov.coa.definition.adapter.http.errors.CoaDefinitionErrorHandler#resolveToMultipleErrors
method. It would be great if there was something similar to that for validation of the request.I did find this existing ticket, but it is a bit different.
The text was updated successfully, but these errors were encountered: