Skip to content

Methods that access the resopnse should raise GraphQlException consistently #1219

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

Open
GeorgEchterling opened this issue May 27, 2025 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@GeorgEchterling
Copy link

When calling ClientResponseField.toEntity(someClass) on a field that cannot be deserialized into the given type, the method will throw an HttpMessageNotReadableException.

Spring MVC's ResponseEntityExceptionHandler will unfortunately convert this into a 400 Bad Request response, while this error should actually be treated as an internal server error. (The error was caused because the GraphQL response could not be read.)

It would be nice if ClientResponseField.toEntity could wrap this exception in a way that distinguishes it from actual client errors.

Spring GraphQL version: 1.4.0

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 27, 2025
@rstoyanchev
Copy link
Contributor

rstoyanchev commented May 29, 2025

That makes sense. Methods to access the response already throw FieldAccessExceptions, an extension of GraphQlClientException. We could wrap any others as GraphQlClientException similar to what RestClient does for such errors.

@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels May 29, 2025
@rstoyanchev rstoyanchev added this to the 2.0.0-M1 milestone May 29, 2025
@rstoyanchev rstoyanchev self-assigned this May 29, 2025
@rstoyanchev rstoyanchev changed the title ClientResponseField.toEntity throws HttpMessageNotReadableException Methods that access the resopnse should raise GraphQlException consistently May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants