Can I generate correct union types for interface fields? #5125
-
Schema:
codegen.yml
types.ts export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in keyof Pick<T, K>]?: Maybe<Pick<T, K>[SubKey]> };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
Date: any;
};
export type Query = {
__typename?: 'Query';
me: User;
user?: Maybe<User>;
allUsers?: Maybe<Array<Maybe<User>>>;
search: Array<SearchResult>;
myChats: Array<Chat>;
};
export type QueryUserArgs = {
id: Scalars['ID'];
};
export type QuerySearchArgs = {
term: Scalars['String'];
};
export enum Role {
User = 'USER',
Admin = 'ADMIN'
}
export type Node = {
id: Scalars['ID'];
};
export type Foo = {
__typename?: 'Foo';
nodes: Array<Node>;
};
export type SearchResult = User | Chat | ChatMessage;
export type User = Node & {
__typename?: 'User';
id: Scalars['ID'];
username: Scalars['String'];
email: Scalars['String'];
role: Role;
};
export type Chat = Node & {
__typename?: 'Chat';
id: Scalars['ID'];
users: Array<User>;
messages: Array<ChatMessage>;
};
export type ChatMessage = Node & {
__typename?: 'ChatMessage';
id: Scalars['ID'];
content: Scalars['String'];
time: Scalars['Date'];
user: User;
}; Why is the field In the schema, |
Beta Was this translation helpful? Give feedback.
Answered by
dotansimha
Nov 29, 2020
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dotansimha
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
useImplementingTypes
will be available soon ;) Thank you for the PR!