Open
Description
Our @GraphQlExceptionHandler
example in the reference documentation shows the following:
@GraphQlExceptionHandler
public GraphQLError handle(BindException ex) {
return GraphQLError.newError().errorType(ErrorType.BAD_REQUEST).message("...").build();
}
Doing so would return the error in the error map, but would miss critical information like "path" and "location".
You can get a better result with:
@GraphQlExceptionHandler
public GraphQLError handle(DataFetchingEnvironment environment, IllegalStateException ex) {
return GraphqlErrorBuilder.newError(environment).errorType(ErrorType.BAD_REQUEST).message("...").build();
}
We should consider whether we should document this approach, or make available a GraphqlErrorBuilder
parameter for error handlers with location/path information available from the environment.