you can see that we are avoidOptionals: { inputValue: false } for that value
the output does avoid optionals, despite being instructed not to. you can see the following output:
export type FindUserQueryVariables = Exact<{
userId: Maybe<Scalars['ID']>;
}>;
Interestingly, if you flip object: false as well, suddenly the correct behavior takes for inputValue: false. Perhaps these are unintentionally coupled?
To produce an optional value for the userId?: Maybe<Int> field:
expected:
export type FindUserQueryVariables = Exact<{
userId?: Maybe<Scalars['ID']>;
}>;
actual:
export type FindUserQueryVariables = Exact<{
userId: Maybe<Scalars['ID']>;
}>;
Environment:
latest, deployed on graphql-code-generator website
Additional context
This PR https://github.com/dotansimha/graphql-code-generator/pull/5113, in the bottom comment, seems to suggest that this design is intentional. However, object seems orthogonal to inputValue for avoidOptionals configuration, and produces an unexpected result. If they are not orthogonal, then inputValue should take precedence over object
Describe the bug
In the following live demo:
userId: ID
avoidOptionals: { inputValue: false }
for that valueInterestingly, if you flip
object: false
as well, suddenly the correct behavior takes forinputValue: false
. Perhaps these are unintentionally coupled?https://www.graphql-code-generator.com/docs/plugins/typescript-operations
To Reproduce
Codesandbox has been down for me. The schema, query, & config are listed below. The repro is quite simple :)
Stripped down version of the homepage demo:
codegen.yml
config file:Expected behavior
To produce an optional value for the
userId?: Maybe<Int>
field:expected:
actual:
Environment:
latest, deployed on graphql-code-generator website
Additional context
This PR https://github.com/dotansimha/graphql-code-generator/pull/5113, in the bottom comment, seems to suggest that this design is intentional. However,
object
seems orthogonal toinputValue
foravoidOptionals
configuration, and produces an unexpected result. If they are not orthogonal, theninputValue
should take precedence overobject