diff --git a/.changeset/flat-paths-boil.md b/.changeset/flat-paths-boil.md new file mode 100644 index 00000000000..7a02df893a0 --- /dev/null +++ b/.changeset/flat-paths-boil.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/typescript-operations': patch +--- + +Add internal utility type warning to deter usage diff --git a/dev-test/githunt/typed-document-nodes.ts b/dev-test/githunt/typed-document-nodes.ts index e8890d5c984..19b215bdd2d 100644 --- a/dev-test/githunt/typed-document-nodes.ts +++ b/dev-test/githunt/typed-document-nodes.ts @@ -1,6 +1,8 @@ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; /** A list of options for the sort order of the feed */ export type FeedType = /** Sort by a combination of freshness and score, using Reddit's algorithm */ diff --git a/dev-test/githunt/types.avoidOptionals.ts b/dev-test/githunt/types.avoidOptionals.ts index 347e74b06e4..1538e6ed2cb 100644 --- a/dev-test/githunt/types.avoidOptionals.ts +++ b/dev-test/githunt/types.avoidOptionals.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** A list of options for the sort order of the feed */ export type FeedType = diff --git a/dev-test/githunt/types.d.ts b/dev-test/githunt/types.d.ts index ff53ee817e9..3975b48c626 100644 --- a/dev-test/githunt/types.d.ts +++ b/dev-test/githunt/types.d.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** A list of options for the sort order of the feed */ export type FeedType = diff --git a/dev-test/githunt/types.enumsAsTypes.ts b/dev-test/githunt/types.enumsAsTypes.ts index ff53ee817e9..3975b48c626 100644 --- a/dev-test/githunt/types.enumsAsTypes.ts +++ b/dev-test/githunt/types.enumsAsTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** A list of options for the sort order of the feed */ export type FeedType = diff --git a/dev-test/githunt/types.flatten.preResolveTypes.ts b/dev-test/githunt/types.flatten.preResolveTypes.ts index 51fdd0c0f66..169e0987f10 100644 --- a/dev-test/githunt/types.flatten.preResolveTypes.ts +++ b/dev-test/githunt/types.flatten.preResolveTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** A list of options for the sort order of the feed */ export type FeedType = diff --git a/dev-test/githunt/types.immutableTypes.ts b/dev-test/githunt/types.immutableTypes.ts index c0045668540..ed00a6e9658 100644 --- a/dev-test/githunt/types.immutableTypes.ts +++ b/dev-test/githunt/types.immutableTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** A list of options for the sort order of the feed */ export type FeedType = diff --git a/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts b/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts index ff53ee817e9..3975b48c626 100644 --- a/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts +++ b/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** A list of options for the sort order of the feed */ export type FeedType = diff --git a/dev-test/githunt/types.preResolveTypes.ts b/dev-test/githunt/types.preResolveTypes.ts index ff53ee817e9..3975b48c626 100644 --- a/dev-test/githunt/types.preResolveTypes.ts +++ b/dev-test/githunt/types.preResolveTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** A list of options for the sort order of the feed */ export type FeedType = diff --git a/dev-test/githunt/types.ts b/dev-test/githunt/types.ts index ff53ee817e9..3975b48c626 100644 --- a/dev-test/githunt/types.ts +++ b/dev-test/githunt/types.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** A list of options for the sort order of the feed */ export type FeedType = diff --git a/dev-test/gql-tag-operations-masking/gql/graphql.ts b/dev-test/gql-tag-operations-masking/gql/graphql.ts index f46c9c6e7b7..4870bf1b579 100644 --- a/dev-test/gql-tag-operations-masking/gql/graphql.ts +++ b/dev-test/gql-tag-operations-masking/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type TweetFragmentFragment = ({ id: string; body: string } & { ' $fragmentRefs'?: { TweetAuthorFragmentFragment: TweetAuthorFragmentFragment }; }) & { ' $fragmentName'?: 'TweetFragmentFragment' }; diff --git a/dev-test/gql-tag-operations-urql/gql/graphql.ts b/dev-test/gql-tag-operations-urql/gql/graphql.ts index addcd45db1c..cc702e2d7db 100644 --- a/dev-test/gql-tag-operations-urql/gql/graphql.ts +++ b/dev-test/gql-tag-operations-urql/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type FooQueryVariables = Exact<{ [key: string]: never }>; export type FooQuery = { Tweets: Array<{ id: string } | null> | null }; diff --git a/dev-test/gql-tag-operations/gql/graphql.ts b/dev-test/gql-tag-operations/gql/graphql.ts index d348f12708c..7285c9e02e0 100644 --- a/dev-test/gql-tag-operations/gql/graphql.ts +++ b/dev-test/gql-tag-operations/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type FooQueryVariables = Exact<{ [key: string]: never }>; export type FooQuery = { Tweets: Array<{ id: string } | null> | null }; diff --git a/dev-test/gql-tag-operations/graphql/graphql.ts b/dev-test/gql-tag-operations/graphql/graphql.ts index d348f12708c..7285c9e02e0 100644 --- a/dev-test/gql-tag-operations/graphql/graphql.ts +++ b/dev-test/gql-tag-operations/graphql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type FooQueryVariables = Exact<{ [key: string]: never }>; export type FooQuery = { Tweets: Array<{ id: string } | null> | null }; 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 6a222027557..c476e82f0fa 100644 --- a/dev-test/standalone-operations/import-schema-types/_types.generated.ts +++ b/dev-test/standalone-operations/import-schema-types/_types.generated.ts @@ -1,7 +1,9 @@ -import type * as Types from './_base.generated.js'; - +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import type * as Types from './_base.generated.js'; + export type WithVariablesQueryVariables = Exact<{ role?: Types.UserRole | null | undefined; }>; diff --git a/dev-test/standalone-operations/with-typescript-plugin/_types.generated.ts b/dev-test/standalone-operations/with-typescript-plugin/_types.generated.ts index 6a222027557..c476e82f0fa 100644 --- a/dev-test/standalone-operations/with-typescript-plugin/_types.generated.ts +++ b/dev-test/standalone-operations/with-typescript-plugin/_types.generated.ts @@ -1,7 +1,9 @@ -import type * as Types from './_base.generated.js'; - +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import type * as Types from './_base.generated.js'; + export type WithVariablesQueryVariables = Exact<{ role?: Types.UserRole | null | undefined; }>; diff --git a/dev-test/star-wars/types.avoidOptionals.ts b/dev-test/star-wars/types.avoidOptionals.ts index 868f540cb5b..3d59362489b 100644 --- a/dev-test/star-wars/types.avoidOptionals.ts +++ b/dev-test/star-wars/types.avoidOptionals.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The input object sent when passing a color */ export type ColorInput = { diff --git a/dev-test/star-wars/types.d.ts b/dev-test/star-wars/types.d.ts index ef961c94a56..19cb3bf4b88 100644 --- a/dev-test/star-wars/types.d.ts +++ b/dev-test/star-wars/types.d.ts @@ -1 +1,2 @@ +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; diff --git a/dev-test/star-wars/types.excludeQueryAlpha.ts b/dev-test/star-wars/types.excludeQueryAlpha.ts index 4c5b5b46ab5..e73cc525ed9 100644 --- a/dev-test/star-wars/types.excludeQueryAlpha.ts +++ b/dev-test/star-wars/types.excludeQueryAlpha.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The input object sent when passing a color */ export type ColorInput = { diff --git a/dev-test/star-wars/types.excludeQueryBeta.ts b/dev-test/star-wars/types.excludeQueryBeta.ts index 70ea7127823..63f51e46d04 100644 --- a/dev-test/star-wars/types.excludeQueryBeta.ts +++ b/dev-test/star-wars/types.excludeQueryBeta.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The input object sent when passing a color */ export type ColorInput = { diff --git a/dev-test/star-wars/types.globallyAvailable.d.ts b/dev-test/star-wars/types.globallyAvailable.d.ts index 1d16e9f6348..a023b0cf980 100644 --- a/dev-test/star-wars/types.globallyAvailable.d.ts +++ b/dev-test/star-wars/types.globallyAvailable.d.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The input object sent when passing a color */ type ColorInput = { diff --git a/dev-test/star-wars/types.immutableTypes.ts b/dev-test/star-wars/types.immutableTypes.ts index 934430e5890..4b787fcfb7b 100644 --- a/dev-test/star-wars/types.immutableTypes.ts +++ b/dev-test/star-wars/types.immutableTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The input object sent when passing a color */ export type ColorInput = { diff --git a/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts b/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts index 8e3468b77a4..e04ca9d9bc0 100644 --- a/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts +++ b/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The input object sent when passing a color */ export type ColorInput = { diff --git a/dev-test/star-wars/types.preResolveTypes.ts b/dev-test/star-wars/types.preResolveTypes.ts index 8e3468b77a4..e04ca9d9bc0 100644 --- a/dev-test/star-wars/types.preResolveTypes.ts +++ b/dev-test/star-wars/types.preResolveTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The input object sent when passing a color */ export type ColorInput = { diff --git a/dev-test/star-wars/types.skipSchema.ts b/dev-test/star-wars/types.skipSchema.ts index 8e3468b77a4..e04ca9d9bc0 100644 --- a/dev-test/star-wars/types.skipSchema.ts +++ b/dev-test/star-wars/types.skipSchema.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The input object sent when passing a color */ export type ColorInput = { diff --git a/dev-test/star-wars/types.ts b/dev-test/star-wars/types.ts index 8e3468b77a4..e04ca9d9bc0 100644 --- a/dev-test/star-wars/types.ts +++ b/dev-test/star-wars/types.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The input object sent when passing a color */ export type ColorInput = { diff --git a/dev-test/test-null-value/result.d.ts b/dev-test/test-null-value/result.d.ts index 43b53927040..24b59bef557 100644 --- a/dev-test/test-null-value/result.d.ts +++ b/dev-test/test-null-value/result.d.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type CartLineFragment = { id: string; quantity: number }; diff --git a/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts b/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts index 7dfb7db5c1d..06fce5250be 100644 --- a/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts +++ b/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type TestQueryVariables = Exact<{ [key: string]: never }>; diff --git a/dev-test/test-schema/types.preResolveTypes.ts b/dev-test/test-schema/types.preResolveTypes.ts index 7dfb7db5c1d..06fce5250be 100644 --- a/dev-test/test-schema/types.preResolveTypes.ts +++ b/dev-test/test-schema/types.preResolveTypes.ts @@ -1,4 +1,6 @@ +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type TestQueryVariables = Exact<{ [key: string]: never }>; diff --git a/examples/persisted-documents-string-mode/src/gql/graphql.ts b/examples/persisted-documents-string-mode/src/gql/graphql.ts index 77380d6a05b..a87e683d86b 100644 --- a/examples/persisted-documents-string-mode/src/gql/graphql.ts +++ b/examples/persisted-documents-string-mode/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; export type HelloQueryQueryVariables = Exact<{ [key: string]: never }>; export type HelloQueryQuery = { hello: string }; diff --git a/examples/persisted-documents/src/gql/graphql.ts b/examples/persisted-documents/src/gql/graphql.ts index 6ac5d575fab..2d433c8d320 100644 --- a/examples/persisted-documents/src/gql/graphql.ts +++ b/examples/persisted-documents/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type HelloQueryQueryVariables = Exact<{ [key: string]: never }>; export type HelloQueryQuery = { hello: string }; diff --git a/examples/react/apollo-client-defer/src/gql/graphql.ts b/examples/react/apollo-client-defer/src/gql/graphql.ts index 6c071d96aef..5e1f745c3d0 100644 --- a/examples/react/apollo-client-defer/src/gql/graphql.ts +++ b/examples/react/apollo-client-defer/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type SlowFieldFragmentFragment = { slowField: string } & { ' $fragmentName'?: 'SlowFieldFragmentFragment' }; export type SlowAndFastFieldWithDeferQueryVariables = Exact<{ [key: string]: never }>; diff --git a/examples/react/apollo-client/src/gql/graphql.ts b/examples/react/apollo-client/src/gql/graphql.ts index 18d55b9577d..717040c48e7 100644 --- a/examples/react/apollo-client/src/gql/graphql.ts +++ b/examples/react/apollo-client/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ first: number; }>; diff --git a/examples/react/http-executor/src/gql/graphql.ts b/examples/react/http-executor/src/gql/graphql.ts index da59e757081..7b71170ebb8 100644 --- a/examples/react/http-executor/src/gql/graphql.ts +++ b/examples/react/http-executor/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ first: number; }>; diff --git a/examples/react/tanstack-react-query/src/gql/graphql.ts b/examples/react/tanstack-react-query/src/gql/graphql.ts index 9fc41dafa93..097a9199bec 100644 --- a/examples/react/tanstack-react-query/src/gql/graphql.ts +++ b/examples/react/tanstack-react-query/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ first: number; }>; diff --git a/examples/react/urql/src/gql/graphql.ts b/examples/react/urql/src/gql/graphql.ts index 04123d3bd0b..8fce27b7f93 100644 --- a/examples/react/urql/src/gql/graphql.ts +++ b/examples/react/urql/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; export type AllFilmsWithVariablesQuery199QueryVariables = Exact<{ first: number; }>; diff --git a/examples/typescript-esm/src/gql/graphql.ts b/examples/typescript-esm/src/gql/graphql.ts index e99329c6584..0c81e9968fc 100644 --- a/examples/typescript-esm/src/gql/graphql.ts +++ b/examples/typescript-esm/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AllPeopleQueryQueryVariables = Exact<{ [key: string]: never }>; export type AllPeopleQueryQuery = { diff --git a/examples/typescript-graphql-request/src/gql/graphql.ts b/examples/typescript-graphql-request/src/gql/graphql.ts index 42f3b927d34..4ea18efc166 100644 --- a/examples/typescript-graphql-request/src/gql/graphql.ts +++ b/examples/typescript-graphql-request/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; export type AllPeopleQueryQueryVariables = Exact<{ [key: string]: never }>; export type AllPeopleQueryQuery = { diff --git a/examples/vite/vite-react-cts/src/gql/graphql.ts b/examples/vite/vite-react-cts/src/gql/graphql.ts index 584c493815e..48bd866e1a3 100644 --- a/examples/vite/vite-react-cts/src/gql/graphql.ts +++ b/examples/vite/vite-react-cts/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type FilmItemFragment = { id: string; title: string | null; diff --git a/examples/vite/vite-react-mts/src/gql/graphql.ts b/examples/vite/vite-react-mts/src/gql/graphql.ts index 584c493815e..48bd866e1a3 100644 --- a/examples/vite/vite-react-mts/src/gql/graphql.ts +++ b/examples/vite/vite-react-mts/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type FilmItemFragment = { id: string; title: string | null; diff --git a/examples/vite/vite-react-ts/src/gql/graphql.ts b/examples/vite/vite-react-ts/src/gql/graphql.ts index 584c493815e..48bd866e1a3 100644 --- a/examples/vite/vite-react-ts/src/gql/graphql.ts +++ b/examples/vite/vite-react-ts/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type FilmItemFragment = { id: string; title: string | null; diff --git a/examples/vue/apollo-composable/src/gql/graphql.ts b/examples/vue/apollo-composable/src/gql/graphql.ts index b58515b3392..be4fd24cd1a 100644 --- a/examples/vue/apollo-composable/src/gql/graphql.ts +++ b/examples/vue/apollo-composable/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ first: number; }>; diff --git a/examples/vue/urql/src/gql/graphql.ts b/examples/vue/urql/src/gql/graphql.ts index b58515b3392..be4fd24cd1a 100644 --- a/examples/vue/urql/src/gql/graphql.ts +++ b/examples/vue/urql/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ first: number; }>; diff --git a/examples/vue/villus/src/gql/graphql.ts b/examples/vue/villus/src/gql/graphql.ts index b58515b3392..be4fd24cd1a 100644 --- a/examples/vue/villus/src/gql/graphql.ts +++ b/examples/vue/villus/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ first: number; }>; diff --git a/examples/yoga-tests/src/gql/graphql.ts b/examples/yoga-tests/src/gql/graphql.ts index 86973327b30..b4814ea7491 100644 --- a/examples/yoga-tests/src/gql/graphql.ts +++ b/examples/yoga-tests/src/gql/graphql.ts @@ -1,7 +1,9 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +/** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; +/** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type HelloQueryQueryVariables = Exact<{ [key: string]: never }>; export type HelloQueryQuery = { hello: string }; diff --git a/packages/plugins/typescript/operations/src/visitor.ts b/packages/plugins/typescript/operations/src/visitor.ts index 45b97774130..080fbb80120 100644 --- a/packages/plugins/typescript/operations/src/visitor.ts +++ b/packages/plugins/typescript/operations/src/visitor.ts @@ -695,7 +695,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< return null; } - return 'type Exact = { [K in keyof T]: T[K] };'; + return `${internalUtilityTypeWarning}type Exact = { [K in keyof T]: T[K] };`; } getIncrementalUtilityType(): string | null { @@ -706,10 +706,12 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< // Note: `export` here is important for 2 reasons // 1. It is not always used in the rest of the file, so this is a safe way to avoid lint rules (in tsconfig or eslint) complaining it's not used in the current file. // 2. In Client Preset, it is used by fragment-masking.ts, so it needs `export` - return "export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };"; + return `${internalUtilityTypeWarning}export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };`; } } +const internalUtilityTypeWarning = '/** Internal type. DO NOT USE DIRECTLY. */\n'; + function parseOneOfInputValue({ node, schema, diff --git a/packages/plugins/typescript/operations/tests/ts-documents.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.spec.ts index b60b3f2a956..9ec9991a2e6 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.spec.ts @@ -5993,7 +5993,9 @@ function test(q: GetEntityBrandDataQuery): void { ]); expect(content).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type WidgetFragmentFragment = { widgetCount: number, widgetPreference: string } & { ' $fragmentName'?: 'WidgetFragmentFragment' }; diff --git a/packages/plugins/typescript/operations/tests/ts-documents.standalone.config.avoidOptionals.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.standalone.config.avoidOptionals.spec.ts index e4f659b2309..025f1890f67 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.standalone.config.avoidOptionals.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.config.avoidOptionals.spec.ts @@ -48,7 +48,9 @@ describe('TypeScript Operations Plugin - config.avoidOptionals', () => { const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { id: string | number; @@ -116,7 +118,9 @@ describe('TypeScript Operations Plugin - config.avoidOptionals', () => { const result = mergeOutputs([await plugin(schema, [{ document }], { avoidOptionals: true }, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { id: string | number; @@ -195,7 +199,9 @@ describe('TypeScript Operations Plugin - config.avoidOptionals', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { id: string | number; @@ -272,7 +278,9 @@ describe('TypeScript Operations Plugin - config.avoidOptionals', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { id: string | number; @@ -349,7 +357,9 @@ describe('TypeScript Operations Plugin - config.avoidOptionals', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { id: string | number; @@ -432,7 +442,9 @@ describe('TypeScript Operations Plugin - config.avoidOptionals', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { id: string | number; 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 cc0bcb97a89..ed5988f779a 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 @@ -35,7 +35,9 @@ describe('TypeScript Operations Plugin - Enum', () => { const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type MeQueryVariables = Exact<{ [key: string]: never; }>; @@ -80,7 +82,9 @@ describe('TypeScript Operations Plugin - Enum', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export enum UserRole { Admin = 0, @@ -133,7 +137,9 @@ describe('TypeScript Operations Plugin - Enum', () => { const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'const' }, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export const UserRole = { ABC: 'A_B_C', @@ -192,7 +198,9 @@ describe('TypeScript Operations Plugin - Enum', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** Multiline comment test */ export const enum UserRole { @@ -244,7 +252,9 @@ describe('TypeScript Operations Plugin - Enum', () => { const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'native' }, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export enum UserRole { Admin = 'ADMIN', @@ -313,7 +323,9 @@ describe('TypeScript Operations Plugin - Enum', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserRole = | 0 @@ -383,7 +395,9 @@ describe('TypeScript Operations Plugin - Enum', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export const UserRole = { ABC: 0, @@ -451,7 +465,9 @@ describe('TypeScript Operations Plugin - Enum', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export enum UserRole { Admin = 0, @@ -514,7 +530,9 @@ describe('TypeScript Operations Plugin - Enum', () => { expect(result).toMatchInlineSnapshot(` "import { MyEnum as UserRole } from './my-file'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export { UserRole }; @@ -573,7 +591,9 @@ describe('TypeScript Operations Plugin - Enum', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; @@ -630,7 +650,9 @@ describe('TypeScript Operations Plugin - Enum', () => { expect(result).toMatchInlineSnapshot(` "import { NS } from './my-file'; import UserRole = NS.ETest; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export { UserRole }; @@ -691,7 +713,9 @@ describe('TypeScript Operations Plugin - Enum', () => { expect(result).toMatchInlineSnapshot(` "import { NS } from './my-file'; import UserRole = NS.UserRole; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export { UserRole }; @@ -756,7 +780,9 @@ describe('TypeScript Operations Plugin - Enum', () => { expect(result).toMatchInlineSnapshot(` "import { UserRole } from './my-file'; import { UserStatus } from './my-file'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export { UserRole }; @@ -824,7 +850,9 @@ describe('TypeScript Operations Plugin - Enum', () => { expect(result).toMatchInlineSnapshot(` "import { UserRole } from './my-file'; import { UserStatus2X as UserStatus } from './my-file'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export { UserRole }; @@ -877,7 +905,9 @@ describe('TypeScript Operations Plugin - Enum', () => { const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'native' }, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export enum UserRole { ABC = 'A_B_C', @@ -931,7 +961,9 @@ describe('TypeScript Operations Plugin - Enum', () => { const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'native' }, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export enum UserRole { _ = '_', @@ -984,7 +1016,9 @@ describe('TypeScript Operations Plugin - Enum', () => { await plugin(schema, [{ document }], { typesPrefix: 'I', enumPrefix: true }, { outputFile: '' }), ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type IUserRole = | 'ADMIN' @@ -1035,7 +1069,9 @@ describe('TypeScript Operations Plugin - Enum', () => { await plugin(schema, [{ document }], { typesPrefix: 'I', enumPrefix: false }, { outputFile: '' }), ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserRole = | 'ADMIN' @@ -1086,7 +1122,9 @@ describe('TypeScript Operations Plugin - Enum', () => { await plugin(schema, [{ document }], { typesSuffix: 'Z', enumSuffix: true }, { outputFile: '' }), ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserRoleZ = | 'ADMIN' @@ -1137,7 +1175,9 @@ describe('TypeScript Operations Plugin - Enum', () => { await plugin(schema, [{ document }], { typesSuffix: 'Z', enumSuffix: false }, { outputFile: '' }), ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserRole = | 'ADMIN' @@ -1198,7 +1238,9 @@ describe('TypeScript Operations Plugin - Enum', () => { ), ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type userrole = | 'ADMIN' @@ -1260,7 +1302,9 @@ describe('TypeScript Operations Plugin - Enum', () => { ), ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export enum UserRole { admin = 'ADMIN', @@ -1319,7 +1363,9 @@ describe('TypeScript Operations Plugin - Enum', () => { ), ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; type UserRole = | 'ADMIN' @@ -1383,7 +1429,9 @@ describe('TypeScript Operations Plugin - Enum', () => { expect(result).toMatchInlineSnapshot(` "import UserRole from './files'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export { UserRole }; @@ -1430,7 +1478,9 @@ describe('TypeScript Operations Plugin - Enum', () => { const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'native' }, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export enum UserRole { Axb = 'AXB', @@ -1481,7 +1531,9 @@ describe('TypeScript Operations Plugin - Enum `%future added value`', () => { const result = mergeOutputs([await plugin(schema, [{ document }], { futureProofEnums: true }, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserRole = | 'ADMIN' 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 efd54f316a6..1519b50e31f 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 @@ -102,7 +102,9 @@ describe('TypeScript Operations Plugin - Import Types', () => { expect(result).toMatchInlineSnapshot(` "import type * as Types from './path-to-other-file.generated'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ id: string | number; @@ -234,7 +236,9 @@ describe('TypeScript Operations Plugin - Import Types', () => { expect(result).toMatchInlineSnapshot(` "import type * as Types from '@my-company/package/types'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ id: string | number; @@ -340,7 +344,9 @@ describe('TypeScript Operations Plugin - Import Types', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ id?: string | number | null | undefined; @@ -426,7 +432,9 @@ describe('TypeScript Operations Plugin - Import Types with external custom Scala expect(operationFileResult).toMatchInlineSnapshot(` "import type * as Types from './graphql-code-generator/path-to-other-file'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ input?: Types.UserInput | null | undefined; @@ -495,7 +503,9 @@ describe('TypeScript Operations Plugin - Import Types with external custom Scala ]); expect(operationFileResult).toMatchInlineSnapshot(` "import { Scalar1 } from '@org/scalars'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ scalar1?: Scalar1 | null | undefined; @@ -565,7 +575,9 @@ describe('TypeScript Operations Plugin - Import Types with external custom Scala ]); expect(operationFileResult).toMatchInlineSnapshot(` "import { Scalar1 } from '@org/scalars'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ [key: string]: never; }>; @@ -622,7 +634,9 @@ describe('TypeScript Operations Plugin - Import Types with external custom Scala expect(result).toMatchInlineSnapshot(` "import type * as TypeImport from './path-to-other-file.generated'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ id: string | number; diff --git a/packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts index fa84ec8d629..b47e3af2527 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts @@ -93,7 +93,9 @@ describe('TypeScript Operations Plugin - Input', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** UserRole Description */ export type UserRole = @@ -214,7 +216,9 @@ describe('TypeScript Operations Plugin - Input', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** UserRole Description */ export type UserRole = @@ -323,7 +327,9 @@ describe('TypeScript Operations Plugin - Input', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** UserRole Description */ export type UserRole = @@ -422,7 +428,9 @@ describe('TypeScript Operations Plugin - Input', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { dateRange1?: Array | null; diff --git a/packages/plugins/typescript/operations/tests/ts-documents.standalone.scalars.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.standalone.scalars.spec.ts index 7dc053f4d13..ea8726487aa 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.standalone.scalars.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.scalars.spec.ts @@ -66,7 +66,9 @@ describe('TypeScript Operations Plugin - Default Scalar types', () => { const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { nonNullableDate: unknown; @@ -159,7 +161,9 @@ describe('TypeScript Operations Plugin - Default Scalar types', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { nonNullableDate: any; @@ -252,7 +256,9 @@ describe('TypeScript Operations Plugin - Default Scalar types', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { nonNullableDate: Date; @@ -354,7 +360,9 @@ describe('TypeScript Operations Plugin - Custom Scalars', () => { import Scalar4 from '@org/scalars'; import { MyScalar5, MyScalar6 as AliasedScalar6 } from '@org/scalars'; import { Scalar7Output } from '@org/input-output'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ [key: string]: never; }>; @@ -428,7 +436,9 @@ describe('TypeScript Operations Plugin - Custom Scalars', () => { import Scalar4 from '@org/scalars'; import { MyScalar5, MyScalar6 as AliasedScalar6 } from '@org/scalars'; import { Scalar7Input } from '@org/input-output'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserInput = { scalar1?: Scalar1 | null | undefined; @@ -545,7 +555,9 @@ describe('TypeScript Operations Plugin - Custom Scalars', () => { import DefaultScalar8 from '@org/scalars'; import { Scalar9, Scalar10 as MyScalar10 } from '@org/scalars'; import { Scalar11 as Scalar11Input, Scalar11 as Scalar11Output, Scalar12 } from '@org/input-output'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ scalar1?: Scalar1 | null | undefined; @@ -666,7 +678,9 @@ describe('TypeScript Operations Plugin - Custom Scalars', () => { import type { default as DefaultScalar8 } from '@org/scalars'; import type { Scalar9, Scalar10 as MyScalar10 } from '@org/scalars'; import type { Scalar11 as Scalar11Input, Scalar11 as Scalar11Output, Scalar12 } from '@org/input-output'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ scalar1?: Scalar1 | null | undefined; 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 add6723dd06..5c7a5db8a65 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.standalone.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.spec.ts @@ -120,7 +120,9 @@ describe('TypeScript Operations Plugin - Standalone', () => { const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type ResponseErrorType = | 'NOT_FOUND' @@ -236,7 +238,9 @@ describe('TypeScript Operations Plugin - Standalone', () => { const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type EnumRoot = | 'ENUM_A' @@ -328,7 +332,9 @@ describe('TypeScript Operations Plugin - Standalone', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type EnumRoot = | 'ENUM_A' @@ -392,7 +398,9 @@ describe('TypeScript Operations Plugin - Standalone', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ id: string | number | boolean; @@ -443,7 +451,9 @@ describe('TypeScript Operations Plugin - Standalone', () => { const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type RoleType = | 'ROLE_A' @@ -503,7 +513,9 @@ describe('TypeScript Operations Plugin - Standalone', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type RoleType = | 'ROLE_A' @@ -794,7 +806,9 @@ describe('TypeScript Operations Plugin - Standalone', () => { ]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserQueryVariables = Exact<{ id: string | number; @@ -841,6 +855,7 @@ describe('TypeScript Operations Plugin - Standalone', () => { expect(result).toMatchInlineSnapshot(` " + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; export type UserPartFragment = { id: string, name: string }; " @@ -885,7 +900,9 @@ describe('TypeScript Operations Plugin - Standalone', () => { const result = mergeOutputs([await plugin(schema, [{ document }], { globalNamespace: true }, { outputFile: '' })]); expect(result).toMatchInlineSnapshot(` - "type Exact = { [K in keyof T]: T[K] }; + "/** Internal type. DO NOT USE DIRECTLY. */ + type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; declare global { diff --git a/packages/presets/client/tests/client-preset.enum.spec.ts b/packages/presets/client/tests/client-preset.enum.spec.ts index 8ea0aa1a047..028e5164e37 100644 --- a/packages/presets/client/tests/client-preset.enum.spec.ts +++ b/packages/presets/client/tests/client-preset.enum.spec.ts @@ -23,6 +23,7 @@ describe('client-preset - Enum', () => { const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };" `); }); @@ -69,9 +70,11 @@ describe('client-preset - Enum', () => { const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type Shape = | 'ROUND' | 'SQUARE'; @@ -131,9 +134,11 @@ describe('client-preset - Enum', () => { const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type Shape = | 'ROUND' | 'SQUARE'; @@ -188,9 +193,11 @@ describe('client-preset - Enum', () => { const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export const Shape = { Round: 'ROUND', Square: 'SQUARE' diff --git a/packages/presets/client/tests/client-preset.spec.ts b/packages/presets/client/tests/client-preset.spec.ts index 072fbd46b11..2716fc994aa 100644 --- a/packages/presets/client/tests/client-preset.spec.ts +++ b/packages/presets/client/tests/client-preset.spec.ts @@ -362,9 +362,11 @@ export * from "./gql";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -477,9 +479,11 @@ export * from "./gql";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -543,9 +547,11 @@ export * from "./gql";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type MeQueryVariables = Exact<{ [key: string]: never; }>; @@ -634,9 +640,11 @@ export * from "./gql";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -1472,9 +1480,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type BbbQueryVariables = Exact<{ [key: string]: never; }>; @@ -1529,9 +1539,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -1589,9 +1601,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -1649,9 +1663,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -1711,9 +1727,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AaaQueryVariables = Exact<{ [key: string]: never; }>; @@ -1769,9 +1787,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -1833,9 +1853,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -1898,9 +1920,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -1963,9 +1987,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AQueryVariables = Exact<{ [key: string]: never; }>; @@ -2034,9 +2060,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AbFragment = ( { b: string } & { ' $fragmentRefs'?: { 'AcFragment': AcFragment;'AaFragment': AaFragment } } @@ -2112,9 +2140,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type AcFragment = { __typename: 'A', b: string } & { ' $fragmentName'?: 'AcFragment' }; export type AaFragment = { __typename: 'A', b: string } & { ' $fragmentName'?: 'AaFragment' }; @@ -2166,9 +2196,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type FooQueryVariables = Exact<{ [key: string]: never; }>; @@ -2228,9 +2260,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type FooQueryVariables = Exact<{ [key: string]: never; }>; @@ -2290,9 +2324,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; export type FooQueryVariables = Exact<{ [key: string]: never; }>; @@ -2425,9 +2461,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; export type FooQueryVariables = Exact<{ [key: string]: never; }>; @@ -2558,9 +2596,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; export type FooQueryVariables = Exact<{ [key: string]: never; }>; @@ -2824,9 +2864,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; export type OnRegionCreatedSubscriptionVariables = Exact<{ [key: string]: never; }>; @@ -2901,9 +2943,11 @@ export * from "./gql.cjs";`); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + /** Internal type. DO NOT USE DIRECTLY. */ type Exact = { [K in keyof T]: T[K] }; + /** Internal type. DO NOT USE DIRECTLY. */ export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; export type Test_UserQueryVariables = Exact<{ [key: string]: never; }>;