You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I can tell there are two ways to have explicit control over the errors reported in ExecutionResult.getErrors() using graphql-java-tools. (e.g. if you want explicit control over the extensions map in one or more errors):
Have the Resolver field methods return a DataFetcherResult object and populate it however you see fit with your own custom GraphQLError objects.
Create a custom error class that extends RuntimeException and implements GraphQLError which is then thrown from the Resolver methods.
In the latter case I don't understand what exactly is the expected behavior. Experimentally it seems that the final GraphQLError object found in ExecutionResult.getErrors() is a merge between the custom data I put into it, and data that GraphQL added to it.
For example, even if I don't put in the exception type in the extensions map, the result will still contain the exception type (e.g. DataFetchingException).
So what are the semantics of doing that? Is there actual logic to check if the error being thrown from a Resolver method implements GraphQLError? Or am I missing something?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As far as I can tell there are two ways to have explicit control over the errors reported in ExecutionResult.getErrors() using graphql-java-tools. (e.g. if you want explicit control over the extensions map in one or more errors):
Have the Resolver field methods return a DataFetcherResult object and populate it however you see fit with your own custom GraphQLError objects.
Create a custom error class that extends RuntimeException and implements GraphQLError which is then thrown from the Resolver methods.
In the latter case I don't understand what exactly is the expected behavior. Experimentally it seems that the final GraphQLError object found in ExecutionResult.getErrors() is a merge between the custom data I put into it, and data that GraphQL added to it.
For example, even if I don't put in the exception type in the extensions map, the result will still contain the exception type (e.g. DataFetchingException).
So what are the semantics of doing that? Is there actual logic to check if the error being thrown from a Resolver method implements GraphQLError? Or am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions