Skip to content

Missing location and path from @GraphQlExceptionHandler errors #1200

Open
@bclozel

Description

@bclozel

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.

Metadata

Metadata

Assignees

Labels

for: team-attentionAn issue we need to discuss as a team to make progressin: dataIssues related to working with datastatus: waiting-for-triageAn issue we've not yet triagedtype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions