Describe the bug
Optional types should be marked with ?
Current behavior:
export type CommentQuery = {
__typename?: 'Query';
currentUser: Maybe<{ __typename?: 'User'; login: string; html_url: string }>;
entry: Maybe<{
__typename?: 'Entry';
id: number;
createdAt: number;
commentCount: number;
postedBy: { __typename?: 'User'; login: string; html_url: string };
comments: Array<Maybe<{ __typename?: 'Comment' } & CommentsPageCommentFragment>>;
repository: { __typename?: 'Repository'; description: Maybe<string>; open_issues_count: Maybe<number>; stargazers_count: number; full_name: string; html_url: string };
}>;
};
Expected behavior:
export type CommentQuery = {
__typename?: 'Query';
currentUser?: Maybe<{ __typename?: 'User'; login: string; html_url: string }>;
entry?: Maybe<{
__typename?: 'Entry';
id: number;
createdAt: number;
commentCount: number;
postedBy: { __typename?: 'User'; login: string; html_url: string };
comments: Array<Maybe<{ __typename?: 'Comment' } & CommentsPageCommentFragment>>;
repository: { __typename?: 'Repository'; description?: Maybe<string>; open_issues_count?: Maybe<number>; stargazers_count: number; full_name: string; html_url: string };
}>;
};
To Reproduce
There is an example in dev-test folder:
https://github.com/dotansimha/graphql-code-generator/blob/master/dev-test/githunt/types.preResolveTypes.ts#L177
Fixed in v1.13.1 馃帀
Hi there. Are this optional? Or why is this expected behavior (it's never undefined, but it may be null)? @dotansimha
i can opt out this behavior via avoidOptionals: true, but i'm using this syntax:
avoidOptionals:
inputValue: false
object: true
and it seems like i can't opt out this behavior via this syntax
answer is here https://github.com/dotansimha/graphql-code-generator/pull/3657
so this is works for me:
avoidOptionals:
object: true
field: true
Most helpful comment
Fixed in
v1.13.1馃帀