Describe the bug
nullable fields are T | null | undefined instead of T | null
To Reproduce
Steps to reproduce the behavior:
type Character {
name: String!
nickname: String
}
codegen.yml config file:overwrite: true
schema: "http://localhost:4000/graphql"
documents: "src/**/*.graphql"
generates:
src/generated/graphql.generated.tsx:
config:
skipTypename: true
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo"
Expected behavior
I expect the generated models nickname property to be T | null:
Expected
type Character = {
name: Scalars['String'],
nickname: Maybe<Scalars['String']>,
}
not T | null | undefined:
Actual
type Character = {
name: Scalars['String'],
nickname?: Maybe<Scalars['String']>,
}
Environment:
Additional context
I saw issue #138 and understand people have different opinions on this. But we also have the config: maybeValue which you can use to set Maybe to be T | null | undefined..
Maybe the models properties could be reverted back to no-undefined and the default for maybeValue could be changed to T | null | undefined...?
@LarsJK I dealt with the recently and the solution was to set avoidOptionals: true in my config. See https://graphql-code-generator.com/docs/plugins/typescript#avoidoptionals-boolean-default-value-false for more info.
How did I not see that reading the docs 馃槻
Thanks @grxy !
Most helpful comment
How did I not see that reading the docs 馃槻
Thanks @grxy !