Why are fragments generated with typescript-operation T | null | undefined? #7137
Answered
by
alexrhogue
alexrhogue
asked this question in
Q&A
-
Hey I've been trying to understand why graphql operation fragments for nullable fields are generated with For example: # Schema
type User implements Node {
id: ID!
username: String # this field is nullable
role: Role!
}
# Operations
query findUser($userId: ID!) {
user(id: $userId) {
...UserFields
}
}
fragment UserFields on User {
id
username
role
} Generate the following export type UserFieldsFragment = {
id: string,
username: string | null | undefined, // <- this field
role: Types.Role
}; Graphql will return what is asked for in a query, so it will always return either Can anyone:
Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
alexrhogue
Mar 29, 2022
Replies: 1 comment
-
Seems fixed in the recent versions |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
alexrhogue
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems fixed in the recent versions