Graphql-code-generator: How to express a list of nullable elements

Created on 19 Apr 2018  路  5Comments  路  Source: dotansimha/graphql-code-generator

Some of the elements of my query may be null, so I'm writing it like:

type Query {
    myList: [String]!
}

I should expect to get something like this, right?

interface Query {
    myList: (string | null)[]
}

but I get this

interface Query {
    myList: string[]
}

which is not quite right I think.

bug waiting-for-release

All 5 comments

Related:
https://github.com/dotansimha/graphql-code-generator/issues/155
https://github.com/dotansimha/graphql-code-generator/issues/138

It should be this way:
a: [String]! -> a: (string | null)[]
a: [String] -> a?: null | (string | null)[]
a: [String!]! -> a: string[]

Am I missing something?

@sundeer

@sundeer I'm fixing this issue right now, my results are:
Input:

          f1: String
          f2: Int!
          f3: [String]
          f4: [String]!
          f5: [String!]!
          f6: [String!]

Output:

          f1?: string | null; 
          f2: number; 
          f3?: (string | null)[] | null; 
          f4: (string | null)[]; 
          f5: string[]; 
          f6?: string[] | null; 

What do you think?

Done in 0.9.0 :)

sorry for not responding sooner but that looks complete.
btw - loving this repo!

Was this page helpful?
0 / 5 - 0 ratings