We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The generated types for fields that use aliases don't contain the optional operator ?. This throws a ts error when strictNullChecks is enabled.
?
strictNullChecks
https://stackblitz.com/edit/github-hxvpzz-f9camz?file=types.ts
document.graphql
yarn codegen
types.ts
UserQuery.alias
UserQuery.user
Expected to see something like below. Fields with conditional directives (with or without aliases) should work similary.
export type UserQuery = { __typename?: 'Query'; alias?: { __typename?: 'User'; id: string; username: string; email: string }; user?: { __typename?: 'User'; id: string; username: string; email: string }; };
No response
graphql
@graphql-codegen/typescript-operations
Maybe we can pass the isConditional variable in L532. Currently, only the name has access on this.
isConditional
name
const isConditional = hasConditionalDirectives(field) || inlineFragmentConditional; linkFields.push({ - alias: field.alias ? this._processor.config.formatNamedField(field.alias.value, selectedFieldType) : undefined, + alias: field.alias ? this._processor.config.formatNamedField(field.alias.value, selectedFieldType, isConditional) : undefined,
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
The generated types for fields that use aliases don't contain the optional operator
?
. This throws a ts error whenstrictNullChecks
is enabled.Your Example Website or App
https://stackblitz.com/edit/github-hxvpzz-f9camz?file=types.ts
Steps to Reproduce the Bug or Issue
document.graphql
and see that we have 2 fields with and without aliases.yarn codegen
types.ts
and notice thatUserQuery.alias
isn't an optional property whereasUserQuery.user
works correctly.Expected behavior
Expected to see something like below. Fields with conditional directives (with or without aliases) should work similary.
Screenshots or Videos
No response
Platform
graphql
version: 16.6.0@graphql-codegen/typescript-operations
version(s): 2.5.3Codegen Config File
No response
Additional context
Maybe we can pass the
isConditional
variable in L532. Currently, only thename
has access on this.The text was updated successfully, but these errors were encountered: