MapToListTypeAdapter nullability
See original GitHub issue(Using the default MapToListTypeAdapter)
Output types
If I have an object annotated like:
@GraphQLNonNull
@GraphQLQuery(name = "field")
public Map<@GraphQLNonNull String, @GraphQLNonNull String>getField() {
return null;
}
In the schema I get the field
field [mapEntry_String_String]!
The type mapEntry_String_String picks the non-nulls up fine for its fields, but I would expect the field to be of type
field [mapEntry_String_String!]!
as it doesn’t make sense to have a null map entry in the list.
Input types
If I have a field annotated like:
@GraphQLNonNull
@GraphQLInputField(name = "field")
private Map<@GraphQLNonNull String, @GraphQLNonNull String> field;
Then in the schema I get the field
field [mapEntry_String_String_input!]
I would expect it to be
field [mapEntry_String_String_input!]!
as it’s annotated to be non-null.
The object mapEntry_String_String_input
picks up the annotations fine for its own fields.
Is there something I’m missing a way to mark these non-null myself? Seems like a bug to me.
summary
- For output types it applies the
@GraphQLNonNull
annotation correctly, but should change to make the generatedmapEntry
object always non-null. - For input types is applies the
@GraphQLNonNull
annotation to the generatedmapEntry
object instead of to the list itself, and should have themapEntry
object be always non-null.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Take annotations on private fields into account (also enables ...
SPQR never looks at private elements, so annotating a private field will not work (with the exception of @GraphQLInputField with Jackson, ...
Read more >graphql.schema.GraphQLNonNull.<init> java code examples ...
A factory method for creating non null types so that when used with static imports allows * more readable code such as *...
Read more >Nullability - GraphQL Nexus
This is the effect where, within a schema runtime, a null or error received from some data ... Nexus defaults to both inputs...
Read more >Get the detected generic type inside Jackson's JsonDeserializer
... beanProperty) throws JsonMappingException { //beanProperty is null when the type to deserialize is the top-level type or a generic type, ...
Read more >io.leangen.graphql.annotations.GraphQLNonNull Java Exaples
withTypeAdapters(new MapToListTypeAdapter()) . ... findById(id); if (toDo != null) { toDoRepository.deleteById(id); return true; } else { return false; } }.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, this is an exceptional case indeed, because it is Jackson that looks at private fields and not SPQR, but Jackson is configured to respect
@GraphQLInputField
annotations, so it seems surprising.I opened a separate issue #160 about annotation on private fields, so track that one for progress.
I made the entries non-nullable, so that change will land in 0.9.8. The transparent treatment of private fields is in popular demand, so I’m starting the work on it. But I don’t want to delay the 0.9.8 release any further, so this will land in 0.9.9.
In the meantime, I’ll try replicating your setup, but if you have the time a simple test demonstrating the behavior you’re seeing would be helpful.
Cheers!