graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

Typescript: GraphQL type [String] should allow single strings

Open draco2007 opened this issue 6 years ago • 1 comments

If I have following input schema: input Test { value: [String]! }

The resulting Typescript schema looks like this: value: Array<Maybe<Scalars['String']>>;

So Typescript only allows arrays as "value" for an instance of "Test". But GraphQL specifications would allow a single sting.

I would expect the Typescript schema of "value" to look like this: value: Array<Maybe<Scalars['String']>> | Maybe<Scalars['String']>;

What do you think? Does it sound useful?

draco2007 avatar Nov 11 '20 12:11 draco2007

Thank you @draco2007 , tracking this here: https://github.com/dotansimha/graphql-code-generator/issues/4888

dotansimha avatar Nov 16 '20 07:11 dotansimha