This repository was archived by the owner on Sep 27, 2023. It is now read-only.
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Union fields incorrectly generating type declarations #201
Open
Description
for the definition:
type PostNotFound implements Node {
id: ID!;
}
type PostMoved implements Node {
id: ID!;
target: Post!;
}
type Post implements Node {
id: ID!;
body: String!;
author: String!;
}
union BlogResult = Post | PostNotFound | PostMoved;
type Blog {
node: BlogResult;
}
and the query:
query BlogPostQuery {
blog {
... on PostNotFound {
__typename
}
... on Post {
body
author
}
}
}
Error:
The types generated doesn't allow me to discriminate unions:
export type BlogPostQuery = {
readonly blog: {
readonly __typename: "PostNotFound";
readonly body?: string;
readonly author?: string;
}
}
To me that is wrong, because the typename PostNotFound
doesnt have those fields on it.
Expected:
export type BlogPostQuery = {
readonly blog: {
readonly __typename: "PostNotFound";
} | {
readonly __typename: "Post";
readonly body: string;
readonly author: string;
}
}
or would I need to ask for __typename
on every union member, or on field for that matter.
Logging so I don't forget, will raise a fix PR soon
Metadata
Metadata
Assignees
Labels
No labels