The problem (current behaviour)
When a GraphQL schema includes input fields accepting arrays with default values, such as:
someField: [String!]! = []
Then the generated TypeScript code will include an invalid line:
someField: z.array(z.string()),
resulting in the schema rejecting undefined value during parsing. The GraphQL API request would still work when the input object is sent without such a property (lacks a value).
Expected behaviour
When generating schemas, such fields should either be generated with a default value or made optional, or both:
someField: z.array(z.string()).default([]),
someField: z.array(z.string()).optional(),
someField: z.array(z.string()).default([]).optional(),
I've seen it for String, enum and object (another input type) arrays.