"typescript-operations@2.2.1" + "avoidOptionals: true" generating "| undefined"
See original GitHub issueDescribe the bug
Starting in typescript-operations@2.2.1, avoidOptionals: true is appending | undefined; The | undefined should not be present with avoidOptionals: true.
This was not happening in typescript-operations@2.2.0. In 2.2.0, the package correctly generates x | null.
To Reproduce Steps to reproduce the behavior:
Live example https://codesandbox.io/s/icy-browser-u7p8q?file=/codegen.yml:180-201
- My GraphQL schema:
type Query {
user(id: ID!): User!
}
type User {
id: ID!
username: String!
email: String
}
- My GraphQL operations:
query user {
user(id: 1) {
id
username
email
}
}
- My
codegen.ymlconfig file:
schema: schema.graphql
documents: document.graphql
generates:
types.ts:
config:
avoidOptionals: true
plugins:
- typescript
- typescript-operations
Expected behavior
Maybe types generate x | null, not x | null | undefined.
Environment:
- OS:
@graphql-codegen/...:- NodeJS:
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
typescript-operations - GraphQL Code Generator
This plugin generates TypeScript types based on your GraphQLSchema and ... It generates types for your GraphQL documents: Query, Mutation, ...
Read more >Property 'cursor' does not exist on type X, null or undefined ...
I was using SvelteKit without the amazing "strict": true in tsconfig.json until today. I have this code generated (with codegen) from a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Verified that this is fixed, thank you
Ok I just found myself again already solving this 😕 https://github.com/dotansimha/graphql-code-generator/pull/7104