Skip to content

Refine null handling for toEntity and toEntityList in ClientResponseField #525

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

Closed
rstoyanchev opened this issue Nov 4, 2022 · 0 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@rstoyanchev
Copy link
Contributor

The toEntity and toEntityList methods throw FieldAccessException if the field is null, with the idea that a field either has a value, or otherwise is set to null in case of a field error. This is true generally, but a field could also be null without any errors, e.g. if it is optional.

For 1.1 we'll refine toEntity in ClientResponseField to return null if the field value is null, but response is neither invalid, nor there are field errors. Likewise toEntityList to return an empty list in the same scenario.

Note that a similar change was made for GraphQlClient#retrieve some time ago, in 3c30376, so this would align the two. The retrieve method actually delegates to ClientResponseField#toEntity internally but needs to perform a more strict check for field errors even when a field value is present, because with retrieve the response is not used directly, and such errors would be missed otherwise.

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

1 participant