-
Notifications
You must be signed in to change notification settings - Fork 289
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
bug: Optional null fields are not returned #1936
Comments
Could this be a configuration error? Is there a way I can poke at the serializer inside of DGS? |
I don't seem to be able to reproduce this behavior. I do see the null fields if they are optional and requested for in the query.
where director is a. nullable field:
|
Separately, are you using the new spring-graphql integration: https://netflix.github.io/dgs/spring-graphql-integration/? If not switching to that would be good as well. |
Sounds like a configuration problem then. I'll update if I can fix it locally, maybe that can help someone else |
Fixed it locally, so closing this ticket. DGS uses Jackson; the Custom Object Mapper DGS Documentation suggests that this can customized by adding a Jackson2ObjectMapperBuilder to the Spring Context. This doesn't prevent other autowired configurations from then further customizing the object mapper, however; this is what was happening in our case. Spring magic doing spring magic things. If you run into this, try and hunt down where the ObjectMapper is being reconfigured. In our case, it was simpler to explicitly create a not a Jackson2ObjectMapperBuilder bean, as the docs suggest, but rather the MappingJackson2HttpMessageConverter itself. |
EDIT: Turns out to be a spring configuration error, other dependencies were reconfiguring the jackson object mapper. See the resolution below.
Observed in DGS 8.7.1 - null return values are not being returned.
Expected behavior
Given the following schema
and a query asking for both fields
and a server that contains a Foo object with
required := "required"
,optional := null
,then the DGS query should return with
Actual behavior
The
optional
field is not returned; the response ends up beingThis runs counter to the graphQL spec - https://spec.graphql.org/draft/#sec-Value-Completion - and breaks some client integrations, such as the one from Apollo.
Steps to reproduce
Start a DGS server with the above schema, execute the query against it. Or more generally, just query an optional type that ends up being null.
The text was updated successfully, but these errors were encountered: