-
Couldn't load subscription status.
- Fork 1.4k
Closed
Labels
stage/5-alpha-release-testingThe pull request is merged, an alpha release is available, to be testedThe pull request is merged, an alpha release is available, to be tested
Description
Describe the bug
The @skip and @include directives seem to be generating optional types for GraphQLList fields, even when avoidOptionals is true.
To Reproduce
Steps to reproduce the behavior:
https://codesandbox.io/s/practical-swanson-b93wg
- My GraphQL schema:
type Query {
me: User!
}
type User {
messages: [Message!]!
}
type Message {
content: String!
}- My GraphQL operations:
query MyQuery($include: Boolean!) {
me {
messages @include(if: $include) {
content
}
}
}- My
codegen.ymlconfig file:
schema: schema.graphql
documents: document.graphql
generates:
types.ts:
plugins:
- typescript
- typescript-operations
config:
avoidOptionals: true
nonOptionalTypename: trueExpected behavior
I expect TypeScript optionals not to be included in the generated output.
Actual behavior
export type MyQueryQuery = (
{ __typename: 'Query' }
& { me: (
{ __typename: 'User' }
& { messages?: Maybe<(
{ __typename: 'Message' }
& Pick<Message, 'content'>
)> }
) }
);messages is optional.
Environment:
- OS: MacOS Big Sur (11.6)
- "@graphql-codegen/add": "2.0.2",
- "@graphql-codegen/cli": "1.20.1",
- "@graphql-codegen/typescript": "1.21.0",
- "@graphql-codegen/typescript-operations": "1.17.14",
- "graphql": "15.5.0"
Additional context
Probably related to this PR:
#5104
Metadata
Metadata
Assignees
Labels
stage/5-alpha-release-testingThe pull request is merged, an alpha release is available, to be testedThe pull request is merged, an alpha release is available, to be tested