Which packages are impacted by your issue?
@graphql-codegen/typescript
Describe the bug
Since #3836 fields adorned with @include or @skip directives are correctly treated as optional:
query getUsers($includeName: Boolean!) {
users {
id
name @include(if: $includeName)
}
}
becomes
export type GetUsersQuery = (
{ users: Array<(
{ id: string, name?: string }
& { __typename?: 'User' }
)> }
& { __typename?: 'Query' }
);
However, when the conditional field is aliased, it's treated as mandatory:
query getUsers($includeName: Boolean!) {
users {
id
userName: name @include(if: $includeName)
}
}
becomes
export type GetUsersQuery = (
{ users: Array<(
{ id: string, userName: string } // no question mark in sight
& { __typename?: 'User' }
)> }
& { __typename?: 'Query' }
);
Your Example Website or App
Steps to Reproduce the Bug or Issue
Alias a conditional field (i.e. one with @include or @skip directive). It's no longer treated as optional in the generated type.
Expected behavior
Fields adorned with @include or @skip should be treated as optional in the generated type, even if they are aliased.
Screenshots or Videos
No response
Platform
-
Codegen Config File
No response
Additional context
No response
Which packages are impacted by your issue?
@graphql-codegen/typescript
Describe the bug
Since #3836 fields adorned with
@includeor@skipdirectives are correctly treated as optional:becomes
However, when the conditional field is aliased, it's treated as mandatory:
becomes
Your Example Website or App
Steps to Reproduce the Bug or Issue
Alias a conditional field (i.e. one with
@includeor@skipdirective). It's no longer treated as optional in the generated type.Expected behavior
Fields adorned with
@includeor@skipshould be treated as optional in the generated type, even if they are aliased.Screenshots or Videos
No response
Platform
-
Codegen Config File
No response
Additional context
No response