Handle lists and non-null properly
See original GitHub issueHello,
Right now gql-gen doesn’t check if !
(non-nullable) applies to a list or elements inside the list:
As a result, the list is considered required even when it isn’t:
GraphQL type | Expected Typescript Type | Actual Generated Type |
---|---|---|
[String] |
(string | null)[] | null |
string[] | null |
[String]! |
(string | null)[] |
string[] |
[String!] |
string[] | null |
string[] |
[String!]! |
string[] |
string[] |
More generally, GraphQL allows arbitrary nesting of list and non-null modifiers according to http://graphql.org/learn/schema/#lists-and-non-null .
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Handling Nulls Inside Lists where List Element Type is @NotNull
ObjectWithStringList defines strings as List, which means that users should expect that the strings inside the list are never null (List<String?> ...
Read more >Best way to check collections not null & null conditions
In short, let your methods return Collections.emptyList() instead of null and you've got one thing less to worry about. 2. if(list.
Read more >How to Handle NullPointerException in Java - freeCodeCamp
Before looping over the list, we need to put a null check on the list. If the null check is not present, then...
Read more >Using nullability in GraphQL
A field can either be nullable or non-null, and this tells you whether or not you ... For example, you can have a...
Read more >Removing all nulls from a List in Java | Baeldung
User management is very complex, when implemented properly. No surprise here. Not having to roll all of that out manually, ...
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
Fixed in 0.8.16. Thanks @FredyC !
@FredyC @dotansimha Thank you 🙌