diff --git a/.changeset/breezy-games-enter.md b/.changeset/breezy-games-enter.md new file mode 100644 index 00000000000..9befb0d91ae --- /dev/null +++ b/.changeset/breezy-games-enter.md @@ -0,0 +1,11 @@ +--- +'@graphql-codegen/visitor-plugin-common': major +'@graphql-codegen/typescript-operations': major +'@graphql-codegen/client-preset': major +--- + +Fix nullable field optionality in operations + +Previously, a nullable Result field is generated as optional (marked by `?` TypeScript modifier) by default. This is not correct, because generally at runtime such field can only be `null`, and not `undefined` (both missing from the object OR `undefined`). The only exceptions are when fields are deferred (using `@defer` directive) or marked as conditional (using `@skip` or `@include`). + +Now, a nullable Result field cannot be optional unless the exceptions are met. This also limits `avoidOptionals` to only target Variables input, since some users may want to force explicit `null` when providing operation variables. diff --git a/dev-test/githunt/typed-document-nodes.ts b/dev-test/githunt/typed-document-nodes.ts index 3cbeb500f21..02f1e73d968 100644 --- a/dev-test/githunt/typed-document-nodes.ts +++ b/dev-test/githunt/typed-document-nodes.ts @@ -7,7 +7,7 @@ export type OnCommentAddedSubscriptionVariables = Exact<{ export type OnCommentAddedSubscription = { __typename?: 'Subscription'; - commentAdded?: { + commentAdded: { __typename?: 'Comment'; id: number; createdAt: number; @@ -24,8 +24,8 @@ export type CommentQueryVariables = Exact<{ export type CommentQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { + currentUser: { __typename?: 'User'; login: string; html_url: string } | null; + entry: { __typename?: 'Entry'; id: number; createdAt: number; @@ -40,8 +40,8 @@ export type CommentQuery = { } | null>; repository: { __typename?: 'Repository'; - description?: string | null; - open_issues_count?: number | null; + description: string | null; + open_issues_count: number | null; stargazers_count: number; full_name: string; html_url: string; @@ -61,7 +61,7 @@ export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never } export type CurrentUserForProfileQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; + currentUser: { __typename?: 'User'; login: string; avatar_url: string } | null; }; export type FeedEntryFragment = { @@ -74,10 +74,10 @@ export type FeedEntryFragment = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -91,8 +91,8 @@ export type FeedQueryVariables = Exact<{ export type FeedQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ + currentUser: { __typename?: 'User'; login: string } | null; + feed: Array<{ __typename?: 'Entry'; id: number; commentCount: number; @@ -102,10 +102,10 @@ export type FeedQuery = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -118,7 +118,7 @@ export type SubmitRepositoryMutationVariables = Exact<{ export type SubmitRepositoryMutation = { __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; + submitRepository: { __typename?: 'Entry'; createdAt: number } | null; }; export type RepoInfoFragment = { @@ -126,9 +126,9 @@ export type RepoInfoFragment = { createdAt: number; repository: { __typename?: 'Repository'; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; + open_issues_count: number | null; }; postedBy: { __typename?: 'User'; html_url: string; login: string }; }; @@ -140,7 +140,7 @@ export type SubmitCommentMutationVariables = Exact<{ export type SubmitCommentMutation = { __typename?: 'Mutation'; - submitComment?: { + submitComment: { __typename?: 'Comment'; id: number; createdAt: number; @@ -162,7 +162,7 @@ export type VoteMutationVariables = Exact<{ export type VoteMutation = { __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; + vote: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; }; export const CommentsPageCommentFragmentDoc = { diff --git a/dev-test/githunt/types.d.ts b/dev-test/githunt/types.d.ts index 87e35a2a5da..2005606651d 100644 --- a/dev-test/githunt/types.d.ts +++ b/dev-test/githunt/types.d.ts @@ -6,7 +6,7 @@ export type OnCommentAddedSubscriptionVariables = Exact<{ export type OnCommentAddedSubscription = { __typename?: 'Subscription'; - commentAdded?: { + commentAdded: { __typename?: 'Comment'; id: number; createdAt: number; @@ -23,8 +23,8 @@ export type CommentQueryVariables = Exact<{ export type CommentQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { + currentUser: { __typename?: 'User'; login: string; html_url: string } | null; + entry: { __typename?: 'Entry'; id: number; createdAt: number; @@ -39,8 +39,8 @@ export type CommentQuery = { } | null>; repository: { __typename?: 'Repository'; - description?: string | null; - open_issues_count?: number | null; + description: string | null; + open_issues_count: number | null; stargazers_count: number; full_name: string; html_url: string; @@ -60,7 +60,7 @@ export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never } export type CurrentUserForProfileQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; + currentUser: { __typename?: 'User'; login: string; avatar_url: string } | null; }; export type FeedEntryFragment = { @@ -73,10 +73,10 @@ export type FeedEntryFragment = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -90,8 +90,8 @@ export type FeedQueryVariables = Exact<{ export type FeedQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ + currentUser: { __typename?: 'User'; login: string } | null; + feed: Array<{ __typename?: 'Entry'; id: number; commentCount: number; @@ -101,10 +101,10 @@ export type FeedQuery = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -117,7 +117,7 @@ export type SubmitRepositoryMutationVariables = Exact<{ export type SubmitRepositoryMutation = { __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; + submitRepository: { __typename?: 'Entry'; createdAt: number } | null; }; export type RepoInfoFragment = { @@ -125,9 +125,9 @@ export type RepoInfoFragment = { createdAt: number; repository: { __typename?: 'Repository'; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; + open_issues_count: number | null; }; postedBy: { __typename?: 'User'; html_url: string; login: string }; }; @@ -139,7 +139,7 @@ export type SubmitCommentMutationVariables = Exact<{ export type SubmitCommentMutation = { __typename?: 'Mutation'; - submitComment?: { + submitComment: { __typename?: 'Comment'; id: number; createdAt: number; @@ -161,5 +161,5 @@ export type VoteMutationVariables = Exact<{ export type VoteMutation = { __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; + vote: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; }; diff --git a/dev-test/githunt/types.enumsAsTypes.ts b/dev-test/githunt/types.enumsAsTypes.ts index 87e35a2a5da..2005606651d 100644 --- a/dev-test/githunt/types.enumsAsTypes.ts +++ b/dev-test/githunt/types.enumsAsTypes.ts @@ -6,7 +6,7 @@ export type OnCommentAddedSubscriptionVariables = Exact<{ export type OnCommentAddedSubscription = { __typename?: 'Subscription'; - commentAdded?: { + commentAdded: { __typename?: 'Comment'; id: number; createdAt: number; @@ -23,8 +23,8 @@ export type CommentQueryVariables = Exact<{ export type CommentQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { + currentUser: { __typename?: 'User'; login: string; html_url: string } | null; + entry: { __typename?: 'Entry'; id: number; createdAt: number; @@ -39,8 +39,8 @@ export type CommentQuery = { } | null>; repository: { __typename?: 'Repository'; - description?: string | null; - open_issues_count?: number | null; + description: string | null; + open_issues_count: number | null; stargazers_count: number; full_name: string; html_url: string; @@ -60,7 +60,7 @@ export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never } export type CurrentUserForProfileQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; + currentUser: { __typename?: 'User'; login: string; avatar_url: string } | null; }; export type FeedEntryFragment = { @@ -73,10 +73,10 @@ export type FeedEntryFragment = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -90,8 +90,8 @@ export type FeedQueryVariables = Exact<{ export type FeedQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ + currentUser: { __typename?: 'User'; login: string } | null; + feed: Array<{ __typename?: 'Entry'; id: number; commentCount: number; @@ -101,10 +101,10 @@ export type FeedQuery = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -117,7 +117,7 @@ export type SubmitRepositoryMutationVariables = Exact<{ export type SubmitRepositoryMutation = { __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; + submitRepository: { __typename?: 'Entry'; createdAt: number } | null; }; export type RepoInfoFragment = { @@ -125,9 +125,9 @@ export type RepoInfoFragment = { createdAt: number; repository: { __typename?: 'Repository'; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; + open_issues_count: number | null; }; postedBy: { __typename?: 'User'; html_url: string; login: string }; }; @@ -139,7 +139,7 @@ export type SubmitCommentMutationVariables = Exact<{ export type SubmitCommentMutation = { __typename?: 'Mutation'; - submitComment?: { + submitComment: { __typename?: 'Comment'; id: number; createdAt: number; @@ -161,5 +161,5 @@ export type VoteMutationVariables = Exact<{ export type VoteMutation = { __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; + vote: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; }; diff --git a/dev-test/githunt/types.flatten.preResolveTypes.ts b/dev-test/githunt/types.flatten.preResolveTypes.ts index a68bbeba546..6aa279588a7 100644 --- a/dev-test/githunt/types.flatten.preResolveTypes.ts +++ b/dev-test/githunt/types.flatten.preResolveTypes.ts @@ -6,7 +6,7 @@ export type OnCommentAddedSubscriptionVariables = Exact<{ export type OnCommentAddedSubscription = { __typename?: 'Subscription'; - commentAdded?: { + commentAdded: { __typename?: 'Comment'; id: number; createdAt: number; @@ -23,8 +23,8 @@ export type CommentQueryVariables = Exact<{ export type CommentQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { + currentUser: { __typename?: 'User'; login: string; html_url: string } | null; + entry: { __typename?: 'Entry'; id: number; createdAt: number; @@ -41,8 +41,8 @@ export type CommentQuery = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; - open_issues_count?: number | null; + description: string | null; + open_issues_count: number | null; stargazers_count: number; }; } | null; @@ -52,7 +52,7 @@ export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never } export type CurrentUserForProfileQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; + currentUser: { __typename?: 'User'; login: string; avatar_url: string } | null; }; export type FeedQueryVariables = Exact<{ @@ -63,8 +63,8 @@ export type FeedQueryVariables = Exact<{ export type FeedQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ + currentUser: { __typename?: 'User'; login: string } | null; + feed: Array<{ __typename?: 'Entry'; id: number; commentCount: number; @@ -74,10 +74,10 @@ export type FeedQuery = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; login: string; html_url: string }; @@ -90,7 +90,7 @@ export type SubmitRepositoryMutationVariables = Exact<{ export type SubmitRepositoryMutation = { __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; + submitRepository: { __typename?: 'Entry'; createdAt: number } | null; }; export type SubmitCommentMutationVariables = Exact<{ @@ -100,7 +100,7 @@ export type SubmitCommentMutationVariables = Exact<{ export type SubmitCommentMutation = { __typename?: 'Mutation'; - submitComment?: { + submitComment: { __typename?: 'Comment'; id: number; createdAt: number; @@ -116,5 +116,5 @@ export type VoteMutationVariables = Exact<{ export type VoteMutation = { __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; + vote: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; }; diff --git a/dev-test/githunt/types.immutableTypes.ts b/dev-test/githunt/types.immutableTypes.ts index 32423b2970d..9daf847ec1c 100644 --- a/dev-test/githunt/types.immutableTypes.ts +++ b/dev-test/githunt/types.immutableTypes.ts @@ -6,7 +6,7 @@ export type OnCommentAddedSubscriptionVariables = Exact<{ export type OnCommentAddedSubscription = { readonly __typename?: 'Subscription'; - readonly commentAdded?: { + readonly commentAdded: { readonly __typename?: 'Comment'; readonly id: number; readonly createdAt: number; @@ -23,8 +23,8 @@ export type CommentQueryVariables = Exact<{ export type CommentQuery = { readonly __typename?: 'Query'; - readonly currentUser?: { readonly __typename?: 'User'; readonly login: string; readonly html_url: string } | null; - readonly entry?: { + readonly currentUser: { readonly __typename?: 'User'; readonly login: string; readonly html_url: string } | null; + readonly entry: { readonly __typename?: 'Entry'; readonly id: number; readonly createdAt: number; @@ -39,8 +39,8 @@ export type CommentQuery = { } | null>; readonly repository: { readonly __typename?: 'Repository'; - readonly description?: string | null; - readonly open_issues_count?: number | null; + readonly description: string | null; + readonly open_issues_count: number | null; readonly stargazers_count: number; readonly full_name: string; readonly html_url: string; @@ -60,7 +60,7 @@ export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never } export type CurrentUserForProfileQuery = { readonly __typename?: 'Query'; - readonly currentUser?: { readonly __typename?: 'User'; readonly login: string; readonly avatar_url: string } | null; + readonly currentUser: { readonly __typename?: 'User'; readonly login: string; readonly avatar_url: string } | null; }; export type FeedEntryFragment = { @@ -73,10 +73,10 @@ export type FeedEntryFragment = { readonly __typename?: 'Repository'; readonly full_name: string; readonly html_url: string; - readonly description?: string | null; + readonly description: string | null; readonly stargazers_count: number; - readonly open_issues_count?: number | null; - readonly owner?: { readonly __typename?: 'User'; readonly avatar_url: string } | null; + readonly open_issues_count: number | null; + readonly owner: { readonly __typename?: 'User'; readonly avatar_url: string } | null; }; readonly vote: { readonly __typename?: 'Vote'; readonly vote_value: number }; readonly postedBy: { readonly __typename?: 'User'; readonly html_url: string; readonly login: string }; @@ -90,8 +90,8 @@ export type FeedQueryVariables = Exact<{ export type FeedQuery = { readonly __typename?: 'Query'; - readonly currentUser?: { readonly __typename?: 'User'; readonly login: string } | null; - readonly feed?: ReadonlyArray<{ + readonly currentUser: { readonly __typename?: 'User'; readonly login: string } | null; + readonly feed: ReadonlyArray<{ readonly __typename?: 'Entry'; readonly id: number; readonly commentCount: number; @@ -101,10 +101,10 @@ export type FeedQuery = { readonly __typename?: 'Repository'; readonly full_name: string; readonly html_url: string; - readonly description?: string | null; + readonly description: string | null; readonly stargazers_count: number; - readonly open_issues_count?: number | null; - readonly owner?: { readonly __typename?: 'User'; readonly avatar_url: string } | null; + readonly open_issues_count: number | null; + readonly owner: { readonly __typename?: 'User'; readonly avatar_url: string } | null; }; readonly vote: { readonly __typename?: 'Vote'; readonly vote_value: number }; readonly postedBy: { readonly __typename?: 'User'; readonly html_url: string; readonly login: string }; @@ -117,7 +117,7 @@ export type SubmitRepositoryMutationVariables = Exact<{ export type SubmitRepositoryMutation = { readonly __typename?: 'Mutation'; - readonly submitRepository?: { readonly __typename?: 'Entry'; readonly createdAt: number } | null; + readonly submitRepository: { readonly __typename?: 'Entry'; readonly createdAt: number } | null; }; export type RepoInfoFragment = { @@ -125,9 +125,9 @@ export type RepoInfoFragment = { readonly createdAt: number; readonly repository: { readonly __typename?: 'Repository'; - readonly description?: string | null; + readonly description: string | null; readonly stargazers_count: number; - readonly open_issues_count?: number | null; + readonly open_issues_count: number | null; }; readonly postedBy: { readonly __typename?: 'User'; readonly html_url: string; readonly login: string }; }; @@ -139,7 +139,7 @@ export type SubmitCommentMutationVariables = Exact<{ export type SubmitCommentMutation = { readonly __typename?: 'Mutation'; - readonly submitComment?: { + readonly submitComment: { readonly __typename?: 'Comment'; readonly id: number; readonly createdAt: number; @@ -161,7 +161,7 @@ export type VoteMutationVariables = Exact<{ export type VoteMutation = { readonly __typename?: 'Mutation'; - readonly vote?: { + readonly vote: { readonly __typename?: 'Entry'; readonly score: number; readonly id: number; diff --git a/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts b/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts index 87e35a2a5da..2005606651d 100644 --- a/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts +++ b/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts @@ -6,7 +6,7 @@ export type OnCommentAddedSubscriptionVariables = Exact<{ export type OnCommentAddedSubscription = { __typename?: 'Subscription'; - commentAdded?: { + commentAdded: { __typename?: 'Comment'; id: number; createdAt: number; @@ -23,8 +23,8 @@ export type CommentQueryVariables = Exact<{ export type CommentQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { + currentUser: { __typename?: 'User'; login: string; html_url: string } | null; + entry: { __typename?: 'Entry'; id: number; createdAt: number; @@ -39,8 +39,8 @@ export type CommentQuery = { } | null>; repository: { __typename?: 'Repository'; - description?: string | null; - open_issues_count?: number | null; + description: string | null; + open_issues_count: number | null; stargazers_count: number; full_name: string; html_url: string; @@ -60,7 +60,7 @@ export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never } export type CurrentUserForProfileQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; + currentUser: { __typename?: 'User'; login: string; avatar_url: string } | null; }; export type FeedEntryFragment = { @@ -73,10 +73,10 @@ export type FeedEntryFragment = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -90,8 +90,8 @@ export type FeedQueryVariables = Exact<{ export type FeedQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ + currentUser: { __typename?: 'User'; login: string } | null; + feed: Array<{ __typename?: 'Entry'; id: number; commentCount: number; @@ -101,10 +101,10 @@ export type FeedQuery = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -117,7 +117,7 @@ export type SubmitRepositoryMutationVariables = Exact<{ export type SubmitRepositoryMutation = { __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; + submitRepository: { __typename?: 'Entry'; createdAt: number } | null; }; export type RepoInfoFragment = { @@ -125,9 +125,9 @@ export type RepoInfoFragment = { createdAt: number; repository: { __typename?: 'Repository'; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; + open_issues_count: number | null; }; postedBy: { __typename?: 'User'; html_url: string; login: string }; }; @@ -139,7 +139,7 @@ export type SubmitCommentMutationVariables = Exact<{ export type SubmitCommentMutation = { __typename?: 'Mutation'; - submitComment?: { + submitComment: { __typename?: 'Comment'; id: number; createdAt: number; @@ -161,5 +161,5 @@ export type VoteMutationVariables = Exact<{ export type VoteMutation = { __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; + vote: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; }; diff --git a/dev-test/githunt/types.preResolveTypes.ts b/dev-test/githunt/types.preResolveTypes.ts index 87e35a2a5da..2005606651d 100644 --- a/dev-test/githunt/types.preResolveTypes.ts +++ b/dev-test/githunt/types.preResolveTypes.ts @@ -6,7 +6,7 @@ export type OnCommentAddedSubscriptionVariables = Exact<{ export type OnCommentAddedSubscription = { __typename?: 'Subscription'; - commentAdded?: { + commentAdded: { __typename?: 'Comment'; id: number; createdAt: number; @@ -23,8 +23,8 @@ export type CommentQueryVariables = Exact<{ export type CommentQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { + currentUser: { __typename?: 'User'; login: string; html_url: string } | null; + entry: { __typename?: 'Entry'; id: number; createdAt: number; @@ -39,8 +39,8 @@ export type CommentQuery = { } | null>; repository: { __typename?: 'Repository'; - description?: string | null; - open_issues_count?: number | null; + description: string | null; + open_issues_count: number | null; stargazers_count: number; full_name: string; html_url: string; @@ -60,7 +60,7 @@ export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never } export type CurrentUserForProfileQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; + currentUser: { __typename?: 'User'; login: string; avatar_url: string } | null; }; export type FeedEntryFragment = { @@ -73,10 +73,10 @@ export type FeedEntryFragment = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -90,8 +90,8 @@ export type FeedQueryVariables = Exact<{ export type FeedQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ + currentUser: { __typename?: 'User'; login: string } | null; + feed: Array<{ __typename?: 'Entry'; id: number; commentCount: number; @@ -101,10 +101,10 @@ export type FeedQuery = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -117,7 +117,7 @@ export type SubmitRepositoryMutationVariables = Exact<{ export type SubmitRepositoryMutation = { __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; + submitRepository: { __typename?: 'Entry'; createdAt: number } | null; }; export type RepoInfoFragment = { @@ -125,9 +125,9 @@ export type RepoInfoFragment = { createdAt: number; repository: { __typename?: 'Repository'; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; + open_issues_count: number | null; }; postedBy: { __typename?: 'User'; html_url: string; login: string }; }; @@ -139,7 +139,7 @@ export type SubmitCommentMutationVariables = Exact<{ export type SubmitCommentMutation = { __typename?: 'Mutation'; - submitComment?: { + submitComment: { __typename?: 'Comment'; id: number; createdAt: number; @@ -161,5 +161,5 @@ export type VoteMutationVariables = Exact<{ export type VoteMutation = { __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; + vote: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; }; diff --git a/dev-test/githunt/types.ts b/dev-test/githunt/types.ts index 87e35a2a5da..2005606651d 100644 --- a/dev-test/githunt/types.ts +++ b/dev-test/githunt/types.ts @@ -6,7 +6,7 @@ export type OnCommentAddedSubscriptionVariables = Exact<{ export type OnCommentAddedSubscription = { __typename?: 'Subscription'; - commentAdded?: { + commentAdded: { __typename?: 'Comment'; id: number; createdAt: number; @@ -23,8 +23,8 @@ export type CommentQueryVariables = Exact<{ export type CommentQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { + currentUser: { __typename?: 'User'; login: string; html_url: string } | null; + entry: { __typename?: 'Entry'; id: number; createdAt: number; @@ -39,8 +39,8 @@ export type CommentQuery = { } | null>; repository: { __typename?: 'Repository'; - description?: string | null; - open_issues_count?: number | null; + description: string | null; + open_issues_count: number | null; stargazers_count: number; full_name: string; html_url: string; @@ -60,7 +60,7 @@ export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never } export type CurrentUserForProfileQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; + currentUser: { __typename?: 'User'; login: string; avatar_url: string } | null; }; export type FeedEntryFragment = { @@ -73,10 +73,10 @@ export type FeedEntryFragment = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -90,8 +90,8 @@ export type FeedQueryVariables = Exact<{ export type FeedQuery = { __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ + currentUser: { __typename?: 'User'; login: string } | null; + feed: Array<{ __typename?: 'Entry'; id: number; commentCount: number; @@ -101,10 +101,10 @@ export type FeedQuery = { __typename?: 'Repository'; full_name: string; html_url: string; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; - owner?: { __typename?: 'User'; avatar_url: string } | null; + open_issues_count: number | null; + owner: { __typename?: 'User'; avatar_url: string } | null; }; vote: { __typename?: 'Vote'; vote_value: number }; postedBy: { __typename?: 'User'; html_url: string; login: string }; @@ -117,7 +117,7 @@ export type SubmitRepositoryMutationVariables = Exact<{ export type SubmitRepositoryMutation = { __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; + submitRepository: { __typename?: 'Entry'; createdAt: number } | null; }; export type RepoInfoFragment = { @@ -125,9 +125,9 @@ export type RepoInfoFragment = { createdAt: number; repository: { __typename?: 'Repository'; - description?: string | null; + description: string | null; stargazers_count: number; - open_issues_count?: number | null; + open_issues_count: number | null; }; postedBy: { __typename?: 'User'; html_url: string; login: string }; }; @@ -139,7 +139,7 @@ export type SubmitCommentMutationVariables = Exact<{ export type SubmitCommentMutation = { __typename?: 'Mutation'; - submitComment?: { + submitComment: { __typename?: 'Comment'; id: number; createdAt: number; @@ -161,5 +161,5 @@ export type VoteMutationVariables = Exact<{ export type VoteMutation = { __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; + vote: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; }; diff --git a/dev-test/gql-tag-operations-masking/gql/graphql.ts b/dev-test/gql-tag-operations-masking/gql/graphql.ts index 205eaa4085b..8d4d6c639dc 100644 --- a/dev-test/gql-tag-operations-masking/gql/graphql.ts +++ b/dev-test/gql-tag-operations-masking/gql/graphql.ts @@ -9,12 +9,12 @@ export type TweetFragmentFragment = ({ __typename?: 'Tweet'; id: string; body: s export type TweetAuthorFragmentFragment = { __typename?: 'Tweet'; id: string; - author: { __typename?: 'User'; id: string; username?: string | null }; + author: { __typename?: 'User'; id: string; username: string | null }; } & { ' $fragmentName'?: 'TweetAuthorFragmentFragment' }; export type TweetsFragmentFragment = { __typename?: 'Query'; - Tweets?: Array< + Tweets: Array< { __typename?: 'Tweet'; id: string } & { ' $fragmentRefs'?: { TweetFragmentFragment: TweetFragmentFragment } } > | null; } & { ' $fragmentName'?: 'TweetsFragmentFragment' }; diff --git a/dev-test/gql-tag-operations-urql/gql/graphql.ts b/dev-test/gql-tag-operations-urql/gql/graphql.ts index 3873fbc6989..85b274733c3 100644 --- a/dev-test/gql-tag-operations-urql/gql/graphql.ts +++ b/dev-test/gql-tag-operations-urql/gql/graphql.ts @@ -4,9 +4,9 @@ type Exact = { [K in keyof T]: T[K] }; export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type FooQueryVariables = Exact<{ [key: string]: never }>; -export type FooQuery = { __typename?: 'Query'; Tweets?: Array<{ __typename?: 'Tweet'; id: string } | null> | null }; +export type FooQuery = { __typename?: 'Query'; Tweets: Array<{ __typename?: 'Tweet'; id: string } | null> | null }; -export type LelFragment = { __typename?: 'Tweet'; id: string; body?: string | null } & { +export type LelFragment = { __typename?: 'Tweet'; id: string; body: string | null } & { ' $fragmentName'?: 'LelFragment'; }; @@ -14,7 +14,7 @@ export type BarQueryVariables = Exact<{ [key: string]: never }>; export type BarQuery = { __typename?: 'Query'; - Tweets?: Array<({ __typename?: 'Tweet' } & { ' $fragmentRefs'?: { LelFragment: LelFragment } }) | null> | null; + Tweets: Array<({ __typename?: 'Tweet' } & { ' $fragmentRefs'?: { LelFragment: LelFragment } }) | null> | null; }; export const LelFragmentDoc = { diff --git a/dev-test/gql-tag-operations/gql/graphql.ts b/dev-test/gql-tag-operations/gql/graphql.ts index 3873fbc6989..85b274733c3 100644 --- a/dev-test/gql-tag-operations/gql/graphql.ts +++ b/dev-test/gql-tag-operations/gql/graphql.ts @@ -4,9 +4,9 @@ type Exact = { [K in keyof T]: T[K] }; export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type FooQueryVariables = Exact<{ [key: string]: never }>; -export type FooQuery = { __typename?: 'Query'; Tweets?: Array<{ __typename?: 'Tweet'; id: string } | null> | null }; +export type FooQuery = { __typename?: 'Query'; Tweets: Array<{ __typename?: 'Tweet'; id: string } | null> | null }; -export type LelFragment = { __typename?: 'Tweet'; id: string; body?: string | null } & { +export type LelFragment = { __typename?: 'Tweet'; id: string; body: string | null } & { ' $fragmentName'?: 'LelFragment'; }; @@ -14,7 +14,7 @@ export type BarQueryVariables = Exact<{ [key: string]: never }>; export type BarQuery = { __typename?: 'Query'; - Tweets?: Array<({ __typename?: 'Tweet' } & { ' $fragmentRefs'?: { LelFragment: LelFragment } }) | null> | null; + Tweets: Array<({ __typename?: 'Tweet' } & { ' $fragmentRefs'?: { LelFragment: LelFragment } }) | null> | null; }; export const LelFragmentDoc = { diff --git a/dev-test/gql-tag-operations/graphql/graphql.ts b/dev-test/gql-tag-operations/graphql/graphql.ts index 3873fbc6989..85b274733c3 100644 --- a/dev-test/gql-tag-operations/graphql/graphql.ts +++ b/dev-test/gql-tag-operations/graphql/graphql.ts @@ -4,9 +4,9 @@ type Exact = { [K in keyof T]: T[K] }; export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type FooQueryVariables = Exact<{ [key: string]: never }>; -export type FooQuery = { __typename?: 'Query'; Tweets?: Array<{ __typename?: 'Tweet'; id: string } | null> | null }; +export type FooQuery = { __typename?: 'Query'; Tweets: Array<{ __typename?: 'Tweet'; id: string } | null> | null }; -export type LelFragment = { __typename?: 'Tweet'; id: string; body?: string | null } & { +export type LelFragment = { __typename?: 'Tweet'; id: string; body: string | null } & { ' $fragmentName'?: 'LelFragment'; }; @@ -14,7 +14,7 @@ export type BarQueryVariables = Exact<{ [key: string]: never }>; export type BarQuery = { __typename?: 'Query'; - Tweets?: Array<({ __typename?: 'Tweet' } & { ' $fragmentRefs'?: { LelFragment: LelFragment } }) | null> | null; + Tweets: Array<({ __typename?: 'Tweet' } & { ' $fragmentRefs'?: { LelFragment: LelFragment } }) | null> | null; }; export const LelFragmentDoc = { diff --git a/dev-test/standalone-operations/import-schema-types/_types.generated.ts b/dev-test/standalone-operations/import-schema-types/_types.generated.ts index 8e7086fd159..41ab1798916 100644 --- a/dev-test/standalone-operations/import-schema-types/_types.generated.ts +++ b/dev-test/standalone-operations/import-schema-types/_types.generated.ts @@ -8,5 +8,5 @@ export type WithVariablesQueryVariables = Exact<{ export type WithVariablesQuery = { __typename?: 'Query'; - user?: { __typename?: 'User'; id: string; name: string } | null; + user: { __typename?: 'User'; id: string; name: string } | null; }; diff --git a/dev-test/star-wars/types.excludeQueryAlpha.ts b/dev-test/star-wars/types.excludeQueryAlpha.ts index 3dcdf61ba0f..24539db56b3 100644 --- a/dev-test/star-wars/types.excludeQueryAlpha.ts +++ b/dev-test/star-wars/types.excludeQueryAlpha.ts @@ -7,7 +7,7 @@ export type CreateReviewForEpisodeMutationVariables = Exact<{ export type CreateReviewForEpisodeMutation = { __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; + createReview: { __typename?: 'Review'; stars: number; commentary: string | null } | null; }; export type ExcludeQueryBetaQueryVariables = Exact<{ @@ -16,7 +16,7 @@ export type ExcludeQueryBetaQueryVariables = Exact<{ export type ExcludeQueryBetaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroAndFriendsNamesQueryVariables = Exact<{ @@ -25,16 +25,16 @@ export type HeroAndFriendsNamesQueryVariables = Exact<{ export type HeroAndFriendsNamesQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | { __typename?: 'Human'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | null; }; @@ -43,7 +43,7 @@ export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; appearsIn: Array } | { __typename?: 'Human'; name: string; appearsIn: Array } | null; @@ -55,15 +55,15 @@ export type HeroDetailsQueryVariables = Exact<{ export type HeroDetailsQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { __typename?: 'Human'; height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; @@ -73,9 +73,9 @@ export type HeroDetailsWithFragmentQueryVariables = Exact<{ export type HeroDetailsWithFragmentQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; @@ -85,7 +85,7 @@ export type HeroNameQueryVariables = Exact<{ export type HeroNameQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ @@ -95,7 +95,7 @@ export type HeroNameConditionalInclusionQueryVariables = Exact<{ export type HeroNameConditionalInclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ @@ -105,7 +105,7 @@ export type HeroNameConditionalExclusionQueryVariables = Exact<{ export type HeroNameConditionalExclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ @@ -114,19 +114,19 @@ export type HeroParentTypeDependentFieldQueryVariables = Exact<{ export type HeroParentTypeDependentFieldQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | { __typename?: 'Human'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | null; @@ -138,22 +138,22 @@ export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ export type HeroTypeDependentAliasedFieldQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { __typename?: 'Droid'; property: string | null } | { __typename?: 'Human'; property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass: number | null }; export type HumanWithNullHeightQueryVariables = Exact<{ [key: string]: never }>; export type HumanWithNullHeightQuery = { __typename?: 'Query'; - human?: { __typename?: 'Human'; name: string; mass?: number | null } | null; + human: { __typename?: 'Human'; name: string; mass: number | null } | null; }; export type TwoHeroesQueryVariables = Exact<{ [key: string]: never }>; export type TwoHeroesQuery = { __typename?: 'Query'; - r2?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; - luke?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + r2: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + luke: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; diff --git a/dev-test/star-wars/types.excludeQueryBeta.ts b/dev-test/star-wars/types.excludeQueryBeta.ts index 17d946340de..1054aac1314 100644 --- a/dev-test/star-wars/types.excludeQueryBeta.ts +++ b/dev-test/star-wars/types.excludeQueryBeta.ts @@ -7,7 +7,7 @@ export type CreateReviewForEpisodeMutationVariables = Exact<{ export type CreateReviewForEpisodeMutation = { __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; + createReview: { __typename?: 'Review'; stars: number; commentary: string | null } | null; }; export type ExcludeQueryAlphaQueryVariables = Exact<{ @@ -16,7 +16,7 @@ export type ExcludeQueryAlphaQueryVariables = Exact<{ export type ExcludeQueryAlphaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroAndFriendsNamesQueryVariables = Exact<{ @@ -25,16 +25,16 @@ export type HeroAndFriendsNamesQueryVariables = Exact<{ export type HeroAndFriendsNamesQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | { __typename?: 'Human'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | null; }; @@ -43,7 +43,7 @@ export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; appearsIn: Array } | { __typename?: 'Human'; name: string; appearsIn: Array } | null; @@ -55,15 +55,15 @@ export type HeroDetailsQueryVariables = Exact<{ export type HeroDetailsQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { __typename?: 'Human'; height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; @@ -73,9 +73,9 @@ export type HeroDetailsWithFragmentQueryVariables = Exact<{ export type HeroDetailsWithFragmentQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; @@ -85,7 +85,7 @@ export type HeroNameQueryVariables = Exact<{ export type HeroNameQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ @@ -95,7 +95,7 @@ export type HeroNameConditionalInclusionQueryVariables = Exact<{ export type HeroNameConditionalInclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ @@ -105,7 +105,7 @@ export type HeroNameConditionalExclusionQueryVariables = Exact<{ export type HeroNameConditionalExclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ @@ -114,19 +114,19 @@ export type HeroParentTypeDependentFieldQueryVariables = Exact<{ export type HeroParentTypeDependentFieldQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | { __typename?: 'Human'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | null; @@ -138,22 +138,22 @@ export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ export type HeroTypeDependentAliasedFieldQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { __typename?: 'Droid'; property: string | null } | { __typename?: 'Human'; property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass: number | null }; export type HumanWithNullHeightQueryVariables = Exact<{ [key: string]: never }>; export type HumanWithNullHeightQuery = { __typename?: 'Query'; - human?: { __typename?: 'Human'; name: string; mass?: number | null } | null; + human: { __typename?: 'Human'; name: string; mass: number | null } | null; }; export type TwoHeroesQueryVariables = Exact<{ [key: string]: never }>; export type TwoHeroesQuery = { __typename?: 'Query'; - r2?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; - luke?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + r2: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + luke: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; diff --git a/dev-test/star-wars/types.globallyAvailable.d.ts b/dev-test/star-wars/types.globallyAvailable.d.ts index 4fff8bbe8b4..48a1dc3d9e6 100644 --- a/dev-test/star-wars/types.globallyAvailable.d.ts +++ b/dev-test/star-wars/types.globallyAvailable.d.ts @@ -7,7 +7,7 @@ type CreateReviewForEpisodeMutationVariables = Exact<{ type CreateReviewForEpisodeMutation = { __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; + createReview: { __typename?: 'Review'; stars: number; commentary: string | null } | null; }; type ExcludeQueryAlphaQueryVariables = Exact<{ @@ -16,7 +16,7 @@ type ExcludeQueryAlphaQueryVariables = Exact<{ type ExcludeQueryAlphaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; type ExcludeQueryBetaQueryVariables = Exact<{ @@ -25,7 +25,7 @@ type ExcludeQueryBetaQueryVariables = Exact<{ type ExcludeQueryBetaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; type HeroAndFriendsNamesQueryVariables = Exact<{ @@ -34,16 +34,16 @@ type HeroAndFriendsNamesQueryVariables = Exact<{ type HeroAndFriendsNamesQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | { __typename?: 'Human'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | null; }; @@ -52,7 +52,7 @@ type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; type HeroAppearsInQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; appearsIn: Array } | { __typename?: 'Human'; name: string; appearsIn: Array } | null; @@ -64,15 +64,15 @@ type HeroDetailsQueryVariables = Exact<{ type HeroDetailsQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { __typename?: 'Human'; height: number | null; name: string }; type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; @@ -82,9 +82,9 @@ type HeroDetailsWithFragmentQueryVariables = Exact<{ type HeroDetailsWithFragmentQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; @@ -94,7 +94,7 @@ type HeroNameQueryVariables = Exact<{ type HeroNameQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; type HeroNameConditionalInclusionQueryVariables = Exact<{ @@ -104,7 +104,7 @@ type HeroNameConditionalInclusionQueryVariables = Exact<{ type HeroNameConditionalInclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; type HeroNameConditionalExclusionQueryVariables = Exact<{ @@ -114,7 +114,7 @@ type HeroNameConditionalExclusionQueryVariables = Exact<{ type HeroNameConditionalExclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; type HeroParentTypeDependentFieldQueryVariables = Exact<{ @@ -123,19 +123,19 @@ type HeroParentTypeDependentFieldQueryVariables = Exact<{ type HeroParentTypeDependentFieldQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | { __typename?: 'Human'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | null; @@ -147,22 +147,22 @@ type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ type HeroTypeDependentAliasedFieldQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { __typename?: 'Droid'; property: string | null } | { __typename?: 'Human'; property: string | null } | null; }; -type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass: number | null }; type HumanWithNullHeightQueryVariables = Exact<{ [key: string]: never }>; type HumanWithNullHeightQuery = { __typename?: 'Query'; - human?: { __typename?: 'Human'; name: string; mass?: number | null } | null; + human: { __typename?: 'Human'; name: string; mass: number | null } | null; }; type TwoHeroesQueryVariables = Exact<{ [key: string]: never }>; type TwoHeroesQuery = { __typename?: 'Query'; - r2?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; - luke?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + r2: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + luke: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; diff --git a/dev-test/star-wars/types.immutableTypes.ts b/dev-test/star-wars/types.immutableTypes.ts index 1f5936f09e3..961c04bd21c 100644 --- a/dev-test/star-wars/types.immutableTypes.ts +++ b/dev-test/star-wars/types.immutableTypes.ts @@ -7,10 +7,10 @@ export type CreateReviewForEpisodeMutationVariables = Exact<{ export type CreateReviewForEpisodeMutation = { readonly __typename?: 'Mutation'; - readonly createReview?: { + readonly createReview: { readonly __typename?: 'Review'; readonly stars: number; - readonly commentary?: string | null; + readonly commentary: string | null; } | null; }; @@ -20,7 +20,7 @@ export type ExcludeQueryAlphaQueryVariables = Exact<{ export type ExcludeQueryAlphaQuery = { readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { readonly __typename?: 'Droid'; readonly name: string } | { readonly __typename?: 'Human'; readonly name: string } | null; @@ -32,7 +32,7 @@ export type ExcludeQueryBetaQueryVariables = Exact<{ export type ExcludeQueryBetaQuery = { readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { readonly __typename?: 'Droid'; readonly name: string } | { readonly __typename?: 'Human'; readonly name: string } | null; @@ -44,11 +44,11 @@ export type HeroAndFriendsNamesQueryVariables = Exact<{ export type HeroAndFriendsNamesQuery = { readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { readonly __typename?: 'Droid'; readonly name: string; - readonly friends?: ReadonlyArray< + readonly friends: ReadonlyArray< | { readonly __typename?: 'Droid'; readonly name: string } | { readonly __typename?: 'Human'; readonly name: string } | null @@ -57,7 +57,7 @@ export type HeroAndFriendsNamesQuery = { | { readonly __typename?: 'Human'; readonly name: string; - readonly friends?: ReadonlyArray< + readonly friends: ReadonlyArray< | { readonly __typename?: 'Droid'; readonly name: string } | { readonly __typename?: 'Human'; readonly name: string } | null @@ -70,7 +70,7 @@ export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { readonly __typename?: 'Droid'; readonly name: string; readonly appearsIn: ReadonlyArray } | { readonly __typename?: 'Human'; readonly name: string; readonly appearsIn: ReadonlyArray } | null; @@ -82,21 +82,21 @@ export type HeroDetailsQueryVariables = Exact<{ export type HeroDetailsQuery = { readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly primaryFunction?: string | null; readonly name: string } - | { readonly __typename?: 'Human'; readonly height?: number | null; readonly name: string } + readonly hero: + | { readonly __typename?: 'Droid'; readonly primaryFunction: string | null; readonly name: string } + | { readonly __typename?: 'Human'; readonly height: number | null; readonly name: string } | null; }; type HeroDetails_Droid_Fragment = { readonly __typename?: 'Droid'; - readonly primaryFunction?: string | null; + readonly primaryFunction: string | null; readonly name: string; }; type HeroDetails_Human_Fragment = { readonly __typename?: 'Human'; - readonly height?: number | null; + readonly height: number | null; readonly name: string; }; @@ -108,9 +108,9 @@ export type HeroDetailsWithFragmentQueryVariables = Exact<{ export type HeroDetailsWithFragmentQuery = { readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly primaryFunction?: string | null; readonly name: string } - | { readonly __typename?: 'Human'; readonly height?: number | null; readonly name: string } + readonly hero: + | { readonly __typename?: 'Droid'; readonly primaryFunction: string | null; readonly name: string } + | { readonly __typename?: 'Human'; readonly height: number | null; readonly name: string } | null; }; @@ -120,7 +120,7 @@ export type HeroNameQueryVariables = Exact<{ export type HeroNameQuery = { readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { readonly __typename?: 'Droid'; readonly name: string } | { readonly __typename?: 'Human'; readonly name: string } | null; @@ -133,7 +133,7 @@ export type HeroNameConditionalInclusionQueryVariables = Exact<{ export type HeroNameConditionalInclusionQuery = { readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { readonly __typename?: 'Droid'; readonly name?: string } | { readonly __typename?: 'Human'; readonly name?: string } | null; @@ -146,7 +146,7 @@ export type HeroNameConditionalExclusionQueryVariables = Exact<{ export type HeroNameConditionalExclusionQuery = { readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { readonly __typename?: 'Droid'; readonly name?: string } | { readonly __typename?: 'Human'; readonly name?: string } | null; @@ -158,22 +158,22 @@ export type HeroParentTypeDependentFieldQueryVariables = Exact<{ export type HeroParentTypeDependentFieldQuery = { readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { readonly __typename?: 'Droid'; readonly name: string; - readonly friends?: ReadonlyArray< + readonly friends: ReadonlyArray< | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly height?: number | null; readonly name: string } + | { readonly __typename?: 'Human'; readonly height: number | null; readonly name: string } | null > | null; } | { readonly __typename?: 'Human'; readonly name: string; - readonly friends?: ReadonlyArray< + readonly friends: ReadonlyArray< | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly height?: number | null; readonly name: string } + | { readonly __typename?: 'Human'; readonly height: number | null; readonly name: string } | null > | null; } @@ -186,34 +186,34 @@ export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ export type HeroTypeDependentAliasedFieldQuery = { readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly property?: string | null } - | { readonly __typename?: 'Human'; readonly property?: string | null } + readonly hero: + | { readonly __typename?: 'Droid'; readonly property: string | null } + | { readonly __typename?: 'Human'; readonly property: string | null } | null; }; export type HumanFieldsFragment = { readonly __typename?: 'Human'; readonly name: string; - readonly mass?: number | null; + readonly mass: number | null; }; export type HumanWithNullHeightQueryVariables = Exact<{ [key: string]: never }>; export type HumanWithNullHeightQuery = { readonly __typename?: 'Query'; - readonly human?: { readonly __typename?: 'Human'; readonly name: string; readonly mass?: number | null } | null; + readonly human: { readonly __typename?: 'Human'; readonly name: string; readonly mass: number | null } | null; }; export type TwoHeroesQueryVariables = Exact<{ [key: string]: never }>; export type TwoHeroesQuery = { readonly __typename?: 'Query'; - readonly r2?: + readonly r2: | { readonly __typename?: 'Droid'; readonly name: string } | { readonly __typename?: 'Human'; readonly name: string } | null; - readonly luke?: + readonly luke: | { readonly __typename?: 'Droid'; readonly name: string } | { readonly __typename?: 'Human'; readonly name: string } | null; diff --git a/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts b/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts index dabd899e390..e458fd3fb51 100644 --- a/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts +++ b/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts @@ -7,7 +7,7 @@ export type CreateReviewForEpisodeMutationVariables = Exact<{ export type CreateReviewForEpisodeMutation = { __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; + createReview: { __typename?: 'Review'; stars: number; commentary: string | null } | null; }; export type ExcludeQueryAlphaQueryVariables = Exact<{ @@ -16,7 +16,7 @@ export type ExcludeQueryAlphaQueryVariables = Exact<{ export type ExcludeQueryAlphaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type ExcludeQueryBetaQueryVariables = Exact<{ @@ -25,7 +25,7 @@ export type ExcludeQueryBetaQueryVariables = Exact<{ export type ExcludeQueryBetaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroAndFriendsNamesQueryVariables = Exact<{ @@ -34,16 +34,16 @@ export type HeroAndFriendsNamesQueryVariables = Exact<{ export type HeroAndFriendsNamesQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | { __typename?: 'Human'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | null; }; @@ -52,7 +52,7 @@ export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; appearsIn: Array } | { __typename?: 'Human'; name: string; appearsIn: Array } | null; @@ -64,15 +64,15 @@ export type HeroDetailsQueryVariables = Exact<{ export type HeroDetailsQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { __typename?: 'Human'; height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; @@ -82,9 +82,9 @@ export type HeroDetailsWithFragmentQueryVariables = Exact<{ export type HeroDetailsWithFragmentQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; @@ -94,7 +94,7 @@ export type HeroNameQueryVariables = Exact<{ export type HeroNameQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ @@ -104,7 +104,7 @@ export type HeroNameConditionalInclusionQueryVariables = Exact<{ export type HeroNameConditionalInclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ @@ -114,7 +114,7 @@ export type HeroNameConditionalExclusionQueryVariables = Exact<{ export type HeroNameConditionalExclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ @@ -123,19 +123,19 @@ export type HeroParentTypeDependentFieldQueryVariables = Exact<{ export type HeroParentTypeDependentFieldQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | { __typename?: 'Human'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | null; @@ -147,22 +147,22 @@ export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ export type HeroTypeDependentAliasedFieldQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { __typename?: 'Droid'; property: string | null } | { __typename?: 'Human'; property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass: number | null }; export type HumanWithNullHeightQueryVariables = Exact<{ [key: string]: never }>; export type HumanWithNullHeightQuery = { __typename?: 'Query'; - human?: { __typename?: 'Human'; name: string; mass?: number | null } | null; + human: { __typename?: 'Human'; name: string; mass: number | null } | null; }; export type TwoHeroesQueryVariables = Exact<{ [key: string]: never }>; export type TwoHeroesQuery = { __typename?: 'Query'; - r2?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; - luke?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + r2: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + luke: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; diff --git a/dev-test/star-wars/types.preResolveTypes.ts b/dev-test/star-wars/types.preResolveTypes.ts index dabd899e390..e458fd3fb51 100644 --- a/dev-test/star-wars/types.preResolveTypes.ts +++ b/dev-test/star-wars/types.preResolveTypes.ts @@ -7,7 +7,7 @@ export type CreateReviewForEpisodeMutationVariables = Exact<{ export type CreateReviewForEpisodeMutation = { __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; + createReview: { __typename?: 'Review'; stars: number; commentary: string | null } | null; }; export type ExcludeQueryAlphaQueryVariables = Exact<{ @@ -16,7 +16,7 @@ export type ExcludeQueryAlphaQueryVariables = Exact<{ export type ExcludeQueryAlphaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type ExcludeQueryBetaQueryVariables = Exact<{ @@ -25,7 +25,7 @@ export type ExcludeQueryBetaQueryVariables = Exact<{ export type ExcludeQueryBetaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroAndFriendsNamesQueryVariables = Exact<{ @@ -34,16 +34,16 @@ export type HeroAndFriendsNamesQueryVariables = Exact<{ export type HeroAndFriendsNamesQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | { __typename?: 'Human'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | null; }; @@ -52,7 +52,7 @@ export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; appearsIn: Array } | { __typename?: 'Human'; name: string; appearsIn: Array } | null; @@ -64,15 +64,15 @@ export type HeroDetailsQueryVariables = Exact<{ export type HeroDetailsQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { __typename?: 'Human'; height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; @@ -82,9 +82,9 @@ export type HeroDetailsWithFragmentQueryVariables = Exact<{ export type HeroDetailsWithFragmentQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; @@ -94,7 +94,7 @@ export type HeroNameQueryVariables = Exact<{ export type HeroNameQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ @@ -104,7 +104,7 @@ export type HeroNameConditionalInclusionQueryVariables = Exact<{ export type HeroNameConditionalInclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ @@ -114,7 +114,7 @@ export type HeroNameConditionalExclusionQueryVariables = Exact<{ export type HeroNameConditionalExclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ @@ -123,19 +123,19 @@ export type HeroParentTypeDependentFieldQueryVariables = Exact<{ export type HeroParentTypeDependentFieldQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | { __typename?: 'Human'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | null; @@ -147,22 +147,22 @@ export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ export type HeroTypeDependentAliasedFieldQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { __typename?: 'Droid'; property: string | null } | { __typename?: 'Human'; property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass: number | null }; export type HumanWithNullHeightQueryVariables = Exact<{ [key: string]: never }>; export type HumanWithNullHeightQuery = { __typename?: 'Query'; - human?: { __typename?: 'Human'; name: string; mass?: number | null } | null; + human: { __typename?: 'Human'; name: string; mass: number | null } | null; }; export type TwoHeroesQueryVariables = Exact<{ [key: string]: never }>; export type TwoHeroesQuery = { __typename?: 'Query'; - r2?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; - luke?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + r2: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + luke: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; diff --git a/dev-test/star-wars/types.skipSchema.ts b/dev-test/star-wars/types.skipSchema.ts index dabd899e390..e458fd3fb51 100644 --- a/dev-test/star-wars/types.skipSchema.ts +++ b/dev-test/star-wars/types.skipSchema.ts @@ -7,7 +7,7 @@ export type CreateReviewForEpisodeMutationVariables = Exact<{ export type CreateReviewForEpisodeMutation = { __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; + createReview: { __typename?: 'Review'; stars: number; commentary: string | null } | null; }; export type ExcludeQueryAlphaQueryVariables = Exact<{ @@ -16,7 +16,7 @@ export type ExcludeQueryAlphaQueryVariables = Exact<{ export type ExcludeQueryAlphaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type ExcludeQueryBetaQueryVariables = Exact<{ @@ -25,7 +25,7 @@ export type ExcludeQueryBetaQueryVariables = Exact<{ export type ExcludeQueryBetaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroAndFriendsNamesQueryVariables = Exact<{ @@ -34,16 +34,16 @@ export type HeroAndFriendsNamesQueryVariables = Exact<{ export type HeroAndFriendsNamesQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | { __typename?: 'Human'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | null; }; @@ -52,7 +52,7 @@ export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; appearsIn: Array } | { __typename?: 'Human'; name: string; appearsIn: Array } | null; @@ -64,15 +64,15 @@ export type HeroDetailsQueryVariables = Exact<{ export type HeroDetailsQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { __typename?: 'Human'; height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; @@ -82,9 +82,9 @@ export type HeroDetailsWithFragmentQueryVariables = Exact<{ export type HeroDetailsWithFragmentQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; @@ -94,7 +94,7 @@ export type HeroNameQueryVariables = Exact<{ export type HeroNameQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ @@ -104,7 +104,7 @@ export type HeroNameConditionalInclusionQueryVariables = Exact<{ export type HeroNameConditionalInclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ @@ -114,7 +114,7 @@ export type HeroNameConditionalExclusionQueryVariables = Exact<{ export type HeroNameConditionalExclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ @@ -123,19 +123,19 @@ export type HeroParentTypeDependentFieldQueryVariables = Exact<{ export type HeroParentTypeDependentFieldQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | { __typename?: 'Human'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | null; @@ -147,22 +147,22 @@ export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ export type HeroTypeDependentAliasedFieldQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { __typename?: 'Droid'; property: string | null } | { __typename?: 'Human'; property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass: number | null }; export type HumanWithNullHeightQueryVariables = Exact<{ [key: string]: never }>; export type HumanWithNullHeightQuery = { __typename?: 'Query'; - human?: { __typename?: 'Human'; name: string; mass?: number | null } | null; + human: { __typename?: 'Human'; name: string; mass: number | null } | null; }; export type TwoHeroesQueryVariables = Exact<{ [key: string]: never }>; export type TwoHeroesQuery = { __typename?: 'Query'; - r2?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; - luke?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + r2: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + luke: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; diff --git a/dev-test/star-wars/types.ts b/dev-test/star-wars/types.ts index dabd899e390..e458fd3fb51 100644 --- a/dev-test/star-wars/types.ts +++ b/dev-test/star-wars/types.ts @@ -7,7 +7,7 @@ export type CreateReviewForEpisodeMutationVariables = Exact<{ export type CreateReviewForEpisodeMutation = { __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; + createReview: { __typename?: 'Review'; stars: number; commentary: string | null } | null; }; export type ExcludeQueryAlphaQueryVariables = Exact<{ @@ -16,7 +16,7 @@ export type ExcludeQueryAlphaQueryVariables = Exact<{ export type ExcludeQueryAlphaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type ExcludeQueryBetaQueryVariables = Exact<{ @@ -25,7 +25,7 @@ export type ExcludeQueryBetaQueryVariables = Exact<{ export type ExcludeQueryBetaQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroAndFriendsNamesQueryVariables = Exact<{ @@ -34,16 +34,16 @@ export type HeroAndFriendsNamesQueryVariables = Exact<{ export type HeroAndFriendsNamesQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | { __typename?: 'Human'; name: string; - friends?: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; + friends: Array<{ __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null> | null; } | null; }; @@ -52,7 +52,7 @@ export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; appearsIn: Array } | { __typename?: 'Human'; name: string; appearsIn: Array } | null; @@ -64,15 +64,15 @@ export type HeroDetailsQueryVariables = Exact<{ export type HeroDetailsQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { __typename?: 'Human'; height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; @@ -82,9 +82,9 @@ export type HeroDetailsWithFragmentQueryVariables = Exact<{ export type HeroDetailsWithFragmentQuery = { __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } + hero: + | { __typename?: 'Droid'; primaryFunction: string | null; name: string } + | { __typename?: 'Human'; height: number | null; name: string } | null; }; @@ -94,7 +94,7 @@ export type HeroNameQueryVariables = Exact<{ export type HeroNameQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ @@ -104,7 +104,7 @@ export type HeroNameConditionalInclusionQueryVariables = Exact<{ export type HeroNameConditionalInclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ @@ -114,7 +114,7 @@ export type HeroNameConditionalExclusionQueryVariables = Exact<{ export type HeroNameConditionalExclusionQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; + hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ @@ -123,19 +123,19 @@ export type HeroParentTypeDependentFieldQueryVariables = Exact<{ export type HeroParentTypeDependentFieldQuery = { __typename?: 'Query'; - hero?: + hero: | { __typename?: 'Droid'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | { __typename?: 'Human'; name: string; - friends?: Array< - { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height?: number | null; name: string } | null + friends: Array< + { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; height: number | null; name: string } | null > | null; } | null; @@ -147,22 +147,22 @@ export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ export type HeroTypeDependentAliasedFieldQuery = { __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { __typename?: 'Droid'; property: string | null } | { __typename?: 'Human'; property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass: number | null }; export type HumanWithNullHeightQueryVariables = Exact<{ [key: string]: never }>; export type HumanWithNullHeightQuery = { __typename?: 'Query'; - human?: { __typename?: 'Human'; name: string; mass?: number | null } | null; + human: { __typename?: 'Human'; name: string; mass: number | null } | null; }; export type TwoHeroesQueryVariables = Exact<{ [key: string]: never }>; export type TwoHeroesQuery = { __typename?: 'Query'; - r2?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; - luke?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + r2: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; + luke: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; }; diff --git a/dev-test/test-null-value/result.d.ts b/dev-test/test-null-value/result.d.ts index 71f68e1f690..43b53927040 100644 --- a/dev-test/test-null-value/result.d.ts +++ b/dev-test/test-null-value/result.d.ts @@ -4,4 +4,4 @@ export type CartLineFragment = { id: string; quantity: number }; export type TestQueryVariables = Exact<{ [key: string]: never }>; -export type TestQuery = { cart?: { lines: { nodes: Array<{ id: string; quantity: number }> } } | null }; +export type TestQuery = { cart: { lines: { nodes: Array<{ id: string; quantity: number }> } } | null }; diff --git a/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts b/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts index 35ecb4a9c22..94e5a5a5faf 100644 --- a/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts +++ b/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts @@ -4,7 +4,7 @@ export type TestQueryVariables = Exact<{ [key: string]: never }>; export type TestQuery = { __typename?: 'Query'; - testArr1?: Array | null; + testArr1: Array | null; testArr2: Array; testArr3: Array; }; diff --git a/dev-test/test-schema/types.preResolveTypes.ts b/dev-test/test-schema/types.preResolveTypes.ts index 35ecb4a9c22..94e5a5a5faf 100644 --- a/dev-test/test-schema/types.preResolveTypes.ts +++ b/dev-test/test-schema/types.preResolveTypes.ts @@ -4,7 +4,7 @@ export type TestQueryVariables = Exact<{ [key: string]: never }>; export type TestQuery = { __typename?: 'Query'; - testArr1?: Array | null; + testArr1: Array | null; testArr2: Array; testArr3: Array; }; diff --git a/examples/react/apollo-client/src/gql/graphql.ts b/examples/react/apollo-client/src/gql/graphql.ts index 839c15cecbe..57a176b0592 100644 --- a/examples/react/apollo-client/src/gql/graphql.ts +++ b/examples/react/apollo-client/src/gql/graphql.ts @@ -8,11 +8,11 @@ export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ export type AllFilmsWithVariablesQueryQuery = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; @@ -20,9 +20,9 @@ export type AllFilmsWithVariablesQueryQuery = { export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export const FilmItemFragmentDoc = { diff --git a/examples/react/http-executor/src/gql/graphql.ts b/examples/react/http-executor/src/gql/graphql.ts index 839c15cecbe..57a176b0592 100644 --- a/examples/react/http-executor/src/gql/graphql.ts +++ b/examples/react/http-executor/src/gql/graphql.ts @@ -8,11 +8,11 @@ export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ export type AllFilmsWithVariablesQueryQuery = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; @@ -20,9 +20,9 @@ export type AllFilmsWithVariablesQueryQuery = { export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export const FilmItemFragmentDoc = { diff --git a/examples/react/tanstack-react-query/src/gql/graphql.ts b/examples/react/tanstack-react-query/src/gql/graphql.ts index 7b85263029b..8cb1aa1b197 100644 --- a/examples/react/tanstack-react-query/src/gql/graphql.ts +++ b/examples/react/tanstack-react-query/src/gql/graphql.ts @@ -8,11 +8,11 @@ export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ export type AllFilmsWithVariablesQueryQuery = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; @@ -20,9 +20,9 @@ export type AllFilmsWithVariablesQueryQuery = { export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export class TypedDocumentString diff --git a/examples/react/urql/src/gql/graphql.ts b/examples/react/urql/src/gql/graphql.ts index f080e002be3..7be4d52413e 100644 --- a/examples/react/urql/src/gql/graphql.ts +++ b/examples/react/urql/src/gql/graphql.ts @@ -8,11 +8,11 @@ export type AllFilmsWithVariablesQuery199QueryVariables = Exact<{ export type AllFilmsWithVariablesQuery199Query = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; @@ -20,9 +20,9 @@ export type AllFilmsWithVariablesQuery199Query = { export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export class TypedDocumentString diff --git a/examples/typescript-esm/src/gql/graphql.ts b/examples/typescript-esm/src/gql/graphql.ts index e0a6513a6ce..5e8fa025254 100644 --- a/examples/typescript-esm/src/gql/graphql.ts +++ b/examples/typescript-esm/src/gql/graphql.ts @@ -6,14 +6,14 @@ export type AllPeopleQueryQueryVariables = Exact<{ [key: string]: never }>; export type AllPeopleQueryQuery = { __typename?: 'Root'; - allPeople?: { + allPeople: { __typename?: 'PeopleConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'PeopleEdge'; - node?: { + node: { __typename?: 'Person'; - name?: string | null; - homeworld?: { __typename?: 'Planet'; name?: string | null } | null; + name: string | null; + homeworld: { __typename?: 'Planet'; name: string | null } | null; } | null; } | null> | null; } | null; @@ -25,14 +25,14 @@ export type AllPeopleWithVariablesQueryQueryVariables = Exact<{ export type AllPeopleWithVariablesQueryQuery = { __typename?: 'Root'; - allPeople?: { + allPeople: { __typename?: 'PeopleConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'PeopleEdge'; - node?: { + node: { __typename?: 'Person'; - name?: string | null; - homeworld?: { __typename?: 'Planet'; name?: string | null } | null; + name: string | null; + homeworld: { __typename?: 'Planet'; name: string | null } | null; } | null; } | null> | null; } | null; diff --git a/examples/typescript-graphql-request/src/gql/graphql.ts b/examples/typescript-graphql-request/src/gql/graphql.ts index 173dcd437e5..69d6ca34aef 100644 --- a/examples/typescript-graphql-request/src/gql/graphql.ts +++ b/examples/typescript-graphql-request/src/gql/graphql.ts @@ -6,14 +6,14 @@ export type AllPeopleQueryQueryVariables = Exact<{ [key: string]: never }>; export type AllPeopleQueryQuery = { __typename?: 'Root'; - allPeople?: { + allPeople: { __typename?: 'PeopleConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'PeopleEdge'; - node?: { + node: { __typename?: 'Person'; - name?: string | null; - homeworld?: { __typename?: 'Planet'; name?: string | null } | null; + name: string | null; + homeworld: { __typename?: 'Planet'; name: string | null } | null; } | null; } | null> | null; } | null; @@ -25,14 +25,14 @@ export type AllPeopleWithVariablesQueryQueryVariables = Exact<{ export type AllPeopleWithVariablesQueryQuery = { __typename?: 'Root'; - allPeople?: { + allPeople: { __typename?: 'PeopleConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'PeopleEdge'; - node?: { + node: { __typename?: 'Person'; - name?: string | null; - homeworld?: { __typename?: 'Planet'; name?: string | null } | null; + name: string | null; + homeworld: { __typename?: 'Planet'; name: string | null } | null; } | null; } | null> | null; } | null; diff --git a/examples/vite/vite-react-cts/src/gql/graphql.ts b/examples/vite/vite-react-cts/src/gql/graphql.ts index 47f6fdc00b2..f8322b2e4c8 100644 --- a/examples/vite/vite-react-cts/src/gql/graphql.ts +++ b/examples/vite/vite-react-cts/src/gql/graphql.ts @@ -5,9 +5,9 @@ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ @@ -16,11 +16,11 @@ export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ export type AllFilmsWithVariablesQueryQuery = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; diff --git a/examples/vite/vite-react-mts/src/gql/graphql.ts b/examples/vite/vite-react-mts/src/gql/graphql.ts index 47f6fdc00b2..f8322b2e4c8 100644 --- a/examples/vite/vite-react-mts/src/gql/graphql.ts +++ b/examples/vite/vite-react-mts/src/gql/graphql.ts @@ -5,9 +5,9 @@ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ @@ -16,11 +16,11 @@ export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ export type AllFilmsWithVariablesQueryQuery = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; diff --git a/examples/vite/vite-react-ts/src/gql/graphql.ts b/examples/vite/vite-react-ts/src/gql/graphql.ts index 47f6fdc00b2..f8322b2e4c8 100644 --- a/examples/vite/vite-react-ts/src/gql/graphql.ts +++ b/examples/vite/vite-react-ts/src/gql/graphql.ts @@ -5,9 +5,9 @@ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ @@ -16,11 +16,11 @@ export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ export type AllFilmsWithVariablesQueryQuery = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; diff --git a/examples/vue/apollo-composable/src/gql/graphql.ts b/examples/vue/apollo-composable/src/gql/graphql.ts index 043c8a95f3a..a08f9eb03ae 100644 --- a/examples/vue/apollo-composable/src/gql/graphql.ts +++ b/examples/vue/apollo-composable/src/gql/graphql.ts @@ -8,11 +8,11 @@ export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ export type AllFilmsWithVariablesQueryQuery = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; @@ -20,9 +20,9 @@ export type AllFilmsWithVariablesQueryQuery = { export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export const FilmItemFragmentDoc = { diff --git a/examples/vue/urql/src/gql/graphql.ts b/examples/vue/urql/src/gql/graphql.ts index 043c8a95f3a..a08f9eb03ae 100644 --- a/examples/vue/urql/src/gql/graphql.ts +++ b/examples/vue/urql/src/gql/graphql.ts @@ -8,11 +8,11 @@ export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ export type AllFilmsWithVariablesQueryQuery = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; @@ -20,9 +20,9 @@ export type AllFilmsWithVariablesQueryQuery = { export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export const FilmItemFragmentDoc = { diff --git a/examples/vue/villus/src/gql/graphql.ts b/examples/vue/villus/src/gql/graphql.ts index 043c8a95f3a..a08f9eb03ae 100644 --- a/examples/vue/villus/src/gql/graphql.ts +++ b/examples/vue/villus/src/gql/graphql.ts @@ -8,11 +8,11 @@ export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ export type AllFilmsWithVariablesQueryQuery = { __typename?: 'Root'; - allFilms?: { + allFilms: { __typename?: 'FilmsConnection'; - edges?: Array<{ + edges: Array<{ __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + node: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; @@ -20,9 +20,9 @@ export type AllFilmsWithVariablesQueryQuery = { export type FilmItemFragment = { __typename?: 'Film'; id: string; - title?: string | null; - releaseDate?: string | null; - producers?: Array | null; + title: string | null; + releaseDate: string | null; + producers: Array | null; } & { ' $fragmentName'?: 'FilmItemFragment' }; export const FilmItemFragmentDoc = { diff --git a/packages/plugins/other/visitor-plugin-common/src/selection-set-processor/base.ts b/packages/plugins/other/visitor-plugin-common/src/selection-set-processor/base.ts index 8f2edb4a5aa..bb73edecdca 100644 --- a/packages/plugins/other/visitor-plugin-common/src/selection-set-processor/base.ts +++ b/packages/plugins/other/visitor-plugin-common/src/selection-set-processor/base.ts @@ -1,5 +1,5 @@ import { GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLOutputType, Location } from 'graphql'; -import { AvoidOptionalsConfig, ConvertNameFn, NormalizedScalarsMap } from '../types.js'; +import { ConvertNameFn, NormalizedScalarsMap } from '../types.js'; export type PrimitiveField = { isConditional: boolean; fieldName: string }; export type PrimitiveAliasedFields = { isConditional: boolean; alias: string; fieldName: string }; @@ -13,14 +13,8 @@ export type SelectionSetProcessorConfig = { enumPrefix: boolean | null; enumSuffix: boolean | null; scalars: NormalizedScalarsMap; - formatNamedField( - name: string, - type?: GraphQLOutputType | GraphQLNamedType | null, - isConditional?: boolean, - isOptional?: boolean - ): string; + formatNamedField(params: { name: string; isOptional?: boolean }): string; wrapTypeWithModifiers(baseType: string, type: GraphQLOutputType | GraphQLNamedType): string; - avoidOptionals?: AvoidOptionalsConfig | boolean; printFieldsOnNewLines?: boolean; }; diff --git a/packages/plugins/other/visitor-plugin-common/src/selection-set-processor/pre-resolve-types.ts b/packages/plugins/other/visitor-plugin-common/src/selection-set-processor/pre-resolve-types.ts index 2be42bfa053..e2fed371800 100644 --- a/packages/plugins/other/visitor-plugin-common/src/selection-set-processor/pre-resolve-types.ts +++ b/packages/plugins/other/visitor-plugin-common/src/selection-set-processor/pre-resolve-types.ts @@ -1,5 +1,5 @@ -import { getBaseType, removeNonNullWrapper } from '@graphql-codegen/plugin-helpers'; -import { GraphQLInterfaceType, GraphQLObjectType, isEnumType, isNonNullType } from 'graphql'; +import { getBaseType } from '@graphql-codegen/plugin-helpers'; +import { GraphQLInterfaceType, GraphQLObjectType, isEnumType } from 'graphql'; import { BaseSelectionSetProcessor, LinkField, @@ -34,15 +34,10 @@ export class PreResolveTypesProcessor extends BaseSelectionSetProcessor { if (aliasedField.fieldName === '__typename') { - const name = this.config.formatNamedField(aliasedField.alias, null); + const name = this.config.formatNamedField({ name: aliasedField.alias }); return { name, type: `'${schemaType.name}'`, @@ -101,12 +96,10 @@ export class PreResolveTypesProcessor extends BaseSelectionSetProcessor> = { __type: TypeMetaFieldDef, }; -export class SelectionSetToObject { +export class SelectionSetToObject< + Config extends ParsedDocumentsConfig = ParsedDocumentsConfig, + SelectionSetProcessorConfig extends BaseSelectionSetProcessorConfig = BaseSelectionSetProcessorConfig +> { protected _primitiveFields: PrimitiveField[] = []; protected _primitiveAliasedFields: PrimitiveAliasedFields[] = []; protected _linksFields: LinkField[] = []; protected _queriedForTypename = false; constructor( - protected _processor: BaseSelectionSetProcessor, + protected _processor: BaseSelectionSetProcessor, protected _scalars: NormalizedScalarsMap, protected _schema: GraphQLSchema, protected _convertName: ConvertNameFn, @@ -399,6 +403,7 @@ export class SelectionSetToObject`; }; - const formatNamedField = ( - name: string, - type: GraphQLOutputType | GraphQLNamedType | null, - isConditional = false, - isOptional = false - ): string => { - const optional = - isOptional || isConditional || (!this.config.avoidOptionals.field && !!type && !isNonNullType(type)); - return (this.config.immutableTypes ? `readonly ${name}` : name) + (optional ? '?' : ''); - }; - const allFragments: LoadedFragment[] = [ ...(documentNode.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION) as FragmentDefinitionNode[]).map( fragmentDef => ({ @@ -139,11 +125,12 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< enumPrefix: this.config.enumPrefix, enumSuffix: this.config.enumSuffix, scalars: this.scalars, - formatNamedField, + formatNamedField: ({ name, isOptional }) => { + return (this.config.immutableTypes ? `readonly ${name}` : name) + (isOptional ? '?' : ''); + }, wrapTypeWithModifiers(baseType, type) { return wrapTypeWithModifiers(baseType, type, { wrapOptional, wrapArray }); }, - avoidOptionals: this.config.avoidOptionals, printFieldsOnNewLines: this.config.printFieldsOnNewLines, }; const processor = new (preResolveTypes ? PreResolveTypesProcessor : TypeScriptSelectionSetProcessor)( @@ -165,6 +152,9 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< new TypeScriptOperationVariablesToObject( this.scalars, this.convertName.bind(this), + // FIXME: this is the legacy avoidOptionals which was used to make Result fields non-optional. This use case is no longer valid. + // It's also being used for Variables so people could already be using it. + // Maybe it's better to deprecate and remove, to see what users think. this.config.avoidOptionals, this.config.immutableTypes, this.config.namespacedImportName, diff --git a/packages/plugins/typescript/operations/tests/__snapshots__/ts-documents.spec.ts.snap b/packages/plugins/typescript/operations/tests/__snapshots__/ts-documents.spec.ts.snap index b9d144384f1..0ba7941fc12 100644 --- a/packages/plugins/typescript/operations/tests/__snapshots__/ts-documents.spec.ts.snap +++ b/packages/plugins/typescript/operations/tests/__snapshots__/ts-documents.spec.ts.snap @@ -18,19 +18,19 @@ exports[`TypeScript Operations Plugin > Issues > #2699 - Issues with multiple in export type GetEntityBrandDataQuery = { __typename?: 'Query', node: - | { __typename: 'Company', active: boolean, id: string, createdAt: any, updatedAt: any, brandData?: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle?: string | null, description: string } | null, createdBy?: { __typename?: 'User', id: string, name: string } | null, updatedBy?: { __typename?: 'User', id: string, name: string } | null } - | { __typename: 'Theater', active: boolean, id: string, createdAt: any, updatedAt: any, brandData?: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle?: string | null, description: string } | null, createdBy?: { __typename?: 'User', id: string, name: string } | null, updatedBy?: { __typename?: 'User', id: string, name: string } | null } - | { __typename: 'Movie', id: string, createdAt: any, updatedAt: any, brandData?: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle?: string | null, description: string } | null, createdBy?: { __typename?: 'User', id: string, name: string } | null, updatedBy?: { __typename?: 'User', id: string, name: string } | null } - | { __typename: 'User', id: string, createdAt: any, updatedAt: any, brandData?: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle?: string | null, description: string } | null, createdBy?: { __typename?: 'User', id: string, name: string } | null, updatedBy?: { __typename?: 'User', id: string, name: string } | null } + | { __typename: 'Company', active: boolean, id: string, createdAt: any, updatedAt: any, brandData: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null, createdBy: { __typename?: 'User', id: string, name: string } | null, updatedBy: { __typename?: 'User', id: string, name: string } | null } + | { __typename: 'Theater', active: boolean, id: string, createdAt: any, updatedAt: any, brandData: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null, createdBy: { __typename?: 'User', id: string, name: string } | null, updatedBy: { __typename?: 'User', id: string, name: string } | null } + | { __typename: 'Movie', id: string, createdAt: any, updatedAt: any, brandData: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null, createdBy: { __typename?: 'User', id: string, name: string } | null, updatedBy: { __typename?: 'User', id: string, name: string } | null } + | { __typename: 'User', id: string, createdAt: any, updatedAt: any, brandData: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null, createdBy: { __typename?: 'User', id: string, name: string } | null, updatedBy: { __typename?: 'User', id: string, name: string } | null } }; -type EntityBrandData_Company_Fragment = { __typename?: 'Company', brandData?: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle?: string | null, description: string } | null }; +type EntityBrandData_Company_Fragment = { __typename?: 'Company', brandData: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null }; -type EntityBrandData_Theater_Fragment = { __typename?: 'Theater', brandData?: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle?: string | null, description: string } | null }; +type EntityBrandData_Theater_Fragment = { __typename?: 'Theater', brandData: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null }; -type EntityBrandData_Movie_Fragment = { __typename?: 'Movie', brandData?: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle?: string | null, description: string } | null }; +type EntityBrandData_Movie_Fragment = { __typename?: 'Movie', brandData: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null }; -type EntityBrandData_User_Fragment = { __typename?: 'User', brandData?: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle?: string | null, description: string } | null }; +type EntityBrandData_User_Fragment = { __typename?: 'User', brandData: { __typename?: 'EntityBrandData', active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null }; export type EntityBrandDataFragment = | EntityBrandData_Company_Fragment @@ -39,13 +39,13 @@ export type EntityBrandDataFragment = | EntityBrandData_User_Fragment ; -type ElementMetadata_Company_Fragment = { __typename?: 'Company', createdAt: any, updatedAt: any, createdBy?: { __typename?: 'User', id: string, name: string } | null, updatedBy?: { __typename?: 'User', id: string, name: string } | null }; +type ElementMetadata_Company_Fragment = { __typename?: 'Company', createdAt: any, updatedAt: any, createdBy: { __typename?: 'User', id: string, name: string } | null, updatedBy: { __typename?: 'User', id: string, name: string } | null }; -type ElementMetadata_Theater_Fragment = { __typename?: 'Theater', createdAt: any, updatedAt: any, createdBy?: { __typename?: 'User', id: string, name: string } | null, updatedBy?: { __typename?: 'User', id: string, name: string } | null }; +type ElementMetadata_Theater_Fragment = { __typename?: 'Theater', createdAt: any, updatedAt: any, createdBy: { __typename?: 'User', id: string, name: string } | null, updatedBy: { __typename?: 'User', id: string, name: string } | null }; -type ElementMetadata_Movie_Fragment = { __typename?: 'Movie', createdAt: any, updatedAt: any, createdBy?: { __typename?: 'User', id: string, name: string } | null, updatedBy?: { __typename?: 'User', id: string, name: string } | null }; +type ElementMetadata_Movie_Fragment = { __typename?: 'Movie', createdAt: any, updatedAt: any, createdBy: { __typename?: 'User', id: string, name: string } | null, updatedBy: { __typename?: 'User', id: string, name: string } | null }; -type ElementMetadata_User_Fragment = { __typename?: 'User', createdAt: any, updatedAt: any, createdBy?: { __typename?: 'User', id: string, name: string } | null, updatedBy?: { __typename?: 'User', id: string, name: string } | null }; +type ElementMetadata_User_Fragment = { __typename?: 'User', createdAt: any, updatedAt: any, createdBy: { __typename?: 'User', id: string, name: string } | null, updatedBy: { __typename?: 'User', id: string, name: string } | null }; export type ElementMetadataFragment = | ElementMetadata_Company_Fragment @@ -82,56 +82,7 @@ export type QQuery = { __typename?: 'Query', hotel: { __typename?: 'Hotel', id: `; exports[`TypeScript Operations Plugin > Issues > #3064 - fragments over interfaces causes issues with fields 2`] = ` -"export type Maybe = T | null; -export type InputMaybe = Maybe; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; -export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; -/** All built-in and custom scalars, mapped to their actual values */ -export type Scalars = { - ID: { input: string; output: string; } - String: { input: string; output: string; } - Boolean: { input: boolean; output: boolean; } - Int: { input: number; output: number; } - Float: { input: number; output: number; } -}; - -export type Venue = { - id: Scalars['String']['output']; - name: Scalars['String']['output']; -}; - -export type GpsPosition = { - __typename?: 'GPSPosition'; - lat: Scalars['Float']['output']; - lng: Scalars['Float']['output']; -}; - -export type VenueWithPosition = { - id: Scalars['String']['output']; - gpsPosition: GpsPosition; -}; - -export type Hotel = VenueWithPosition & Venue & { - __typename?: 'Hotel'; - id: Scalars['String']['output']; - gpsPosition: GpsPosition; - name: Scalars['String']['output']; -}; - -export type Transport = Venue & { - __typename?: 'Transport'; - id: Scalars['String']['output']; - name: Scalars['String']['output']; -}; - -export type Query = { - __typename?: 'Query'; - hotel: Hotel; - transport: Transport; -}; -type Venue_Hotel_Fragment = { __typename?: 'Hotel', id: string, gpsPosition: { __typename?: 'GPSPosition', lat: number, lng: number } }; +"type Venue_Hotel_Fragment = { __typename?: 'Hotel', id: string, gpsPosition: { __typename?: 'GPSPosition', lat: number, lng: number } }; type Venue_Transport_Fragment = { __typename?: 'Transport', id: string }; @@ -192,7 +143,7 @@ exports[`TypeScript Operations Plugin > Selection Set > Should generate the corr export type UserQueryQuery = ( { __typename?: 'Query' } - & { user?: Maybe<( + & { user: Maybe<( { __typename?: 'User' } & Pick )> } @@ -211,7 +162,7 @@ exports[`TypeScript Operations Plugin > Selection Set > Should generate the corr export type UserQueryQuery = ( { __typename?: 'Query' } - & { user?: Maybe<( + & { user: Maybe<( { __typename?: 'User' } & Pick )> } @@ -225,7 +176,7 @@ exports[`TypeScript Operations Plugin > Selection Set > Should generate the corr export type UserQueryQuery = ( { __typename?: 'Query' } - & { user?: Maybe<( + & { user: Maybe<( { __typename?: 'User' } & Pick )> } @@ -266,7 +217,7 @@ exports[`TypeScript Operations Plugin > Selection Set > Should generate the corr export type Unnamed_1_Query = ( { __typename?: 'Query' } - & { b?: Maybe< + & { b: Maybe< | ( { __typename?: 'A' } & Pick @@ -420,7 +371,7 @@ export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; export type UserQueryQuery = ( { __typename?: 'Query' } - & { user?: Maybe< + & { user: Maybe< | ( { __typename?: 'Tom' } & Pick @@ -435,48 +386,12 @@ export type UserQueryQuery = ( `; exports[`TypeScript Operations Plugin > Union & Interfaces > #4216 - handle fragments against unions and interfaces with flattenGeneratedTypes 1`] = ` -"export type Maybe = T | null; -export type InputMaybe = Maybe; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; -export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; -/** All built-in and custom scalars, mapped to their actual values */ -export type Scalars = { - ID: { input: string; output: string; } - String: { input: string; output: string; } - Boolean: { input: boolean; output: boolean; } - Int: { input: number; output: number; } - Float: { input: number; output: number; } -}; - -export type Query = { - __typename?: 'Query'; - search?: Maybe>; -}; - -export type Concept = { - id?: Maybe; -}; - -export type Dimension = Concept & { - __typename?: 'Dimension'; - id?: Maybe; -}; - -export type DimValue = { - __typename?: 'DimValue'; - dimension?: Maybe; - value: Scalars['String']['output']; -}; - -export type Searchable = Dimension | DimValue; -export type SearchPopularQueryVariables = Exact<{ [key: string]: never; }>; +"export type SearchPopularQueryVariables = Exact<{ [key: string]: never; }>; export type SearchPopularQuery = ( { __typename?: 'Query' } - & { search?: Maybe @@ -484,7 +399,7 @@ export type SearchPopularQuery = ( | ( { __typename?: 'DimValue' } & Pick - & { dimension?: Maybe<( + & { dimension: Maybe<( { __typename?: 'Dimension' } & Pick )> } @@ -512,7 +427,7 @@ export type UserQueryQuery = ( | ( { __typename?: 'Error3' } & Pick - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } @@ -534,7 +449,7 @@ type UserResult1_Error2_Fragment = { __typename?: 'Error2' }; type UserResult1_Error3_Fragment = ( { __typename?: 'Error3' } - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } @@ -567,60 +482,7 @@ export type UserResultFragment = `; exports[`TypeScript Operations Plugin > Union & Interfaces > Should handle union selection sets with both FragmentSpreads and InlineFragments with flattenGeneratedTypes 1`] = ` -"export type Maybe = T | null; -export type InputMaybe = Maybe; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; -export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; -/** All built-in and custom scalars, mapped to their actual values */ -export type Scalars = { - ID: { input: string; output: string; } - String: { input: string; output: string; } - Boolean: { input: boolean; output: boolean; } - Int: { input: number; output: number; } - Float: { input: number; output: number; } -}; - -export type Error = { - message: Scalars['String']['output']; -}; - -export type Error1 = Error & { - __typename?: 'Error1'; - message: Scalars['String']['output']; -}; - -export type Error2 = Error & { - __typename?: 'Error2'; - message: Scalars['String']['output']; -}; - -export type Error3 = Error & { - __typename?: 'Error3'; - message: Scalars['String']['output']; - info?: Maybe; -}; - -export type AdditionalInfo = { - __typename?: 'AdditionalInfo'; - message: Scalars['String']['output']; - message2: Scalars['String']['output']; -}; - -export type User = { - __typename?: 'User'; - id: Scalars['ID']['output']; - login: Scalars['String']['output']; -}; - -export type UserResult = User | Error2 | Error3; - -export type Query = { - __typename?: 'Query'; - user: UserResult; -}; -export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; +"export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; export type UserQueryQuery = ( @@ -637,7 +499,7 @@ export type UserQueryQuery = ( | ( { __typename?: 'Error3' } & Pick - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } @@ -665,62 +527,7 @@ export type UserQueryQuery = ( `; exports[`TypeScript Operations Plugin > Union & Interfaces > Should handle union selection sets with both FragmentSpreads and InlineFragments with flattenGeneratedTypes and directives 1`] = ` -"export type Maybe = T | null; -export type InputMaybe = Maybe; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; -export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; -/** All built-in and custom scalars, mapped to their actual values */ -export type Scalars = { - ID: { input: string; output: string; } - String: { input: string; output: string; } - Boolean: { input: boolean; output: boolean; } - Int: { input: number; output: number; } - Float: { input: number; output: number; } -}; - -export type Error = { - message: Scalars['String']['output']; -}; - -export type Error1 = Error & { - __typename?: 'Error1'; - message: Scalars['String']['output']; -}; - -export type Error2 = Error & { - __typename?: 'Error2'; - message: Scalars['String']['output']; -}; - -export type Error3 = Error & { - __typename?: 'Error3'; - message: Scalars['String']['output']; - info?: Maybe; -}; - -export type AdditionalInfo = { - __typename?: 'AdditionalInfo'; - message: Scalars['String']['output']; - message2: Scalars['String']['output']; -}; - -export type User = { - __typename?: 'User'; - id: Scalars['ID']['output']; - login: Scalars['String']['output']; - test?: Maybe; - test2?: Maybe; -}; - -export type UserResult = User | Error2 | Error3; - -export type Query = { - __typename?: 'Query'; - user: UserResult; -}; -export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; +"export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; export type UserQueryQuery = ( @@ -743,7 +550,7 @@ export type UserQueryQuery = ( | ( { __typename?: 'Error3' } & Pick - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } diff --git a/packages/plugins/typescript/operations/tests/extract-all-types.spec.ts b/packages/plugins/typescript/operations/tests/extract-all-types.spec.ts index c64468cf85c..9796c0cb427 100644 --- a/packages/plugins/typescript/operations/tests/extract-all-types.spec.ts +++ b/packages/plugins/typescript/operations/tests/extract-all-types.spec.ts @@ -157,7 +157,7 @@ describe('extractAllFieldsToTypes: true', () => { export type OverlappingFieldsMergingTestQuery_Query = { __typename: 'Query', - me?: OverlappingFieldsMergingTestQuery_me | null + me: OverlappingFieldsMergingTestQuery_me | null }; @@ -187,7 +187,7 @@ describe('extractAllFieldsToTypes: true', () => { export type NestedOverlappingFieldsMergingTestQuery_Query = { __typename: 'Query', - me?: NestedOverlappingFieldsMergingTestQuery_me | null + me: NestedOverlappingFieldsMergingTestQuery_me | null }; @@ -409,11 +409,11 @@ describe('extractAllFieldsToTypes: true', () => { export type ConversationBotSolutionFragment_BotSolution_originatedFrom_TalkInteraction = { __typename: 'TalkInteraction' }; - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_NativeMessagingInteraction = { __typename: 'NativeMessagingInteraction', conversationId?: string | null }; + export type ConversationBotSolutionFragment_BotSolution_originatedFrom_NativeMessagingInteraction = { __typename: 'NativeMessagingInteraction', conversationId: string | null }; - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_WhatsAppInteraction = { __typename: 'WhatsAppInteraction', conversationId?: string | null }; + export type ConversationBotSolutionFragment_BotSolution_originatedFrom_WhatsAppInteraction = { __typename: 'WhatsAppInteraction', conversationId: string | null }; - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_WeChatInteraction = { __typename: 'WeChatInteraction', conversationId?: string | null }; + export type ConversationBotSolutionFragment_BotSolution_originatedFrom_WeChatInteraction = { __typename: 'WeChatInteraction', conversationId: string | null }; export type ConversationBotSolutionFragment_BotSolution_originatedFrom_NotImplementedOriginatedFrom = { __typename: 'NotImplementedOriginatedFrom' }; @@ -439,11 +439,11 @@ describe('extractAllFieldsToTypes: true', () => { export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_TalkInteraction = { __typename: 'TalkInteraction' }; - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_NativeMessagingInteraction = { __typename: 'NativeMessagingInteraction', conversationId?: string | null }; + export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_NativeMessagingInteraction = { __typename: 'NativeMessagingInteraction', conversationId: string | null }; - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_WhatsAppInteraction = { __typename: 'WhatsAppInteraction', conversationId?: string | null }; + export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_WhatsAppInteraction = { __typename: 'WhatsAppInteraction', conversationId: string | null }; - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_WeChatInteraction = { __typename: 'WeChatInteraction', conversationId?: string | null }; + export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_WeChatInteraction = { __typename: 'WeChatInteraction', conversationId: string | null }; export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_NotImplementedOriginatedFrom = { __typename: 'NotImplementedOriginatedFrom' }; @@ -501,11 +501,11 @@ describe('extractAllFieldsToTypes: true', () => { type ConversationOriginatedFrom_TalkInteraction_Fragment = { __typename: 'TalkInteraction' }; - type ConversationOriginatedFrom_NativeMessagingInteraction_Fragment = { __typename: 'NativeMessagingInteraction', conversationId?: string | null }; + type ConversationOriginatedFrom_NativeMessagingInteraction_Fragment = { __typename: 'NativeMessagingInteraction', conversationId: string | null }; - type ConversationOriginatedFrom_WhatsAppInteraction_Fragment = { __typename: 'WhatsAppInteraction', conversationId?: string | null }; + type ConversationOriginatedFrom_WhatsAppInteraction_Fragment = { __typename: 'WhatsAppInteraction', conversationId: string | null }; - type ConversationOriginatedFrom_WeChatInteraction_Fragment = { __typename: 'WeChatInteraction', conversationId?: string | null }; + type ConversationOriginatedFrom_WeChatInteraction_Fragment = { __typename: 'WeChatInteraction', conversationId: string | null }; type ConversationOriginatedFrom_NotImplementedOriginatedFrom_Fragment = { __typename: 'NotImplementedOriginatedFrom' }; @@ -525,11 +525,11 @@ describe('extractAllFieldsToTypes: true', () => { export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_TalkInteraction = { __typename: 'TalkInteraction', channel: string, type: CallType }; - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_NativeMessagingInteraction = { __typename: 'NativeMessagingInteraction', conversationId?: string | null }; + export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_NativeMessagingInteraction = { __typename: 'NativeMessagingInteraction', conversationId: string | null }; - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_WhatsAppInteraction = { __typename: 'WhatsAppInteraction', conversationId?: string | null }; + export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_WhatsAppInteraction = { __typename: 'WhatsAppInteraction', conversationId: string | null }; - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_WeChatInteraction = { __typename: 'WeChatInteraction', conversationId?: string | null }; + export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_WeChatInteraction = { __typename: 'WeChatInteraction', conversationId: string | null }; export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_NotImplementedOriginatedFrom = { __typename: 'NotImplementedOriginatedFrom' }; @@ -583,7 +583,7 @@ describe('extractAllFieldsToTypes: true', () => { export type ConversationBotSolutionFragment_BotSolution_originatedFrom_TalkInteraction_NotImplementedOriginatedFrom = { __typename: 'TalkInteraction' | 'NotImplementedOriginatedFrom' }; export type ConversationBotSolutionFragment_BotSolution_originatedFrom_NativeMessagingInteraction_WhatsAppInteraction_WeChatInteraction = ( - { conversationId?: string | null } + { conversationId: string | null } & { __typename: 'NativeMessagingInteraction' | 'WhatsAppInteraction' | 'WeChatInteraction' } ); @@ -622,7 +622,7 @@ describe('extractAllFieldsToTypes: true', () => { export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_TalkInteraction_NotImplementedOriginatedFrom = { __typename: 'TalkInteraction' | 'NotImplementedOriginatedFrom' }; export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_NativeMessagingInteraction_WhatsAppInteraction_WeChatInteraction = ( - { conversationId?: string | null } + { conversationId: string | null } & { __typename: 'NativeMessagingInteraction' | 'WhatsAppInteraction' | 'WeChatInteraction' } ); @@ -668,7 +668,7 @@ describe('extractAllFieldsToTypes: true', () => { type ConversationOriginatedFrom_TalkInteraction_NotImplementedOriginatedFrom_Fragment = { __typename: 'TalkInteraction' | 'NotImplementedOriginatedFrom' }; type ConversationOriginatedFrom_NativeMessagingInteraction_WhatsAppInteraction_WeChatInteraction_Fragment = ( - { conversationId?: string | null } + { conversationId: string | null } & { __typename: 'NativeMessagingInteraction' | 'WhatsAppInteraction' | 'WeChatInteraction' } ); @@ -695,7 +695,7 @@ describe('extractAllFieldsToTypes: true', () => { ); export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_NativeMessagingInteraction_WhatsAppInteraction_WeChatInteraction = ( - { conversationId?: string | null } + { conversationId: string | null } & { __typename: 'NativeMessagingInteraction' | 'WhatsAppInteraction' | 'WeChatInteraction' } ); @@ -890,17 +890,17 @@ describe('extractAllFieldsToTypes: true', () => { ); type ConversationOriginatedFrom_NativeMessagingInteraction_Fragment = ( - { __typename: 'NativeMessagingInteraction', conversationId?: string | null } + { __typename: 'NativeMessagingInteraction', conversationId: string | null } & MessageEnvelopeData_NativeMessagingInteraction_Fragment ); type ConversationOriginatedFrom_WhatsAppInteraction_Fragment = ( - { __typename: 'WhatsAppInteraction', conversationId?: string | null } + { __typename: 'WhatsAppInteraction', conversationId: string | null } & MessageEnvelopeData_WhatsAppInteraction_Fragment ); type ConversationOriginatedFrom_WeChatInteraction_Fragment = ( - { __typename: 'WeChatInteraction', conversationId?: string | null } + { __typename: 'WeChatInteraction', conversationId: string | null } & MessageEnvelopeData_WeChatInteraction_Fragment ); @@ -1127,17 +1127,17 @@ describe('extractAllFieldsToTypes: true', () => { ) & { ' $fragmentName'?: 'ConversationOriginatedFrom_TalkInteraction_Fragment' }; type ConversationOriginatedFrom_NativeMessagingInteraction_Fragment = ( - { __typename: 'NativeMessagingInteraction', conversationId?: string | null } + { __typename: 'NativeMessagingInteraction', conversationId: string | null } & { ' $fragmentRefs'?: { 'MessageEnvelopeData_NativeMessagingInteraction_Fragment': MessageEnvelopeData_NativeMessagingInteraction_Fragment } } ) & { ' $fragmentName'?: 'ConversationOriginatedFrom_NativeMessagingInteraction_Fragment' }; type ConversationOriginatedFrom_WhatsAppInteraction_Fragment = ( - { __typename: 'WhatsAppInteraction', conversationId?: string | null } + { __typename: 'WhatsAppInteraction', conversationId: string | null } & { ' $fragmentRefs'?: { 'MessageEnvelopeData_WhatsAppInteraction_Fragment': MessageEnvelopeData_WhatsAppInteraction_Fragment } } ) & { ' $fragmentName'?: 'ConversationOriginatedFrom_WhatsAppInteraction_Fragment' }; type ConversationOriginatedFrom_WeChatInteraction_Fragment = ( - { __typename: 'WeChatInteraction', conversationId?: string | null } + { __typename: 'WeChatInteraction', conversationId: string | null } & { ' $fragmentRefs'?: { 'MessageEnvelopeData_WeChatInteraction_Fragment': MessageEnvelopeData_WeChatInteraction_Fragment } } ) & { ' $fragmentName'?: 'ConversationOriginatedFrom_WeChatInteraction_Fragment' }; diff --git a/packages/plugins/typescript/operations/tests/ts-documents.apolloUnmask.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.apolloUnmask.spec.ts index 7332c93f5a7..efc793a3a32 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.apolloUnmask.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.apolloUnmask.spec.ts @@ -25,7 +25,7 @@ describe('TypeScript Operations Plugin - apolloUnmask', () => { "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type Unnamed_1_Query = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; " @@ -53,7 +53,7 @@ describe('TypeScript Operations Plugin - apolloUnmask', () => { "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( + export type Unnamed_1_Query = { __typename?: 'Query', me: ( { __typename?: 'User' } & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } } ) | null }; @@ -84,7 +84,7 @@ describe('TypeScript Operations Plugin - apolloUnmask', () => { "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( + export type Unnamed_1_Query = { __typename?: 'Query', me: ( { __typename?: 'User' } & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } } ) | null }; @@ -120,7 +120,7 @@ describe('TypeScript Operations Plugin - apolloUnmask', () => { "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( + export type Unnamed_1_Query = { __typename?: 'Query', me: ( { __typename?: 'User', id: string } & { ' $fragmentRefs'?: { 'UserFragment2Fragment': UserFragment2Fragment } } ) | null }; @@ -159,7 +159,7 @@ describe('TypeScript Operations Plugin - apolloUnmask', () => { "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( + export type Unnamed_1_Query = { __typename?: 'Query', me: ( { __typename?: 'User', id: string, email: string } & { ' $fragmentRefs'?: { 'UserFragment2Fragment': UserFragment2Fragment } } ) | null }; diff --git a/packages/plugins/typescript/operations/tests/ts-documents.nullability.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.nullability.spec.ts index fb93cae9890..a1889143ccf 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.nullability.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.nullability.spec.ts @@ -79,15 +79,15 @@ describe('TypeScript Operations Plugin - nullability', () => { export type Unnamed_1_Query = { __typename?: "Query"; - me?: { + me: { __typename?: "User"; field: string; fieldLevel0: string; - fieldLevel1?: string | null; + fieldLevel1: string | null; fieldBothLevels: string; list: Array; listLevel0: Array; - listLevel1?: Array | null; + listLevel1: Array | null; listBothLevels: Array; nonNullableList: Array; nonNullableListLevel0: Array; @@ -95,7 +95,7 @@ describe('TypeScript Operations Plugin - nullability', () => { nonNullableListBothLevels: Array; listWithNonNullableItem: Array; listWithNonNullableItemLevel0: Array; - listWithNonNullableItemLevel1?: Array | null; + listWithNonNullableItemLevel1: Array | null; listWithNonNullableItemBothLevels: Array; nonNullableListWithNonNullableItem: Array; nonNullableListWithNonNullableItemLevel0: Array; @@ -125,24 +125,24 @@ describe('TypeScript Operations Plugin - nullability', () => { export type Unnamed_1_Query = { __typename?: "Query"; - me?: { + me: { __typename?: "User"; - field?: string | null; - fieldLevel0?: string | null; - fieldLevel1?: string | null; - fieldBothLevels?: string | null; - list?: Array | null; - listLevel0?: Array | null; - listLevel1?: Array | null; - listBothLevels?: Array | null; + field: string | null; + fieldLevel0: string | null; + fieldLevel1: string | null; + fieldBothLevels: string | null; + list: Array | null; + listLevel0: Array | null; + listLevel1: Array | null; + listBothLevels: Array | null; nonNullableList: Array; nonNullableListLevel0: Array; nonNullableListLevel1: Array; nonNullableListBothLevels: Array; - listWithNonNullableItem?: Array | null; - listWithNonNullableItemLevel0?: Array | null; - listWithNonNullableItemLevel1?: Array | null; - listWithNonNullableItemBothLevels?: Array | null; + listWithNonNullableItem: Array | null; + listWithNonNullableItemLevel0: Array | null; + listWithNonNullableItemLevel1: Array | null; + listWithNonNullableItemBothLevels: Array | null; nonNullableListWithNonNullableItem: Array; nonNullableListWithNonNullableItemLevel0: Array; nonNullableListWithNonNullableItemLevel1: Array; diff --git a/packages/plugins/typescript/operations/tests/ts-documents.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.spec.ts index 28dd11e4a41..54ade101795 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.spec.ts @@ -9,14 +9,8 @@ import { schema } from './shared/schema.js'; describe('TypeScript Operations Plugin', () => { const gitHuntSchema = buildClientSchema(require('../../../../../dev-test/githunt/schema.json')); - const validate = async ( - content: Types.PluginOutput, - config: any = {}, - pluginSchema = schema, - usage = '', - suspenseErrors = [] - ) => { - const m = mergeOutputs([await tsPlugin(pluginSchema, [], config, { outputFile: '' }), content, usage]); + const validate = async (content: Types.PluginOutput, usage = '', suspenseErrors = []) => { + const m = mergeOutputs([content, usage]); validateTs(m, undefined, undefined, undefined, suspenseErrors); return m; @@ -48,7 +42,7 @@ describe('TypeScript Operations Plugin', () => { }); expect(content).not.toContain('export'); - await validate(content, config); + await validate(content); }); it('Should handle "namespacedImportName" and add it when specified', async () => { @@ -97,7 +91,7 @@ describe('TypeScript Operations Plugin', () => { )> } ); `); - await validate(content, config, schema, '', [`Cannot find namespace 'Types'.`]); + await validate(content, '', [`Cannot find namespace 'Types'.`]); }); it('Can merge an inline fragment with a spread', async () => { @@ -194,10 +188,10 @@ describe('TypeScript Operations Plugin', () => { }); expect(content).toBeSimilarStringTo( - `export type TestQuery = { __typename?: 'Query', f?: Types.E | null, user: { __typename?: 'User', id: string, f?: Types.E | null, j?: any | null } };` + `export type TestQuery = { __typename?: 'Query', f: Types.E | null, user: { __typename?: 'User', id: string, f: Types.E | null, j: any | null } };` ); - await validate(content, config, schema, '', [`Cannot find namespace 'Types'.`]); + await validate(content, '', [`Cannot find namespace 'Types'.`]); }); it('Should generate the correct output when using immutableTypes config', async () => { @@ -240,7 +234,7 @@ describe('TypeScript Operations Plugin', () => { )> } ); `); - await validate(content, config); + await validate(content); }); it('should include fragment variable definitions when experimentalFragmentVariables is set', async () => { @@ -299,7 +293,7 @@ describe('TypeScript Operations Plugin', () => { } ); expect(content).toBeSimilarStringTo(` - export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', name: string, age?: number | 'specialType', address?: string, nicknames?: Array | 'specialType', parents?: Array } }; + export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', name: string, age: number | 'specialType', address?: string, nicknames?: Array | 'specialType', parents?: Array } }; `); }); @@ -376,7 +370,7 @@ describe('TypeScript Operations Plugin', () => { outputFile: '', }); expect(content).toContain(`Pick`); - await validate(content, config, testSchema); + await validate(content); }); }); @@ -425,7 +419,7 @@ describe('TypeScript Operations Plugin', () => { ); `); - await validate(content, config); + await validate(content); }); }); @@ -470,7 +464,7 @@ describe('TypeScript Operations Plugin', () => { )> } ); `); - await validate(content, config); + await validate(content); }); it('Should allow custom naming and point to the correct type - with custom prefix', async () => { @@ -517,7 +511,7 @@ describe('TypeScript Operations Plugin', () => { )> } ); `); - await validate(content, config); + await validate(content); }); it('Test for dedupeOperationSuffix', async () => { @@ -842,12 +836,12 @@ describe('TypeScript Operations Plugin', () => { }); expect(content).toBeSimilarStringTo( - `export type Q1Query = { test?: Maybe<( + `export type Q1Query = { test: Maybe<( { __typename?: 'Test' } & Pick )> };` ); - await validate(content, config, testSchema); + await validate(content); }); it('Should ignore __typename for root types with skipTypeNameForRoot = true, and with nonOptionalTypename = true', async () => { @@ -877,12 +871,12 @@ describe('TypeScript Operations Plugin', () => { }); expect(content).toBeSimilarStringTo( - `export type Q1Query = { test?: Maybe<( + `export type Q1Query = { test: Maybe<( { __typename: 'Test' } & Pick )> };` ); - await validate(content, config, testSchema); + await validate(content); }); it('Should ignore skipTypeNameForRoot = true when __typename is specified manually', async () => { @@ -915,13 +909,13 @@ describe('TypeScript Operations Plugin', () => { expect(content).toBeSimilarStringTo( `export type Q1Query = ( { __typename: 'Query' } - & { test?: Maybe<( + & { test: Maybe<( { __typename: 'Test' } & Pick )> } );` ); - await validate(content, config, testSchema); + await validate(content); }); it('Should add __typename correctly with nonOptionalTypename=false,skipTypename=true,preResolveTypes=true and explicit field', async () => { @@ -997,7 +991,7 @@ export type Q2Query = { search: Array< | { __typename: 'Person', id: string, name: string } > };` ); - await validate(content, config, testSchema); + await validate(content); }); it('Should skip __typename when skipTypename is set to true', async () => { @@ -1012,7 +1006,7 @@ export type Q2Query = { search: Array< }); expect(content).not.toContain(`__typename`); - await validate(content, config); + await validate(content); }); it('Should add __typename when dealing with fragments', async () => { @@ -1054,7 +1048,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type TestQuery = ( { __typename?: 'Query' } - & { some?: Maybe<( + & { some: Maybe<( { __typename: 'A' } & Pick ) | ( @@ -1063,7 +1057,7 @@ export type Q2Query = { search: Array< )> } ); `); - await validate(content, config, testSchema); + await validate(content); }); it('Should add aliased __typename correctly', async () => { @@ -1084,7 +1078,7 @@ export type Q2Query = { search: Array< & { type: 'Query' } ); `); - await validate(content, config); + await validate(content); }); it('Should add aliased __typename correctly with preResovleTypes', async () => { @@ -1099,9 +1093,9 @@ export type Q2Query = { search: Array< outputFile: '', }); expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = { __typename?: 'Query', dummy?: string | null, type: 'Query' }; + export type Unnamed_1_Query = { __typename?: 'Query', dummy: string | null, type: 'Query' }; `); - await validate(content, config); + await validate(content); }); it('Should add __typename as non-optional when explicitly specified', async () => { @@ -1121,7 +1115,7 @@ export type Q2Query = { search: Array< & Pick ); `); - await validate(content, config); + await validate(content); }); it('Should add __typename as non-optional when forced', async () => { @@ -1140,7 +1134,7 @@ export type Q2Query = { search: Array< & Pick ); `); - await validate(content, config); + await validate(content); }); it('Should add __typename as optional when its not specified', async () => { @@ -1159,7 +1153,7 @@ export type Q2Query = { search: Array< & Pick ); `); - await validate(content, config); + await validate(content); }); it('Should add __typename as non-optional when its explictly specified, even if skipTypename is true', async () => { @@ -1180,7 +1174,7 @@ export type Q2Query = { search: Array< & Pick ); `); - await validate(content, config); + await validate(content); }); it('Should add __typename correctly when unions are in use', async () => { @@ -1204,7 +1198,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type UnionTestQuery = ( { __typename?: 'Query' } - & { unionTest?: Maybe<( + & { unionTest: Maybe<( { __typename?: 'User' } & Pick ) | ( @@ -1213,7 +1207,7 @@ export type Q2Query = { search: Array< )> } ); `); - await validate(content, config); + await validate(content); }); it('Should add __typename correctly when interfaces are in use', async () => { @@ -1255,7 +1249,7 @@ export type Q2Query = { search: Array< )> } ); `); - await validate(content, config); + await validate(content); }); it('should mark __typename as non optional in case it is included in the selection set of an interface field', async () => { const ast = parse(/* GraphQL */ ` @@ -1287,7 +1281,7 @@ export type Q2Query = { search: Array< )> } ); `); - await validate(content, config); + await validate(content); }); it('should mark __typename as non optional in case it is included in the selection set of an union field', async () => { const ast = parse(/* GraphQL */ ` @@ -1309,7 +1303,7 @@ export type Q2Query = { search: Array< }); expect(content).toBeSimilarStringTo(` { __typename?: 'Query' } - & { unionTest?: Maybe<( + & { unionTest: Maybe<( { __typename: 'User' } & Pick ) | ( @@ -1318,7 +1312,7 @@ export type Q2Query = { search: Array< )> } ); `); - await validate(content, config); + await validate(content); }); }); @@ -1339,7 +1333,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; `); - await validate(content, config); + await validate(content); }); it('Should handle unnamed documents correctly with multiple documents', async () => { @@ -1369,7 +1363,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type Unnamed_2_QueryVariables = Exact<{ [key: string]: never; }>; `); - await validate(content, config); + await validate(content); }); }); @@ -1456,7 +1450,7 @@ export type Q2Query = { search: Array< } `; - await validate(content, config, testSchema, usage); + await validate(content, usage); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1485,7 +1479,7 @@ export type Q2Query = { search: Array< const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { outputFile: '', }); - await validate(content, config, testSchema); + await validate(content); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1518,7 +1512,7 @@ export type Q2Query = { search: Array< const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { outputFile: '', }); - await validate(content, config, testSchema); + await validate(content); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1549,7 +1543,7 @@ export type Q2Query = { search: Array< const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { outputFile: '', }); - await validate(content, config, testSchema); + await validate(content); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1585,8 +1579,6 @@ export type Q2Query = { search: Array< }); await validate( content, - config, - testSchema, `function test(q: AaaQuery) { console.log(q.user.__typename === 'User' ? q.user.id : null); console.log(q.user.__typename === 'Error' ? q.user.__typename : null); @@ -1644,8 +1636,6 @@ export type Q2Query = { search: Array< await validate( content, - config, - testSchema, ` function test(a: UserFragment) { if (a.__typename === 'Tom') { @@ -1717,7 +1707,7 @@ export type Q2Query = { search: Array< } `; - await validate(content, config, testSchema, usage); + await validate(content, usage); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1743,12 +1733,12 @@ export type Q2Query = { search: Array< outputFile: '', }); expect(content).toBeSimilarStringTo(` - export type MeQuery = { me?: Maybe<( + export type MeQuery = { me: Maybe<( Pick - & { profile?: Maybe> } + & { profile: Maybe> } )> }; `); - await validate(content, config); + await validate(content); }); it('Should support fragment spread correctly with simple type with other fields', async () => { @@ -1773,12 +1763,12 @@ export type Q2Query = { search: Array< }); expect(content).toBeSimilarStringTo(` - export type MeQuery = { me?: Maybe<( + export type MeQuery = { me: Maybe<( Pick - & { profile?: Maybe> } + & { profile: Maybe> } )> }; `); - await validate(content, config); + await validate(content); }); it('Should support fragment spread correctly with multiple fragment spread', async () => { @@ -1809,10 +1799,10 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type MeQuery = ( { __typename?: 'Query' } - & { me?: Maybe<( + & { me: Maybe<( { __typename?: 'User' } & Pick - & { profile?: Maybe<( + & { profile: Maybe<( { __typename?: 'Profile' } & Pick )> } @@ -1822,7 +1812,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type UserProfileFragment = ( { __typename?: 'User' } - & { profile?: Maybe<( + & { profile: Maybe<( { __typename?: 'Profile' } & Pick )> } @@ -1834,7 +1824,7 @@ export type Q2Query = { search: Array< & Pick ); `); - await validate(content, config); + await validate(content); }); it('Should generate the correct intersection for fragments when using with interfaces with different type', async () => { @@ -1884,7 +1874,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type Unnamed_1_Query = ( { __typename?: 'Query' } - & { b?: Maybe<( + & { b: Maybe<( { __typename?: 'A' } & Pick ) | ( @@ -1903,7 +1893,7 @@ export type Q2Query = { search: Array< & Pick ); `); - await validate(content, config, schema); + await validate(content); }); it('Should generate the correct intersection for fragments when type implements 2 interfaces', async () => { @@ -1961,7 +1951,7 @@ export type Q2Query = { search: Array< ) } ); `); - await validate(content, config, schema); + await validate(content); }); it('Should generate the correct intersection for fragments when using with interfaces with same type', async () => { @@ -2009,7 +1999,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type Unnamed_1_Query = ( { __typename?: 'Query' } - & { b?: Maybe<( + & { b: Maybe<( { __typename?: 'A' } & Pick ) | { __typename?: 'B' }> } @@ -2069,7 +2059,7 @@ export type Q2Query = { search: Array< )> } ); `); - await validate(content, config); + await validate(content); }); it('Should support union correctly when used with inline fragments', async () => { @@ -2094,7 +2084,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type UnionTestQuery = ( { __typename?: 'Query' } - & { unionTest?: Maybe<( + & { unionTest: Maybe<( { __typename?: 'User' } & Pick ) | ( @@ -2103,7 +2093,7 @@ export type Q2Query = { search: Array< )> } ); `); - await validate(content, config); + await validate(content); }); it('Should support union correctly when used with inline fragments on types implementing common interface', async () => { @@ -2141,7 +2131,7 @@ export type Q2Query = { search: Array< )> } ); `); - await validate(content, config); + await validate(content); }); it('Should support union correctly when used with inline fragments on types implementing common interface and also other types', async () => { @@ -2186,7 +2176,7 @@ export type Q2Query = { search: Array< )> } ); `); - await validate(content, config); + await validate(content); }); it('Should support merging identical fragment union types', async () => { @@ -2222,7 +2212,7 @@ export type Q2Query = { search: Array< & { __typename?: 'TextNotification' | 'ImageNotification' } ); `); - await validate(content, config); + await validate(content); }); it('Should support computing correct names for merged fragment union types', async () => { @@ -2252,7 +2242,7 @@ export type Q2Query = { search: Array< export type NFragment = N_TextNotification_Fragment | N_ImageNotification_Fragment; `); - await validate(content, config); + await validate(content); }); it('Should support computing correct names for large merged fragment union types', async () => { @@ -2313,7 +2303,7 @@ export type Q2Query = { search: Array< export type NFragment = N_A_Fragment | N_zhJJUzpMTyh98zugnx0IKwiLetPNjV8KybSlmpAEUU_Fragment; `); - await validate(content, config); + await validate(content); }); it('Should not create empty types when merging fragment union types', async () => { @@ -2340,7 +2330,7 @@ export type Q2Query = { search: Array< & { __typename?: 'Query' } ); `); - await validate(content, config); + await validate(content); }); it('Should support merging identical fragment union types with skipTypename', async () => { @@ -2365,7 +2355,7 @@ export type Q2Query = { search: Array< export type testQuery = { notifications: Array<{ id: string }> }; `); - await validate(content, config); + await validate(content); }); it('Should support computing correct names for merged fragment union types with skipTypename', async () => { @@ -2389,7 +2379,7 @@ export type Q2Query = { search: Array< export type NFragment = N_TextNotification_Fragment | N_ImageNotification_Fragment; `); - await validate(content, config); + await validate(content); }); it('Ignores merging when enabled alongside inline fragment masking', async () => { @@ -2427,7 +2417,7 @@ export type Q2Query = { search: Array< export type NFragment = N_TextNotification_Fragment | N_ImageNotification_Fragment; `); - await validate(content, config); + await validate(content); }); it('Should support inline fragments', async () => { @@ -2449,13 +2439,13 @@ export type Q2Query = { search: Array< outputFile: '', }); expect(content).toBeSimilarStringTo(` - export type CurrentUserQuery = { me?: Maybe<( + export type CurrentUserQuery = { me: Maybe<( Pick - & { profile?: Maybe> } + & { profile: Maybe> } )> }; `); - await validate(content, config); + await validate(content); }); it('Should build a basic selection set based on basic query on GitHub schema', async () => { @@ -2486,12 +2476,12 @@ export type Q2Query = { search: Array< }>;` ); expect(content).toBeSimilarStringTo(` - export type MeQuery = { currentUser?: Maybe>, entry?: Maybe<( + export type MeQuery = { currentUser: Maybe>, entry: Maybe<( Pick & { postedBy: Pick } )> }; `); - await validate(content, config, gitHuntSchema); + await validate(content); }); it('Should build a basic selection set based on basic query on GitHub schema with preResolveTypes=true', async () => { @@ -2517,9 +2507,9 @@ export type Q2Query = { search: Array< }); expect(content).toBeSimilarStringTo(` - export type MeQuery = { __typename?: 'Query', currentUser?: { __typename?: 'User', login: string, html_url: string } | null, entry?: { __typename?: 'Entry', id: number, createdAt: number, postedBy: { __typename?: 'User', login: string, html_url: string } } | null }; + export type MeQuery = { __typename?: 'Query', currentUser: { __typename?: 'User', login: string, html_url: string } | null, entry: { __typename?: 'Entry', id: number, createdAt: number, postedBy: { __typename?: 'User', login: string, html_url: string } } | null }; `); - await validate(content, config, gitHuntSchema); + await validate(content); }); it('Should produce valid output with preResolveTypes=true and enums', async () => { @@ -2561,8 +2551,8 @@ export type Q2Query = { search: Array< outputFile: '', }); - const o = await validate(content, config, testSchema); - expect(o).toContain(`export enum Information_EntryType {`); + const o = await validate(content); + // expect(o).toContain(`export type Information_EntryType =\n | 'NAME'\n | 'ADDRESS';`); FIXME: eddeee888 this must be generated because enum is used in a Result field expect(o).toContain(`__typename?: 'Information_Entry', id: Information_EntryType,`); }); @@ -2609,12 +2599,11 @@ export type Q2Query = { search: Array< outputFile: '', }); - const o = await validate(content, config, testSchema); + const o = await validate(content); expect(o).toBeSimilarStringTo(` export type ITestQueryVariables = Exact<{ e: Information_EntryType; }>;`); - expect(o).toContain(`export type IQuery = {`); - expect(o).toContain(`export enum Information_EntryType {`); + expect(o).toContain(`export type Information_EntryType =\n | 'NAME'\n | 'ADDRESS';`); expect(o).toContain(`__typename?: 'Information_Entry', id: Information_EntryType,`); }); @@ -2661,12 +2650,11 @@ export type Q2Query = { search: Array< outputFile: '', }); - const o = await validate(content, config, testSchema); + const o = await validate(content); expect(o).toBeSimilarStringTo(` export type TestQueryVariablesI = Exact<{ e: Information_EntryType; }>;`); - expect(o).toContain(`export type QueryI = {`); - expect(o).toContain(`export enum Information_EntryType {`); + expect(o).toContain(`export type Information_EntryType =\n | 'NAME'\n | 'ADDRESS';`); expect(o).toContain(`__typename?: 'Information_Entry', id: Information_EntryType,`); }); @@ -2684,7 +2672,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type DummyQuery = Pick; `); - await validate(content, config); + await validate(content); }); it('Should build a basic selection set based on basic query with field aliasing for basic scalar', async () => { @@ -2704,10 +2692,10 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type DummyQuery = ( { customName: Query['dummy'] } - & { customName2?: Maybe> } + & { customName2: Maybe> } ); `); - await validate(content, config); + await validate(content); }); it('Should build a basic selection set based on a query with inner fields', async () => { @@ -2729,12 +2717,12 @@ export type Q2Query = { search: Array< }); expect(content).toBeSimilarStringTo(` - export type CurrentUserQuery = { me?: Maybe<( + export type CurrentUserQuery = { me: Maybe<( Pick - & { profile?: Maybe> } + & { profile: Maybe> } )> }; `); - await validate(content, config); + await validate(content); }); }); @@ -2757,10 +2745,10 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type UserFieldsFragment = ( Pick - & { profile?: Maybe> } + & { profile: Maybe> } ); `); - await validate(content, config); + await validate(content); }); }); @@ -2783,12 +2771,12 @@ export type Q2Query = { search: Array< }); expect(content).toBeSimilarStringTo(` - export type LoginMutation = { login?: Maybe<( + export type LoginMutation = { login: Maybe<( Pick - & { profile?: Maybe> } + & { profile: Maybe> } )> }; `); - await validate(content, config); + await validate(content); }); it('Should detect Query correctly', async () => { @@ -2805,7 +2793,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type TestQuery = Pick; `); - await validate(content, config); + await validate(content); }); it('Should detect Subscription correctly', async () => { @@ -2822,9 +2810,9 @@ export type Q2Query = { search: Array< }); expect(content).toBeSimilarStringTo(` - export type TestSubscription = { userCreated?: Maybe> }; + export type TestSubscription = { userCreated: Maybe> }; `); - await validate(content, config); + await validate(content); }); it('Should handle operation variables correctly', async () => { @@ -2859,7 +2847,7 @@ export type Q2Query = { search: Array< innerRequired: Array | string; }>;`) ); - await validate(content, config, schema); + await validate(content); }); it('Should handle operation variables correctly when they use custom scalars', async () => { @@ -2878,7 +2866,7 @@ export type Q2Query = { search: Array< test?: any | null; }>;` ); - await validate(content, config); + await validate(content); }); it('Should create empty variables when there are no operation variables', async () => { @@ -2893,7 +2881,7 @@ export type Q2Query = { search: Array< }); expect(content).toBeSimilarStringTo(`export type TestQueryQueryVariables = Exact<{ [key: string]: never; }>;`); - await validate(content, config); + await validate(content); }); it('avoid duplicates - each type name should be unique', async () => { @@ -3021,7 +3009,7 @@ export type Q2Query = { search: Array< { __typename?: '__Schema' } & { queryType: ( { __typename?: '__Type' } - & { fields?: Maybe )>> } @@ -3066,10 +3054,10 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type InfoQuery = ( { __typename?: 'Query' } - & { __type?: Maybe<( + & { __type: Maybe<( { __typename?: '__Type' } & Pick<__Type, 'name'> - & { fields?: Maybe & { type: ( @@ -3193,7 +3181,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type PREFIX_UsersQuery = ( { __typename?: 'Query' } - & { users?: Maybe )>>> } @@ -3432,7 +3420,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type SomethingQuery = ( { __typename?: 'Query' } - & { node?: Maybe<( + & { node: Maybe<( { __typename?: 'A' } & Pick ) | ( @@ -3502,7 +3490,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type UserQuery = ( { __typename?: 'Query' } - & { user?: Maybe<( + & { user: Maybe<( { __typename?: 'User' } & Pick ) | ( @@ -3511,7 +3499,7 @@ export type Q2Query = { search: Array< ) | ( { __typename?: 'Error3' } & Pick - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } @@ -3595,7 +3583,7 @@ export type Q2Query = { search: Array< expect(content).toBeSimilarStringTo(` export type UserQuery = ( { __typename?: 'Query' } - & { user?: Maybe<( + & { user: Maybe<( { __typename?: 'User' } & Pick ) | ( @@ -3604,7 +3592,7 @@ export type Q2Query = { search: Array< ) | ( { __typename?: 'Error3' } & Pick - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } @@ -3648,7 +3636,7 @@ export type Q2Query = { search: Array< } ); - const o = await validate(content, {}, testSchema); + const o = await validate(content); expect(o).toBeSimilarStringTo(` export type UserQueryQuery = ( @@ -3698,7 +3686,7 @@ export type Q2Query = { search: Array< } ); - const o = await validate(content, {}, testSchema); + const o = await validate(content); expect(o).toBeSimilarStringTo(` export type UserQueryQuery = ( @@ -3799,8 +3787,6 @@ export type Q2Query = { search: Array< const output = await validate( content, - {}, - testSchema, ` function t(q: UserQueryQuery) { if (q.user) { @@ -3834,7 +3820,7 @@ export type Q2Query = { search: Array< ) | ( { __typename?: 'Error3' } & Pick - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } @@ -3856,7 +3842,7 @@ export type Q2Query = { search: Array< type UserResult1_Error3_Fragment = ( { __typename?: 'Error3' } - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } @@ -3963,8 +3949,6 @@ export type Q2Query = { search: Array< const output = await validate( content, - config, - testSchema, ` function t(q: UserQueryQuery) { if (q.user) { @@ -3998,7 +3982,7 @@ export type Q2Query = { search: Array< ) | ( { __typename?: 'Error3' } & Pick - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } @@ -4066,57 +4050,21 @@ export type Q2Query = { search: Array< outputFile: 'graphql.ts', }); - const output = await validate(content, config, testSchema); + const output = await validate(content); expect(mergeOutputs([output])).toMatchSnapshot(); expect(output).toBeSimilarStringTo(` - export type Maybe = T | null; - export type InputMaybe = Maybe; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; - export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; - /** All built-in and custom scalars, mapped to their actual values */ - export type Scalars = { - ID: { input: string; output: string; } - String: { input: string; output: string; } - Boolean: { input: boolean; output: boolean; } - Int: { input: number; output: number; } - Float: { input: number; output: number; } - }; - - export type Query = { - __typename?: 'Query'; - search?: Maybe>; - }; - - export type Concept = { - id?: Maybe; - }; - - export type Dimension = Concept & { - __typename?: 'Dimension'; - id?: Maybe; - }; - - export type DimValue = { - __typename?: 'DimValue'; - dimension?: Maybe; - value: Scalars['String']['output']; - }; - - export type Searchable = Dimension | DimValue; export type SearchPopularQueryVariables = Exact<{ [key: string]: never; }>; export type SearchPopularQuery = ( { __typename?: 'Query' } - & { search?: Maybe ) | ( { __typename?: 'DimValue' } & Pick - & { dimension?: Maybe<( + & { dimension: Maybe<( { __typename?: 'Dimension' } & Pick )> } @@ -4176,38 +4124,14 @@ export type Q2Query = { search: Array< } ); - const output = await validate(content, config, testSchema); + const output = await validate(content); expect(output).toBeSimilarStringTo(` - export type Maybe = T | null; - export type InputMaybe = Maybe; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; - export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; - /** All built-in and custom scalars, mapped to their actual values */ - export type Scalars = { - ID: { input: string; output: string; } - String: { input: string; output: string; } - Boolean: { input: boolean; output: boolean; } - Int: { input: number; output: number; } - Float: { input: number; output: number; } - }; - - export type Query = { - __typename?: 'Query'; - search?: Maybe>; - }; - - export type Dimension = { - __typename?: 'Dimension'; - id?: Maybe; - }; - export type SearchableFragmentFragment = { __typename?: 'Dimension', id?: string | null }; + export type SearchableFragmentFragment = { __typename?: 'Dimension', id: string | null }; export type SearchPopularQueryVariables = Exact<{ [key: string]: never; }>; - export type SearchPopularQuery = { __typename?: 'Query', search?: Array<{ __typename?: 'Dimension', id?: string | null }> | null };`); + export type SearchPopularQuery = { __typename?: 'Query', search: Array<{ __typename?: 'Dimension', id: string | null }> | null };`); }); it('Drops fragments with flattenGeneratedTypes', async () => { @@ -4263,37 +4187,12 @@ export type Q2Query = { search: Array< } ); - const output = await validate(content, config, testSchema); + const output = await validate(content); expect(output).toBeSimilarStringTo(` - export type Maybe = T | null; - export type InputMaybe = Maybe; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; - export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; - /** All built-in and custom scalars, mapped to their actual values */ - export type Scalars = { - ID: { input: string; output: string; } - String: { input: string; output: string; } - Boolean: { input: boolean; output: boolean; } - Int: { input: number; output: number; } - Float: { input: number; output: number; } - }; - - export type Query = { - __typename?: 'Query'; - search?: Maybe>; - }; - - export type Dimension = { - __typename?: 'Dimension'; - id?: Maybe; - }; - export type SearchPopularQueryVariables = Exact<{ [key: string]: never; }>; - export type SearchPopularQuery = { __typename?: 'Query', search?: Array<{ __typename?: 'Dimension', id?: string | null }> | null };`); + export type SearchPopularQuery = { __typename?: 'Query', search: Array<{ __typename?: 'Dimension', id: string | null }> | null };`); }); it('Should add operation name when addOperationExport is true', async () => { @@ -4447,8 +4346,6 @@ export type Q2Query = { search: Array< const output = await validate( content, - config, - testSchema, ` function t(q: UserQueryQuery) { if (q.user) { @@ -4482,7 +4379,7 @@ export type Q2Query = { search: Array< ) | ( { __typename?: 'Error3' } & Pick - & { info?: Maybe<( + & { info: Maybe<( { __typename?: 'AdditionalInfo' } & Pick )> } @@ -4545,8 +4442,6 @@ export type Q2Query = { search: Array< await validate( content, - {}, - testSchema, ` function test (t: TestQuery) { for (const item of t.obj!.items) { @@ -4629,7 +4524,7 @@ export type Q2Query = { search: Array< outputFile: 'graphql.ts', } ); - expect(content).toContain(`{ foo?: Maybe<{ __typename?: 'C' }> }`); + expect(content).toContain(`{ foo: Maybe<{ __typename?: 'C' }> }`); }); it('#5001 - incorrect output with typeSuffix', async () => { @@ -4734,8 +4629,6 @@ export type Q2Query = { search: Array< const result = await validate( content, - {}, - testSchema, `function test(q: QQuery) { if (q.hotel) { const t1 = q.hotel.gpsPosition.lat @@ -4924,8 +4817,6 @@ export type Q2Query = { search: Array< await validate( content, - {}, - testSchema, ` function test(q: GetEntityBrandDataQuery): void { const typeName: 'Company' | 'Theater' | 'User' | 'Movie' = q.node.__typename; // just to check that those are the types we want here @@ -5511,7 +5402,7 @@ function test(q: GetEntityBrandDataQuery): void { requireString: Array | string; innerRequired: Array | string; }>;`); - await validate(content, config); + await validate(content); }); it('#5352 - Prevent array input coercion if arrayInputCoercion = false', async () => { @@ -5543,7 +5434,7 @@ function test(q: GetEntityBrandDataQuery): void { requireString: Array; innerRequired: Array; }>;`); - await validate(content, config); + await validate(content); }); it('#5263 - inline fragment spread on interface field results in incorrect types', async () => { @@ -5923,11 +5814,11 @@ function test(q: GetEntityBrandDataQuery): void { ) }; - type PeopleInfo_Character_Fragment = { __typename?: 'Character', name?: string | null } & { ' $fragmentName'?: 'PeopleInfo_Character_Fragment' }; + type PeopleInfo_Character_Fragment = { __typename?: 'Character', name: string | null } & { ' $fragmentName'?: 'PeopleInfo_Character_Fragment' }; - type PeopleInfo_Jedi_Fragment = { __typename?: 'Jedi', side?: string | null } & { ' $fragmentName'?: 'PeopleInfo_Jedi_Fragment' }; + type PeopleInfo_Jedi_Fragment = { __typename?: 'Jedi', side: string | null } & { ' $fragmentName'?: 'PeopleInfo_Jedi_Fragment' }; - type PeopleInfo_Droid_Fragment = { __typename?: 'Droid', model?: string | null } & { ' $fragmentName'?: 'PeopleInfo_Droid_Fragment' }; + type PeopleInfo_Droid_Fragment = { __typename?: 'Droid', model: string | null } & { ' $fragmentName'?: 'PeopleInfo_Droid_Fragment' }; export type PeopleInfoFragment = | PeopleInfo_Character_Fragment @@ -6267,55 +6158,7 @@ function test(q: GetEntityBrandDataQuery): void { );`); }); - it('On avoidOptionals:true, fields with @skip, @include should make container resolve into MakeMaybe type', async () => { - const schema = buildSchema(/* GraphQL */ ` - type Query { - user(id: ID!): User! - } - - type User { - id: ID! - username: String! - email: String! - } - `); - - const fragment = parse(/* GraphQL */ ` - query user { - user(id: 1) { - id - username - email @skip(if: true) - } - } - `); - - const { content } = await plugin( - schema, - [{ location: '', document: fragment }], - { - avoidOptionals: true, - preResolveTypes: false, - }, - { - outputFile: 'graphql.ts', - } - ); - - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ [key: string]: never; }>; - - export type UserQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & MakeMaybe, 'email'> - ) } - ); - `); - }); - - it('Should handle "preResolveTypes" and "avoidOptionals" together', async () => { + it('Should handle "preResolveTypes" ', async () => { const schema = buildSchema(/* GraphQL */ ` type Query { user(id: ID!): User! @@ -6336,7 +6179,7 @@ function test(q: GetEntityBrandDataQuery): void { } } `); - const config = { avoidOptionals: true, preResolveTypes: true }; + const config = { preResolveTypes: true }; const { content } = await plugin(schema, [{ location: '', document: operations }], config, { outputFile: 'graphql.ts', }); @@ -6346,7 +6189,7 @@ function test(q: GetEntityBrandDataQuery): void { ); }); - it('On avoidOptionals:true, optionals (?) on types should be avoided', async () => { + it('optionals (?) on types should be avoided by default', async () => { const schema = buildSchema(/* GraphQL */ ` type Query { me: User! @@ -6375,7 +6218,6 @@ function test(q: GetEntityBrandDataQuery): void { schema, [{ location: '', document: fragment }], { - avoidOptionals: true, nonOptionalTypename: true, preResolveTypes: false, }, @@ -6398,7 +6240,7 @@ function test(q: GetEntityBrandDataQuery): void { `); }); - it('inline fragment with conditional directives and avoidOptionals', async () => { + it('inline fragment with conditional directives', async () => { const schema = buildSchema(/* GraphQL */ ` type Query { user: User @@ -6430,7 +6272,7 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { preResolveTypes: true, avoidOptionals: true }, + { preResolveTypes: true }, { outputFile: 'graphql.ts', } @@ -6450,7 +6292,7 @@ function test(q: GetEntityBrandDataQuery): void { };`); }); - it('resolve optionals according to maybeValue together with avoidOptionals and conditional directives', async () => { + it('resolve optionals according to maybeValue and conditional directives', async () => { const schema = buildSchema(/* GraphQL */ ` type Query { user: User! @@ -6483,7 +6325,6 @@ function test(q: GetEntityBrandDataQuery): void { { preResolveTypes: true, maybeValue: "T | 'specialType'", - avoidOptionals: true, }, { outputFile: 'graphql.ts', @@ -6494,7 +6335,7 @@ function test(q: GetEntityBrandDataQuery): void { `); }); - it('inline fragment with conditional directives and avoidOptionals, without preResolveTypes', async () => { + it('inline fragment with conditional directives, without preResolveTypes', async () => { const schema = buildSchema(/* GraphQL */ ` type Query { user: User @@ -6526,7 +6367,7 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { preResolveTypes: false, avoidOptionals: true }, + { preResolveTypes: false }, { outputFile: 'graphql.ts', } @@ -6797,7 +6638,7 @@ function test(q: GetEntityBrandDataQuery): void { `); }); - it('should generate an union of initial and deferred fields for fragments MakeEmpty (avoidOptionals: true)', async () => { + it('should generate an union of initial and deferred fields for fragments MakeEmpty', async () => { const schema = buildSchema(` type Address { street1: String! @@ -6873,7 +6714,6 @@ function test(q: GetEntityBrandDataQuery): void { schema, [{ location: '', document: fragment }], { - avoidOptionals: true, preResolveTypes: false, }, { outputFile: 'graphql.ts' } @@ -6936,7 +6776,7 @@ function test(q: GetEntityBrandDataQuery): void { `); }); - it('should support "preResolveTypes: true" and "avoidOptionals: true" together', async () => { + it('should support "preResolveTypes: true"', async () => { const schema = buildSchema(` type Address { street1: String! @@ -7010,7 +6850,6 @@ function test(q: GetEntityBrandDataQuery): void { schema, [{ location: '', document: fragment }], { - avoidOptionals: true, preResolveTypes: true, }, { outputFile: 'graphql.ts' } @@ -7036,7 +6875,7 @@ function test(q: GetEntityBrandDataQuery): void { `); }); - it('should resolve optionals according to maybeValue together with avoidOptionals and deferred fragments', async () => { + it('should resolve optionals according to maybeValue together with deferred fragments', async () => { const schema = buildSchema(` type Address { street1: String @@ -7114,7 +6953,6 @@ function test(q: GetEntityBrandDataQuery): void { { preResolveTypes: true, maybeValue: "T | 'specialType'", - avoidOptionals: true, }, { outputFile: 'graphql.ts' } ); @@ -7310,7 +7148,7 @@ function test(q: GetEntityBrandDataQuery): void { export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( + export type Unnamed_1_Query = { __typename?: 'Query', me: ( { __typename?: 'User' } & UserFragmentFragment ) | null }; @@ -7340,7 +7178,7 @@ function test(q: GetEntityBrandDataQuery): void { export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type Unnamed_1_Query = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; export type UserFragmentFragment = { __typename?: 'User', id: string }; `); @@ -7367,7 +7205,7 @@ function test(q: GetEntityBrandDataQuery): void { export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( + export type Unnamed_1_Query = { __typename?: 'Query', me: ( { __typename?: 'User' } & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } } ) | null }; diff --git a/packages/plugins/typescript/operations/tests/ts-documents.standalone.enum.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.standalone.enum.spec.ts index 4ed7a7f371c..5bea74e94db 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.standalone.enum.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.enum.spec.ts @@ -40,7 +40,7 @@ describe('TypeScript Operations Plugin - Enum', () => { export type MeQueryVariables = Exact<{ [key: string]: never; }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -92,7 +92,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -149,7 +149,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -206,7 +206,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -256,7 +256,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -326,7 +326,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -398,7 +398,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -463,7 +463,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -523,7 +523,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -578,7 +578,7 @@ describe('TypeScript Operations Plugin - Enum', () => { export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type Unnamed_1_Query = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -639,7 +639,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -700,7 +700,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -768,7 +768,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -836,7 +836,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -891,7 +891,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -944,7 +944,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -995,7 +995,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type IMeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type IMeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -1046,7 +1046,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type IMeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type IMeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -1097,7 +1097,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQueryZ = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQueryZ = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -1148,7 +1148,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQueryZ = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQueryZ = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -1209,7 +1209,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type mequery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type mequery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -1272,7 +1272,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -1330,7 +1330,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); @@ -1392,7 +1392,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type IMeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type IMeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); }); @@ -1443,7 +1443,7 @@ describe('TypeScript Operations Plugin - Enum', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); }); @@ -1493,7 +1493,7 @@ describe('TypeScript Operations Plugin - Enum `%future added value`', () => { }>; - export type MeQuery = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null }; + export type MeQuery = { __typename?: 'Query', me: { __typename?: 'User', id: string } | null }; " `); diff --git a/packages/plugins/typescript/operations/tests/ts-documents.standalone.import-types.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.standalone.import-types.spec.ts index de0af9bda02..54ed0cdf2a0 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.standalone.import-types.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.import-types.spec.ts @@ -112,7 +112,7 @@ describe('TypeScript Operations Plugin - Import Types', () => { }>; - export type UserQuery = { __typename?: 'Query', user?: { __typename?: 'User', id: string, name: string, role: TypeImport.UserRole, createdAt: any } | null }; + export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', id: string, name: string, role: TypeImport.UserRole, createdAt: any } | null }; export type UsersQueryVariables = Exact<{ input: TypeImport.UsersInput; @@ -247,7 +247,7 @@ describe('TypeScript Operations Plugin - Import Types', () => { }>; - export type UserQuery = { __typename?: 'Query', user?: { __typename?: 'User', id: string, name: string, role: TypeImport.UserRole, createdAt: any } | null }; + export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', id: string, name: string, role: TypeImport.UserRole, createdAt: any } | null }; export type UsersQueryVariables = Exact<{ input: TypeImport.UsersInput; @@ -365,7 +365,7 @@ describe('TypeScript Operations Plugin - Import Types', () => { }>; - export type UserQuery = { __typename?: 'Query', user?: { __typename?: 'User', id: string, name: string, isOld: boolean, ageInt: number, ageFloat: number } | null }; + export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', id: string, name: string, isOld: boolean, ageInt: number, ageFloat: number } | null }; " `); diff --git a/packages/plugins/typescript/operations/tests/ts-documents.standalone.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.standalone.spec.ts index e466993c245..f00eda06700 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.standalone.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.spec.ts @@ -27,6 +27,7 @@ describe('TypeScript Operations Plugin - Standalone', () => { name: String! role: UserRole! createdAt: DateTime! + nickname: String } "UserRole Description" @@ -60,6 +61,7 @@ describe('TypeScript Operations Plugin - Standalone', () => { name role createdAt + nickname } } @@ -107,7 +109,7 @@ describe('TypeScript Operations Plugin - Standalone', () => { }>; - export type UserQuery = { __typename?: 'Query', user?: { __typename?: 'User', id: string, name: string, role: UserRole, createdAt: any } | null }; + export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', id: string, name: string, role: UserRole, createdAt: any, nickname: string | null } | null }; export type UsersQueryVariables = Exact<{ input: UsersInput; @@ -169,7 +171,7 @@ describe('TypeScript Operations Plugin - Standalone', () => { }>; - export type UserQuery = { __typename?: 'Query', user?: { __typename?: 'User', id: string | number | boolean, name: string } | null }; + export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', id: string | number | boolean, name: string } | null }; " `); }); diff --git a/packages/presets/client/tests/client-preset.nullability.spec.ts b/packages/presets/client/tests/client-preset.nullability.spec.ts index ad1f9834dce..60f8b5740e6 100644 --- a/packages/presets/client/tests/client-preset.nullability.spec.ts +++ b/packages/presets/client/tests/client-preset.nullability.spec.ts @@ -84,15 +84,15 @@ describe('client-preset - nullability', () => { expect(formattedContent).toBeSimilarStringTo(` export type TestQuery = { __typename?: "Query"; - me?: { + me: { __typename?: "User"; field: string; fieldLevel0: string; - fieldLevel1?: string | null; + fieldLevel1: string | null; fieldBothLevels: string; list: Array; listLevel0: Array; - listLevel1?: Array | null; + listLevel1: Array | null; listBothLevels: Array; nonNullableList: Array; nonNullableListLevel0: Array; @@ -100,7 +100,7 @@ describe('client-preset - nullability', () => { nonNullableListBothLevels: Array; listWithNonNullableItem: Array; listWithNonNullableItemLevel0: Array; - listWithNonNullableItemLevel1?: Array | null; + listWithNonNullableItemLevel1: Array | null; listWithNonNullableItemBothLevels: Array; nonNullableListWithNonNullableItem: Array; nonNullableListWithNonNullableItemLevel0: Array; @@ -133,24 +133,24 @@ describe('client-preset - nullability', () => { expect(formattedContent).toBeSimilarStringTo(` export type TestQuery = { __typename?: "Query"; - me?: { + me: { __typename?: "User"; - field?: string | null; - fieldLevel0?: string | null; - fieldLevel1?: string | null; - fieldBothLevels?: string | null; - list?: Array | null; - listLevel0?: Array | null; - listLevel1?: Array | null; - listBothLevels?: Array | null; + field: string | null; + fieldLevel0: string | null; + fieldLevel1: string | null; + fieldBothLevels: string | null; + list: Array | null; + listLevel0: Array | null; + listLevel1: Array | null; + listBothLevels: Array | null; nonNullableList: Array; nonNullableListLevel0: Array; nonNullableListLevel1: Array; nonNullableListBothLevels: Array; - listWithNonNullableItem?: Array | null; - listWithNonNullableItemLevel0?: Array | null; - listWithNonNullableItemLevel1?: Array | null; - listWithNonNullableItemBothLevels?: Array | null; + listWithNonNullableItem: Array | null; + listWithNonNullableItemLevel0: Array | null; + listWithNonNullableItemLevel1: Array | null; + listWithNonNullableItemBothLevels: Array | null; nonNullableListWithNonNullableItem: Array; nonNullableListWithNonNullableItemLevel0: Array; nonNullableListWithNonNullableItemLevel1: Array; diff --git a/packages/presets/client/tests/client-preset.spec.ts b/packages/presets/client/tests/client-preset.spec.ts index 7213fc3dee0..403e58e3e4f 100644 --- a/packages/presets/client/tests/client-preset.spec.ts +++ b/packages/presets/client/tests/client-preset.spec.ts @@ -368,14 +368,14 @@ export * from "./gql";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { __typename?: 'Query', a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { __typename?: 'Query', b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { __typename?: 'Query', c: string | null } & { ' $fragmentName'?: 'CFragment' }; export const CFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"C"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Query"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"c"}}]}}]} as unknown as DocumentNode; export const ADocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"A"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode; @@ -483,14 +483,14 @@ export * from "./gql";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename: 'Query', a?: string | null }; + export type AQuery = { __typename: 'Query', a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename: 'Query', b?: string | null }; + export type BQuery = { __typename: 'Query', b: string | null }; - export type CFragment = { __typename: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { __typename: 'Query', c: string | null } & { ' $fragmentName'?: 'CFragment' }; export const CFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"C"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Query"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"c"}}]}}]} as unknown as DocumentNode; export const ADocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"A"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode; @@ -549,7 +549,7 @@ export * from "./gql";`); export type MeQueryVariables = Exact<{ [key: string]: never; }>; - export type MeQuery = { __typename?: 'Query', unmasked?: { __typename?: 'User', id: string, name: string, age: number } | null, masked?: ( + export type MeQuery = { __typename?: 'Query', unmasked: { __typename?: 'User', id: string, name: string, age: number } | null, masked: ( { __typename?: 'User', id: string } & { ' $fragmentRefs'?: { 'User_MeFragment': User_MeFragment } } ) | null }; @@ -640,7 +640,7 @@ export * from "./gql";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { __typename?: 'Query', a: string | null }; export const ADocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"a"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode;" @@ -1327,12 +1327,12 @@ export * from "./gql.js";`); export type BbbQueryVariables = Exact<{ [key: string]: never; }>; - export type BbbQuery = { __typename?: 'Query', b?: string | null }; + export type BbbQuery = { __typename?: 'Query', b: string | null }; export type AaaQueryVariables = Exact<{ [key: string]: never; }>; - export type AaaQuery = { __typename?: 'Query', a?: string | null }; + export type AaaQuery = { __typename?: 'Query', a: string | null }; export const BbbDocument = {"__meta__":{"cacheKeys":["bbb"]},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"bbb"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"b"}}]}}]} as unknown as DocumentNode; @@ -1384,14 +1384,14 @@ export * from "./gql.js";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { __typename?: 'Query', a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { __typename?: 'Query', b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { __typename?: 'Query', c: string | null } & { ' $fragmentName'?: 'CFragment' }; export const CFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"C"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Query"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"c"}}]}}]} as unknown as DocumentNode; export const ADocument = {"__meta__":{"hash":"b61b879c1eb0040bce65d70c8adfb1ae9360f52f"},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"A"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode; @@ -1444,14 +1444,14 @@ export * from "./gql.js";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { __typename?: 'Query', a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { __typename?: 'Query', b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { __typename?: 'Query', c: string | null } & { ' $fragmentName'?: 'CFragment' }; export const CFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"C"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Query"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"c"}}]}}]} as unknown as DocumentNode; export const ADocument = {"__meta__":{"hash":"b61b879c1eb0040bce65d70c8adfb1ae9360f52f"}} as unknown as DocumentNode; @@ -1504,14 +1504,14 @@ export * from "./gql.js";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { __typename?: 'Query', a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { __typename?: 'Query', b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { __typename?: 'Query', c: string | null } & { ' $fragmentName'?: 'CFragment' }; export const CFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"C"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Query"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"c"}}]}}]} as unknown as DocumentNode; export const ADocument = {"__meta__":{"custom_property_name":"b61b879c1eb0040bce65d70c8adfb1ae9360f52f"},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"A"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode; @@ -1566,12 +1566,12 @@ export * from "./gql.js";`); export type AaaQueryVariables = Exact<{ [key: string]: never; }>; - export type AaaQuery = { __typename?: 'Query', a?: string | null }; + export type AaaQuery = { __typename?: 'Query', a: string | null }; export type BbbQueryVariables = Exact<{ [key: string]: never; }>; - export type BbbQuery = { __typename?: 'Query', b?: string | null }; + export type BbbQuery = { __typename?: 'Query', b: string | null }; export const AaaDocument = {"__meta__":{"cacheKeys":["aaa"],"hash":"682f60dea844320c05fcb4fb6c4118015902c9a8"},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"aaa"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode; @@ -1624,14 +1624,14 @@ export * from "./gql.js";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { __typename?: 'Query', a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { __typename?: 'Query', b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { __typename?: 'Query', c: string | null } & { ' $fragmentName'?: 'CFragment' }; export const CFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"C"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Query"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"c"}}]}}]} as unknown as DocumentNode; export const ADocument = {"__meta__":{"hash":"7d0eedabb966107835cf307a0ebaf93b5d2cb8c30228611ffe3d27a53c211a0c"},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"A"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode; @@ -1688,14 +1688,14 @@ export * from "./gql.js";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { __typename?: 'Query', a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { __typename?: 'Query', b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { __typename?: 'Query', c: string | null } & { ' $fragmentName'?: 'CFragment' }; export const CFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"C"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Query"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"c"}}]}}]} as unknown as DocumentNode; export const ADocument = {"__meta__":{"hash":"queryA{a}"},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"A"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode; @@ -1753,14 +1753,14 @@ export * from "./gql.js";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { __typename?: 'Query', a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { __typename?: 'Query', b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { __typename?: 'Query', c: string | null } & { ' $fragmentName'?: 'CFragment' }; export const CFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"C"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Query"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"c"}}]}}]} as unknown as DocumentNode; export const ADocument = {"__meta__":{"hash":"7d0eedabb966107835cf307a0ebaf93b5d2cb8c30228611ffe3d27a53c211a0c"},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"A"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode; @@ -1818,14 +1818,14 @@ export * from "./gql.js";`); export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { __typename?: 'Query', a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { __typename?: 'Query', b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { __typename?: 'Query', c: string | null } & { ' $fragmentName'?: 'CFragment' }; export const CFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"C"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Query"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"c"}}]}}]} as unknown as DocumentNode; export const ADocument = {"__meta__":{"hash":"a82d8b22f2bf805563146dc8ad80b2eb054845441539e3a5a69d1f534bb5bc0bd4f9470053b9f61b6aa1966cfc2f67406258102e5ee3a356a5d171506f3ede50"},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"A"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"a"}}]}}]} as unknown as DocumentNode; @@ -1943,7 +1943,7 @@ export * from "./gql.js";`); export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: { __typename?: 'Foo' } & ( + export type FooQuery = { __typename?: 'Query', foo: { __typename?: 'Foo' } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) | null }; @@ -1951,16 +1951,16 @@ export * from "./gql.js";`); export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<{ __typename?: 'Foo' } & ( + export type FoosQuery = { __typename?: 'Query', foos: Array<{ __typename?: 'Foo' } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { __typename?: 'Foo', value: string | null } & { ' $fragmentName'?: 'FooFragment' }; - export type FooFragment = { __typename?: 'Foo', id?: string | null } & ({ __typename?: 'Foo', value?: string | null } | { __typename?: 'Foo', value?: never }) & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { __typename?: 'Foo', id: string | null } & ({ __typename?: 'Foo', value: string | null } | { __typename?: 'Foo', value?: never }) & { ' $fragmentName'?: 'FooFragment' }; - export type FooNestedFragment = { __typename?: 'Foo', id?: string | null } & ( + export type FooNestedFragment = { __typename?: 'Foo', id: string | null } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) & { ' $fragmentName'?: 'FooNestedFragment' }; @@ -2008,7 +2008,7 @@ export * from "./gql.js";`); export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: { __typename?: 'Foo' } & ( + export type FooQuery = { __typename?: 'Query', foo: { __typename?: 'Foo' } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) | null }; @@ -2016,16 +2016,16 @@ export * from "./gql.js";`); export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<{ __typename?: 'Foo' } & ( + export type FoosQuery = { __typename?: 'Query', foos: Array<{ __typename?: 'Foo' } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { __typename?: 'Foo', value: string | null } & { ' $fragmentName'?: 'FooFragment' }; - export type FooFragment = { __typename?: 'Foo', id?: string | null } & ({ __typename?: 'Foo', value?: string | null } | { __typename?: 'Foo', value?: never }) & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { __typename?: 'Foo', id: string | null } & ({ __typename?: 'Foo', value: string | null } | { __typename?: 'Foo', value?: never }) & { ' $fragmentName'?: 'FooFragment' }; - export type FooNestedFragment = { __typename?: 'Foo', id?: string | null } & ( + export type FooNestedFragment = { __typename?: 'Foo', id: string | null } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) & { ' $fragmentName'?: 'FooNestedFragment' }; @@ -2073,7 +2073,7 @@ export * from "./gql.js";`); export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: { __typename?: 'Foo' } & ( + export type FooQuery = { __typename?: 'Query', foo: { __typename?: 'Foo' } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) | null }; @@ -2081,16 +2081,16 @@ export * from "./gql.js";`); export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<{ __typename?: 'Foo' } & ( + export type FoosQuery = { __typename?: 'Query', foos: Array<{ __typename?: 'Foo' } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { __typename?: 'Foo', value: string | null } & { ' $fragmentName'?: 'FooFragment' }; - export type FooFragment = { __typename?: 'Foo', id?: string | null } & ({ __typename?: 'Foo', value?: string | null } | { __typename?: 'Foo', value?: never }) & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { __typename?: 'Foo', id: string | null } & ({ __typename?: 'Foo', value: string | null } | { __typename?: 'Foo', value?: never }) & { ' $fragmentName'?: 'FooFragment' }; - export type FooNestedFragment = { __typename?: 'Foo', id?: string | null } & ( + export type FooNestedFragment = { __typename?: 'Foo', id: string | null } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) & { ' $fragmentName'?: 'FooNestedFragment' }; @@ -2211,7 +2211,7 @@ export * from "./gql.js";`); export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: { __typename?: 'Foo' } & ( + export type FooQuery = { __typename?: 'Query', foo: { __typename?: 'Foo' } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) | null }; @@ -2219,16 +2219,16 @@ export * from "./gql.js";`); export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<{ __typename?: 'Foo' } & ( + export type FoosQuery = { __typename?: 'Query', foos: Array<{ __typename?: 'Foo' } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { __typename?: 'Foo', value: string | null } & { ' $fragmentName'?: 'FooFragment' }; - export type FooFragment = { __typename?: 'Foo', id?: string | null } & ({ __typename?: 'Foo', value?: string | null } | { __typename?: 'Foo', value?: never }) & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { __typename?: 'Foo', id: string | null } & ({ __typename?: 'Foo', value: string | null } | { __typename?: 'Foo', value?: never }) & { ' $fragmentName'?: 'FooFragment' }; - export type FooNestedFragment = { __typename?: 'Foo', id?: string | null } & ( + export type FooNestedFragment = { __typename?: 'Foo', id: string | null } & ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } ) & { ' $fragmentName'?: 'FooNestedFragment' }; @@ -2347,7 +2347,7 @@ export * from "./gql.js";`); export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: ( + export type FooQuery = { __typename?: 'Query', foo: ( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': FooFragment } } ) | null }; @@ -2355,12 +2355,12 @@ export * from "./gql.js";`); export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<( + export type FoosQuery = { __typename?: 'Query', foos: Array<( { __typename?: 'Foo' } & { ' $fragmentRefs'?: { 'FooFragment': FooFragment } } ) | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { __typename?: 'Foo', value: string | null } & { ' $fragmentName'?: 'FooFragment' }; export class TypedDocumentString extends String @@ -2696,7 +2696,7 @@ export * from "./gql.js";`); export type Test_UserQueryVariables = Exact<{ [key: string]: never; }>; - export type Test_UserQuery = { readonly __typename?: 'Query', readonly user?: { readonly __typename?: 'User', readonly id: string, readonly name: string } | null }; + export type Test_UserQuery = { readonly __typename?: 'Query', readonly user: { readonly __typename?: 'User', readonly id: string, readonly name: string } | null }; export const Test_UserDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Test_User"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"StringValue","value":"user-001","block":false}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode;"