-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InputMaybe
should explicitly include undefined
#10005
Comments
undefined
if avoidOptionals
is not setundefined
undefined
InputMaybe
should explicitly include undefined
Hi @ericbf inputMaybeValue can be used to add const config: CodegenConfig = {
// ...
generates: {
'path/to/file.ts': {
plugins: ['typescript'],
config: {
inputMaybeValue: 'T | null | undefined' // Add undefined to inputMaybeValue
}
}
}
} |
I'll close this issue, but if this doesn't answer your question, please @ me and let me know to re-open 🙂 |
@eddeee888 I should have specified I’m using the client preset, and this option doesn’t work when using the client preset. I’ve updated the issue description accordingly. |
InputMaybe
should explicitly include undefined
InputMaybe
should explicitly include undefined
(client preset)
InputMaybe
should explicitly include undefined
(client preset)InputMaybe
should explicitly include undefined
We are having the same Problem. |
Which packages are impacted by your issue?
@graphql-codegen/add
@graphql-codegen/cli
@graphql-codegen/typescript
@graphql-codegen/typescript-operations
Describe the bug
When using the typescript compiler option
"exactOptionalPropertyTypes": true
, the fact thatInputMaybe<T>
does not explicitly includeundefined
makes it hard to use as you can no longer pass optional values to query variables.InputMaybe
should explicitly include undefined to allow passing optional values to optional variables in queries.Your Example Website or App
https://stackblitz.com/edit/github-txjvxl?file=query.ts
Steps to Reproduce the Bug or Issue
npx tsc
to see it)Expected behavior
No compilation error. Since input variable
id
is optional, it should allow an optional value to be set to it.Screenshots or Videos
No response
Platform
graphql
version: ^16.2.0@graphql-codegen/add
version: ^5.0.0@graphql-codegen/cli
version: ^4.0.1@graphql-codegen/typescript
version: ^4.0.1@graphql-codegen/typescript-operations
version: ^4.0.1Codegen Config File
Additional context
There’s an option to customize the
InputMaybe
type, but when using some presents, like the client preset, the option is not available. I feel codegen should work in a way compatible with at least this relatively non-niche typescript config.The text was updated successfully, but these errors were encountered: