diff --git a/.changeset/@graphql-codegen_cli-10496-dependencies.md b/.changeset/@graphql-codegen_cli-10496-dependencies.md new file mode 100644 index 00000000000..1da26fe3256 --- /dev/null +++ b/.changeset/@graphql-codegen_cli-10496-dependencies.md @@ -0,0 +1,6 @@ +--- +"@graphql-codegen/cli": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/client-preset@^5.2.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/client-preset/v/5.2.0) (from `^5.1.2`, in `dependencies`) + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_client-preset-10496-dependencies.md b/.changeset/@graphql-codegen_client-preset-10496-dependencies.md new file mode 100644 index 00000000000..aa76a06c453 --- /dev/null +++ b/.changeset/@graphql-codegen_client-preset-10496-dependencies.md @@ -0,0 +1,10 @@ +--- +"@graphql-codegen/client-preset": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/typed-document-node@^6.1.3` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typed-document-node/v/6.1.3) (from `^6.1.2`, in `dependencies`) + - Updated dependency [`@graphql-codegen/typescript@^5.0.5` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript/v/5.0.5) (from `^5.0.4`, in `dependencies`) + - Updated dependency [`@graphql-codegen/typescript-operations@^5.0.5` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript-operations/v/5.0.5) (from `^5.0.4`, in `dependencies`) + - Updated dependency [`@graphql-codegen/gql-tag-operations@5.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/gql-tag-operations/v/5.1.0) (from `5.0.5`, in `dependencies`) + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) + - Updated dependency [`@graphql-codegen/visitor-plugin-common@^6.2.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/6.2.0) (from `^6.1.2`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_gql-tag-operations-10496-dependencies.md b/.changeset/@graphql-codegen_gql-tag-operations-10496-dependencies.md new file mode 100644 index 00000000000..8b556536d8a --- /dev/null +++ b/.changeset/@graphql-codegen_gql-tag-operations-10496-dependencies.md @@ -0,0 +1,6 @@ +--- +"@graphql-codegen/gql-tag-operations": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) + - Updated dependency [`@graphql-codegen/visitor-plugin-common@6.2.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/6.2.0) (from `6.1.2`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_graphql-modules-preset-10496-dependencies.md b/.changeset/@graphql-codegen_graphql-modules-preset-10496-dependencies.md new file mode 100644 index 00000000000..5251ebebfdb --- /dev/null +++ b/.changeset/@graphql-codegen_graphql-modules-preset-10496-dependencies.md @@ -0,0 +1,6 @@ +--- +"@graphql-codegen/graphql-modules-preset": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) + - Updated dependency [`@graphql-codegen/visitor-plugin-common@6.2.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/6.2.0) (from `6.1.2`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typed-document-node-10496-dependencies.md b/.changeset/@graphql-codegen_typed-document-node-10496-dependencies.md new file mode 100644 index 00000000000..ffc6eb27d68 --- /dev/null +++ b/.changeset/@graphql-codegen_typed-document-node-10496-dependencies.md @@ -0,0 +1,6 @@ +--- +"@graphql-codegen/typed-document-node": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) + - Updated dependency [`@graphql-codegen/visitor-plugin-common@6.2.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/6.2.0) (from `6.1.2`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typescript-10496-dependencies.md b/.changeset/@graphql-codegen_typescript-10496-dependencies.md new file mode 100644 index 00000000000..7f1cbc7a52e --- /dev/null +++ b/.changeset/@graphql-codegen_typescript-10496-dependencies.md @@ -0,0 +1,6 @@ +--- +"@graphql-codegen/typescript": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) + - Updated dependency [`@graphql-codegen/visitor-plugin-common@6.2.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/6.2.0) (from `6.1.2`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typescript-document-nodes-10496-dependencies.md b/.changeset/@graphql-codegen_typescript-document-nodes-10496-dependencies.md new file mode 100644 index 00000000000..e26048ceb9c --- /dev/null +++ b/.changeset/@graphql-codegen_typescript-document-nodes-10496-dependencies.md @@ -0,0 +1,6 @@ +--- +"@graphql-codegen/typescript-document-nodes": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) + - Updated dependency [`@graphql-codegen/visitor-plugin-common@6.2.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/6.2.0) (from `6.1.2`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typescript-operations-10496-dependencies.md b/.changeset/@graphql-codegen_typescript-operations-10496-dependencies.md new file mode 100644 index 00000000000..f987ce2292c --- /dev/null +++ b/.changeset/@graphql-codegen_typescript-operations-10496-dependencies.md @@ -0,0 +1,7 @@ +--- +"@graphql-codegen/typescript-operations": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) + - Updated dependency [`@graphql-codegen/typescript@^5.0.5` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript/v/5.0.5) (from `^5.0.4`, in `dependencies`) + - Updated dependency [`@graphql-codegen/visitor-plugin-common@6.2.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/6.2.0) (from `6.1.2`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_typescript-resolvers-10496-dependencies.md b/.changeset/@graphql-codegen_typescript-resolvers-10496-dependencies.md new file mode 100644 index 00000000000..90c2beaf989 --- /dev/null +++ b/.changeset/@graphql-codegen_typescript-resolvers-10496-dependencies.md @@ -0,0 +1,7 @@ +--- +"@graphql-codegen/typescript-resolvers": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) + - Updated dependency [`@graphql-codegen/typescript@^5.0.5` ↗︎](https://www.npmjs.com/package/@graphql-codegen/typescript/v/5.0.5) (from `^5.0.4`, in `dependencies`) + - Updated dependency [`@graphql-codegen/visitor-plugin-common@6.2.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/visitor-plugin-common/v/6.2.0) (from `6.1.2`, in `dependencies`) diff --git a/.changeset/@graphql-codegen_visitor-plugin-common-10496-dependencies.md b/.changeset/@graphql-codegen_visitor-plugin-common-10496-dependencies.md new file mode 100644 index 00000000000..7e6a61d5d42 --- /dev/null +++ b/.changeset/@graphql-codegen_visitor-plugin-common-10496-dependencies.md @@ -0,0 +1,5 @@ +--- +"@graphql-codegen/visitor-plugin-common": patch +--- +dependencies updates: + - Updated dependency [`@graphql-codegen/plugin-helpers@^6.1.0` ↗︎](https://www.npmjs.com/package/@graphql-codegen/plugin-helpers/v/6.1.0) (from `^6.0.0`, in `dependencies`) 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/.changeset/clever-loops-crash.md b/.changeset/clever-loops-crash.md new file mode 100644 index 00000000000..c28b7d69057 --- /dev/null +++ b/.changeset/clever-loops-crash.md @@ -0,0 +1,6 @@ +--- +'@graphql-codegen/visitor-plugin-common': minor +'@graphql-codegen/typescript-operations': minor +--- + +Add importSchemaTypesFrom support diff --git a/.changeset/curly-trees-lead.md b/.changeset/curly-trees-lead.md new file mode 100644 index 00000000000..e6aab78bdca --- /dev/null +++ b/.changeset/curly-trees-lead.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/typescript-operations': major +--- + +BREAKING CHANGE: typescript-operations plugin now generates enum if it is used in operation. diff --git a/.changeset/every-queens-sin.md b/.changeset/every-queens-sin.md new file mode 100644 index 00000000000..cda139690b5 --- /dev/null +++ b/.changeset/every-queens-sin.md @@ -0,0 +1,6 @@ +--- +'@graphql-codegen/typescript-operations': major +'@graphql-codegen/client-preset': major +--- + +Conditionally generate input types and output enums into target file diff --git a/.changeset/khaki-turtles-juggle.md b/.changeset/khaki-turtles-juggle.md new file mode 100644 index 00000000000..bb0e0614a6a --- /dev/null +++ b/.changeset/khaki-turtles-juggle.md @@ -0,0 +1,6 @@ +--- +'@graphql-codegen/typescript-operations': major +'@graphql-codegen/typescript': minor +--- + +The `typescript-operations` plugin no longer generates InputMaybe and Scalars types; it now uses native Typescript types instead. diff --git a/.changeset/lovely-sloths-kiss.md b/.changeset/lovely-sloths-kiss.md new file mode 100644 index 00000000000..3005f29b02b --- /dev/null +++ b/.changeset/lovely-sloths-kiss.md @@ -0,0 +1,7 @@ +--- +'@graphql-codegen/typescript-operations': major +'@graphql-codegen/typescript': major +'@graphql-codegen/client-preset': major +--- + +BREAKING CHANGE: `typescript` plugin no longer generates `Exact` utility type. Instead, `typescript-operations` generates said utility type for every file it creates. This is because it is used _only_ for `Variables`, so we only need to generate it once for every generated operation file. diff --git a/.changeset/proud-cougars-hear.md b/.changeset/proud-cougars-hear.md new file mode 100644 index 00000000000..f02764b32ff --- /dev/null +++ b/.changeset/proud-cougars-hear.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/visitor-plugin-common': major +--- + +BREAKING CHANGE: `@graphql-codegen/visitor-plugin-common`'s `base-types-visitor` no longer has `getNodeComment` or `buildEnumValuesBlock` method. diff --git a/.changeset/proud-jobs-decide.md b/.changeset/proud-jobs-decide.md new file mode 100644 index 00000000000..36c3a298ac4 --- /dev/null +++ b/.changeset/proud-jobs-decide.md @@ -0,0 +1,6 @@ +--- +'@graphql-codegen/visitor-plugin-common': minor +'@graphql-codegen/typescript-operations': minor +--- + +Add generatesOperationTypes to typescript-operations to allow omitting operation types such as Variables, Query/Mutation/Subscription selection set, and Fragment types diff --git a/.changeset/real-numbers-fall.md b/.changeset/real-numbers-fall.md new file mode 100644 index 00000000000..12c0cedbf52 --- /dev/null +++ b/.changeset/real-numbers-fall.md @@ -0,0 +1,14 @@ +--- +'@graphql-codegen/visitor-plugin-common': major +'@graphql-codegen/typescript-operations': major +'@graphql-codegen/client-preset': major +--- + +BREAKING CHANGE: Operation plugin and Client Preset no longer generates optional `__typename` for result type + +`__typenam` should not be in the request unless: + +- explicitly requested by the user +- automatically injected into the request by clients, such as Apollo Clients. + +Note: Apollo Client users can still use `nonOptionalTypename: true` and `skipTypeNameForRoot: true` to ensure generated types match the runtime behaviour. diff --git a/.changeset/salty-cooks-feel.md b/.changeset/salty-cooks-feel.md new file mode 100644 index 00000000000..464168ec4cb --- /dev/null +++ b/.changeset/salty-cooks-feel.md @@ -0,0 +1,6 @@ +--- +'@graphql-codegen/visitor-plugin-common': minor +'@graphql-codegen/typescript-operations': minor +--- + +Adding a new config option 'extractAllFieldsToTypesFieldNamesOnly' that generates field names without types (in the apollo tooling way) diff --git a/.changeset/salty-guests-retire.md b/.changeset/salty-guests-retire.md new file mode 100644 index 00000000000..78587b447ad --- /dev/null +++ b/.changeset/salty-guests-retire.md @@ -0,0 +1,6 @@ +--- +'@graphql-codegen/typescript-operations': major +'@graphql-codegen/client-preset': major +--- + +Integrate new typescript-operations into client-preset diff --git a/.changeset/silly-kiwis-sip.md b/.changeset/silly-kiwis-sip.md new file mode 100644 index 00000000000..31295846e7e --- /dev/null +++ b/.changeset/silly-kiwis-sip.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/typescript': patch +--- + +Extract utilities from base-type-visitor to be shared with other plugins later: convertSchemaEnumToDeclarationBlockString, getNodeComment diff --git a/.changeset/tidy-jobs-unite.md b/.changeset/tidy-jobs-unite.md new file mode 100644 index 00000000000..c4eb57e9cd1 --- /dev/null +++ b/.changeset/tidy-jobs-unite.md @@ -0,0 +1,9 @@ +--- +'@graphql-codegen/visitor-plugin-common': patch +'@graphql-codegen/typescript-operations': patch +'@graphql-codegen/typescript': patch +'@graphql-codegen/typescript-resolvers': patch +'@graphql-codegen/client-preset': patch +--- + +Abstract how enum imports are generated into visitor-plugin-common package diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1584793fa41..caa2bf6d938 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,9 +4,11 @@ on: push: branches: - master + - master-next # FIXME:eddeee888 Remove once done pull_request: branches: - master + - master-next # FIXME:eddeee888 Remove once released env: NODE_OPTIONS: '--max_old_space_size=4096' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d5fcc670e73..a1309ee6844 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,6 +3,7 @@ on: pull_request: branches: - master + - master-next # FIXME:eddeee888 Remove once done permissions: contents: write diff --git a/dev-test/codegen.ts b/dev-test/codegen.ts index 04584a36395..075ee2918be 100644 --- a/dev-test/codegen.ts +++ b/dev-test/codegen.ts @@ -40,7 +40,6 @@ const config: CodegenConfig = { { add: { content: 'declare namespace GraphQL {' } }, { add: { placement: 'append', content: '}' } }, 'typescript', - 'typescript-operations', ], }, './dev-test/test-schema/env.types.ts': { schema: process.env.SCHEMA_PATH, plugins: ['typescript'] }, @@ -65,81 +64,81 @@ const config: CodegenConfig = { './dev-test/githunt/typed-document-nodes.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', - plugins: ['typescript', 'typescript-operations', 'typed-document-node'], + plugins: ['typescript-operations', 'typed-document-node'], }, './dev-test/githunt/types.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/githunt/types.preResolveTypes.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', config: { preResolveTypes: true }, - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/githunt/types.onlyEnums.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', - config: { onlyEnums: true }, - plugins: ['typescript'], + config: { generatesOperationTypes: false }, + plugins: ['typescript-operations'], }, './dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', - config: { preResolveTypes: true, onlyOperationTypes: true }, - plugins: ['typescript', 'typescript-operations'], + config: { preResolveTypes: true }, + plugins: ['typescript-operations'], }, './dev-test/githunt/types.flatten.preResolveTypes.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', config: { preResolveTypes: true, flattenGeneratedTypes: true }, - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/githunt/types.enumsAsTypes.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', - config: { enumsAsTypes: true }, - plugins: ['typescript', 'typescript-operations'], + config: { enumType: 'string-literal' }, + plugins: ['typescript-operations'], }, './dev-test/githunt/types.d.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', - config: { enumsAsTypes: true }, - plugins: ['typescript', 'typescript-operations'], + config: {}, + plugins: ['typescript-operations'], }, './dev-test/githunt/types.avoidOptionals.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', config: { avoidOptionals: true }, - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/githunt/types.immutableTypes.ts': { schema: './dev-test/githunt/schema.json', documents: './dev-test/githunt/**/*.graphql', config: { immutableTypes: true }, - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/star-wars/types.ts': { schema: './dev-test/star-wars/schema.json', documents: './dev-test/star-wars/**/*.graphql', - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/star-wars/types.excludeQueryAlpha.ts': { schema: './dev-test/star-wars/schema.json', documents: ['./dev-test/star-wars/**/*.graphql', '!./dev-test/star-wars/**/ExcludeQueryAlpha.graphql'], - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/star-wars/types.excludeQueryBeta.ts': { schema: './dev-test/star-wars/schema.json', documents: ['./dev-test/star-wars/**/*.graphql', '!./dev-test/star-wars/**/ExcludeQueryBeta.graphql'], - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/star-wars/types.preResolveTypes.ts': { schema: './dev-test/star-wars/schema.json', documents: './dev-test/star-wars/**/*.graphql', config: { preResolveTypes: true }, - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/star-wars/types.OnlyEnums.ts': { schema: './dev-test/star-wars/schema.json', @@ -150,25 +149,25 @@ const config: CodegenConfig = { './dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts': { schema: './dev-test/star-wars/schema.json', documents: './dev-test/star-wars/**/*.graphql', - config: { preResolveTypes: true, onlyOperationTypes: true }, - plugins: ['typescript', 'typescript-operations'], + config: { preResolveTypes: true }, + plugins: ['typescript-operations'], }, './dev-test/test-schema/types.preResolveTypes.ts': { schema: './dev-test/test-schema/schema.graphql', documents: ['query test { testArr1 testArr2 testArr3 }'], config: { preResolveTypes: true }, - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts': { schema: './dev-test/test-schema/schema.graphql', documents: ['query test { testArr1 testArr2 testArr3 }'], - config: { preResolveTypes: true, onlyOperationTypes: true }, - plugins: ['typescript', 'typescript-operations'], + config: { preResolveTypes: true }, + plugins: ['typescript-operations'], }, './dev-test/star-wars/types.d.ts': { schema: './dev-test/star-wars/schema.json', - config: { enumsAsTypes: true }, - plugins: ['typescript', 'typescript-operations'], + config: { enumType: 'string-literal' }, + plugins: ['typescript-operations'], }, './dev-test/modules/': { schema: './dev-test/modules/*/types/*.graphql', @@ -179,25 +178,25 @@ const config: CodegenConfig = { './dev-test/star-wars/types.globallyAvailable.d.ts': { schema: './dev-test/star-wars/schema.json', documents: './dev-test/star-wars/**/*.graphql', - config: { enumsAsTypes: true, noExport: true }, - plugins: ['typescript', 'typescript-operations'], + config: { noExport: true }, + plugins: ['typescript-operations'], }, './dev-test/star-wars/types.avoidOptionals.ts': { schema: './dev-test/star-wars/schema.json', documents: './dev-test/star-wars/**/*.graphql', config: { avoidOptionals: true }, - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/star-wars/types.immutableTypes.ts': { schema: './dev-test/star-wars/schema.json', documents: './dev-test/star-wars/**/*.graphql', config: { immutableTypes: true }, - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/star-wars/types.skipSchema.ts': { schema: './dev-test/star-wars/schema.json', documents: './dev-test/star-wars/**/*.graphql', - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], }, './dev-test/gql-tag-operations/gql/': { schema: './dev-test/gql-tag-operations/schema.graphql', @@ -224,7 +223,7 @@ const config: CodegenConfig = { './dev-test/test-null-value/result.d.ts': { schema: './dev-test/test-null-value/schema.graphql', documents: ['./dev-test/test-null-value/query.ts'], - plugins: ['typescript', 'typescript-operations'], + plugins: ['typescript-operations'], config: { // The combination of these two flags caused the following issue: // https://github.com/dotansimha/graphql-code-generator/pull/9709 @@ -256,6 +255,25 @@ const config: CodegenConfig = { }, }, }, + + // standalone-operations + './dev-test/standalone-operations/import-schema-types/_base.generated.ts': { + schema: './dev-test/standalone-operations/schema.graphql', + documents: ['./dev-test/standalone-operations/import-schema-types/*.graphql'], + plugins: ['typescript-operations'], + config: { + generatesOperationTypes: false, + }, + }, + './dev-test/standalone-operations/import-schema-types/_types.generated.ts': { + schema: './dev-test/standalone-operations/schema.graphql', + documents: ['./dev-test/standalone-operations/import-schema-types/*.graphql'], + plugins: ['typescript-operations'], + config: { + importSchemaTypesFrom: './dev-test/standalone-operations/import-schema-types/_base.generated.ts', + namespacedImportName: 'Types', + }, + }, }, }; diff --git a/dev-test/githunt/typed-document-nodes.ts b/dev-test/githunt/typed-document-nodes.ts index 5d66b82c399..275d45818d5 100644 --- a/dev-test/githunt/typed-document-nodes.ts +++ b/dev-test/githunt/typed-document-nodes.ts @@ -1,215 +1,41 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A comment about an entry, submitted by a user */ -export type Comment = { - __typename?: 'Comment'; - /** The text of the comment */ - content: Scalars['String']['output']; - /** A timestamp of when the comment was posted */ - createdAt: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who posted the comment */ - postedBy: User; - /** The repository which this comment is about */ - repoName: Scalars['String']['output']; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type Entry = { - __typename?: 'Entry'; - /** The number of comments posted about this repository */ - commentCount: Scalars['Int']['output']; - /** Comments posted about this repository */ - comments: Array>; - /** A timestamp of when the entry was submitted */ - createdAt: Scalars['Float']['output']; - /** The hot score of this repository */ - hotScore: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who submitted this entry */ - postedBy: User; - /** Information about the repository from GitHub */ - repository: Repository; - /** The score of this repository, upvotes - downvotes */ - score: Scalars['Int']['output']; - /** XXX to be changed */ - vote: Vote; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type EntryCommentsArgs = { - limit?: InputMaybe; - offset?: InputMaybe; -}; - -/** A list of options for the sort order of the feed */ -export enum FeedType { - /** Sort by a combination of freshness and score, using Reddit's algorithm */ - Hot = 'HOT', - /** Newest entries first */ - New = 'NEW', - /** Highest score entries first */ - Top = 'TOP', -} - -export type Mutation = { - __typename?: 'Mutation'; - /** Comment on a repository, returns the new comment */ - submitComment?: Maybe; - /** Submit a new repository, returns the new submission */ - submitRepository?: Maybe; - /** Vote on a repository submission, returns the submission that was voted on */ - vote?: Maybe; -}; - -export type MutationSubmitCommentArgs = { - commentContent: Scalars['String']['input']; - repoFullName: Scalars['String']['input']; -}; - -export type MutationSubmitRepositoryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type MutationVoteArgs = { - repoFullName: Scalars['String']['input']; - type: VoteType; -}; - -export type Query = { - __typename?: 'Query'; - /** Return the currently logged in user, or null if nobody is logged in */ - currentUser?: Maybe; - /** A single entry */ - entry?: Maybe; - /** A feed of repository submissions */ - feed?: Maybe>>; -}; - -export type QueryEntryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type QueryFeedArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - type: FeedType; -}; - -/** - * A repository object from the GitHub API. This uses the exact field names returned by the - * GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. - */ -export type Repository = { - __typename?: 'Repository'; - /** The description of the repository */ - description?: Maybe; - /** The full name of the repository with the username, e.g. apollostack/GitHunt-API */ - full_name: Scalars['String']['output']; - /** The link to the repository on GitHub */ - html_url: Scalars['String']['output']; - /** Just the name of the repository, e.g. GitHunt-API */ - name: Scalars['String']['output']; - /** The number of open issues on this repository on GitHub */ - open_issues_count?: Maybe; - /** The owner of this repository on GitHub, e.g. apollostack */ - owner?: Maybe; - /** The number of people who have starred this repository on GitHub */ - stargazers_count: Scalars['Int']['output']; -}; - -export type Subscription = { - __typename?: 'Subscription'; - /** Subscription fires on every comment added */ - commentAdded?: Maybe; -}; - -export type SubscriptionCommentAddedArgs = { - repoFullName: Scalars['String']['input']; -}; - -/** A user object from the GitHub API. This uses the exact field names returned from the GitHub API. */ -export type User = { - __typename?: 'User'; - /** The URL to a directly embeddable image for this user's avatar */ - avatar_url: Scalars['String']['output']; - /** The URL of this user's GitHub page */ - html_url: Scalars['String']['output']; - /** The name of the user, e.g. apollostack */ - login: Scalars['String']['output']; -}; - -/** XXX to be removed */ -export type Vote = { - __typename?: 'Vote'; - vote_value: Scalars['Int']['output']; -}; - -/** The type of vote to record, when submitting a vote */ -export enum VoteType { - Cancel = 'CANCEL', - Down = 'DOWN', - Up = 'UP', -} - export type OnCommentAddedSubscriptionVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; export type OnCommentAddedSubscription = { - __typename?: 'Subscription'; - commentAdded?: { - __typename?: 'Comment'; + commentAdded: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; export type CommentQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - limit?: InputMaybe; - offset?: InputMaybe; + repoFullName: string; + limit?: number | null; + offset?: number | null; }>; export type CommentQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { - __typename?: 'Entry'; + currentUser: { login: string; html_url: string } | null; + entry: { id: number; createdAt: number; commentCount: number; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; comments: Array<{ - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | 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; @@ -218,120 +44,93 @@ export type CommentQuery = { }; export type CommentsPageCommentFragment = { - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; }; export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never }>; -export type CurrentUserForProfileQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; -}; +export type CurrentUserForProfileQuery = { currentUser: { login: string; avatar_url: string } | null }; export type FeedEntryFragment = { - __typename?: 'Entry'; id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; }; export type FeedQueryVariables = Exact<{ type: FeedType; - offset?: InputMaybe; - limit?: InputMaybe; + offset?: number | null; + limit?: number | null; }>; export type FeedQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ - __typename?: 'Entry'; + currentUser: { login: string } | null; + feed: Array<{ id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; } | null> | null; }; export type SubmitRepositoryMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; -export type SubmitRepositoryMutation = { - __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; -}; +export type SubmitRepositoryMutation = { submitRepository: { createdAt: number } | null }; export type RepoInfoFragment = { - __typename?: 'Entry'; createdAt: number; - repository: { - __typename?: 'Repository'; - description?: string | null; - stargazers_count: number; - open_issues_count?: number | null; - }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + repository: { description: string | null; stargazers_count: number; open_issues_count: number | null }; + postedBy: { html_url: string; login: string }; }; export type SubmitCommentMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; - commentContent: Scalars['String']['input']; + repoFullName: string; + commentContent: string; }>; export type SubmitCommentMutation = { - __typename?: 'Mutation'; - submitComment?: { - __typename?: 'Comment'; + submitComment: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; -export type VoteButtonsFragment = { - __typename?: 'Entry'; - score: number; - vote: { __typename?: 'Vote'; vote_value: number }; -}; +export type VoteButtonsFragment = { score: number; vote: { vote_value: number } }; export type VoteMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; type: VoteType; }>; -export type VoteMutation = { - __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; -}; +export type VoteMutation = { vote: { score: number; id: number; vote: { vote_value: number } } | null }; export const CommentsPageCommentFragmentDoc = { kind: 'Document', diff --git a/dev-test/githunt/types.avoidOptionals.ts b/dev-test/githunt/types.avoidOptionals.ts index fae92412f8c..69796beb7e6 100644 --- a/dev-test/githunt/types.avoidOptionals.ts +++ b/dev-test/githunt/types.avoidOptionals.ts @@ -1,212 +1,38 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A comment about an entry, submitted by a user */ -export type Comment = { - __typename?: 'Comment'; - /** The text of the comment */ - content: Scalars['String']['output']; - /** A timestamp of when the comment was posted */ - createdAt: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who posted the comment */ - postedBy: User; - /** The repository which this comment is about */ - repoName: Scalars['String']['output']; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type Entry = { - __typename?: 'Entry'; - /** The number of comments posted about this repository */ - commentCount: Scalars['Int']['output']; - /** Comments posted about this repository */ - comments: Array>; - /** A timestamp of when the entry was submitted */ - createdAt: Scalars['Float']['output']; - /** The hot score of this repository */ - hotScore: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who submitted this entry */ - postedBy: User; - /** Information about the repository from GitHub */ - repository: Repository; - /** The score of this repository, upvotes - downvotes */ - score: Scalars['Int']['output']; - /** XXX to be changed */ - vote: Vote; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type EntryCommentsArgs = { - limit: InputMaybe; - offset: InputMaybe; -}; - -/** A list of options for the sort order of the feed */ -export enum FeedType { - /** Sort by a combination of freshness and score, using Reddit's algorithm */ - Hot = 'HOT', - /** Newest entries first */ - New = 'NEW', - /** Highest score entries first */ - Top = 'TOP', -} - -export type Mutation = { - __typename?: 'Mutation'; - /** Comment on a repository, returns the new comment */ - submitComment: Maybe; - /** Submit a new repository, returns the new submission */ - submitRepository: Maybe; - /** Vote on a repository submission, returns the submission that was voted on */ - vote: Maybe; -}; - -export type MutationSubmitCommentArgs = { - commentContent: Scalars['String']['input']; - repoFullName: Scalars['String']['input']; -}; - -export type MutationSubmitRepositoryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type MutationVoteArgs = { - repoFullName: Scalars['String']['input']; - type: VoteType; -}; - -export type Query = { - __typename?: 'Query'; - /** Return the currently logged in user, or null if nobody is logged in */ - currentUser: Maybe; - /** A single entry */ - entry: Maybe; - /** A feed of repository submissions */ - feed: Maybe>>; -}; - -export type QueryEntryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type QueryFeedArgs = { - limit: InputMaybe; - offset: InputMaybe; - type: FeedType; -}; - -/** - * A repository object from the GitHub API. This uses the exact field names returned by the - * GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. - */ -export type Repository = { - __typename?: 'Repository'; - /** The description of the repository */ - description: Maybe; - /** The full name of the repository with the username, e.g. apollostack/GitHunt-API */ - full_name: Scalars['String']['output']; - /** The link to the repository on GitHub */ - html_url: Scalars['String']['output']; - /** Just the name of the repository, e.g. GitHunt-API */ - name: Scalars['String']['output']; - /** The number of open issues on this repository on GitHub */ - open_issues_count: Maybe; - /** The owner of this repository on GitHub, e.g. apollostack */ - owner: Maybe; - /** The number of people who have starred this repository on GitHub */ - stargazers_count: Scalars['Int']['output']; -}; - -export type Subscription = { - __typename?: 'Subscription'; - /** Subscription fires on every comment added */ - commentAdded: Maybe; -}; - -export type SubscriptionCommentAddedArgs = { - repoFullName: Scalars['String']['input']; -}; - -/** A user object from the GitHub API. This uses the exact field names returned from the GitHub API. */ -export type User = { - __typename?: 'User'; - /** The URL to a directly embeddable image for this user's avatar */ - avatar_url: Scalars['String']['output']; - /** The URL of this user's GitHub page */ - html_url: Scalars['String']['output']; - /** The name of the user, e.g. apollostack */ - login: Scalars['String']['output']; -}; - -/** XXX to be removed */ -export type Vote = { - __typename?: 'Vote'; - vote_value: Scalars['Int']['output']; -}; - -/** The type of vote to record, when submitting a vote */ -export enum VoteType { - Cancel = 'CANCEL', - Down = 'DOWN', - Up = 'UP', -} - export type OnCommentAddedSubscriptionVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; export type OnCommentAddedSubscription = { - __typename?: 'Subscription'; commentAdded: { - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; export type CommentQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - limit: InputMaybe; - offset: InputMaybe; + repoFullName: string; + limit: number | null; + offset: number | null; }>; export type CommentQuery = { - __typename?: 'Query'; - currentUser: { __typename?: 'User'; login: string; html_url: string } | null; + currentUser: { login: string; html_url: string } | null; entry: { - __typename?: 'Entry'; id: number; createdAt: number; commentCount: number; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; comments: Array<{ - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null>; repository: { - __typename?: 'Repository'; description: string | null; open_issues_count: number | null; stargazers_count: number; @@ -217,117 +43,90 @@ export type CommentQuery = { }; export type CommentsPageCommentFragment = { - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; }; export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never }>; -export type CurrentUserForProfileQuery = { - __typename?: 'Query'; - currentUser: { __typename?: 'User'; login: string; avatar_url: string } | null; -}; +export type CurrentUserForProfileQuery = { currentUser: { login: string; avatar_url: string } | null }; export type FeedEntryFragment = { - __typename?: 'Entry'; id: number; commentCount: number; score: number; createdAt: number; repository: { - __typename?: 'Repository'; full_name: string; html_url: string; description: string | null; stargazers_count: number; open_issues_count: number | null; - owner: { __typename?: 'User'; avatar_url: string } | null; + owner: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; }; export type FeedQueryVariables = Exact<{ type: FeedType; - offset: InputMaybe; - limit: InputMaybe; + offset: number | null; + limit: number | null; }>; export type FeedQuery = { - __typename?: 'Query'; - currentUser: { __typename?: 'User'; login: string } | null; + currentUser: { login: string } | null; feed: Array<{ - __typename?: 'Entry'; id: number; commentCount: number; score: number; createdAt: number; repository: { - __typename?: 'Repository'; full_name: string; html_url: string; description: string | null; stargazers_count: number; open_issues_count: number | null; - owner: { __typename?: 'User'; avatar_url: string } | null; + owner: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; } | null> | null; }; export type SubmitRepositoryMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; -export type SubmitRepositoryMutation = { - __typename?: 'Mutation'; - submitRepository: { __typename?: 'Entry'; createdAt: number } | null; -}; +export type SubmitRepositoryMutation = { submitRepository: { createdAt: number } | null }; export type RepoInfoFragment = { - __typename?: 'Entry'; createdAt: number; - repository: { - __typename?: 'Repository'; - description: string | null; - stargazers_count: number; - open_issues_count: number | null; - }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + repository: { description: string | null; stargazers_count: number; open_issues_count: number | null }; + postedBy: { html_url: string; login: string }; }; export type SubmitCommentMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; - commentContent: Scalars['String']['input']; + repoFullName: string; + commentContent: string; }>; export type SubmitCommentMutation = { - __typename?: 'Mutation'; submitComment: { - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; -export type VoteButtonsFragment = { - __typename?: 'Entry'; - score: number; - vote: { __typename?: 'Vote'; vote_value: number }; -}; +export type VoteButtonsFragment = { score: number; vote: { vote_value: number } }; export type VoteMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; type: VoteType; }>; -export type VoteMutation = { - __typename?: 'Mutation'; - vote: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; -}; +export type VoteMutation = { vote: { score: number; id: number; vote: { vote_value: number } } | null }; diff --git a/dev-test/githunt/types.d.ts b/dev-test/githunt/types.d.ts index a3214fa9248..87793fe2a3f 100644 --- a/dev-test/githunt/types.d.ts +++ b/dev-test/githunt/types.d.ts @@ -1,209 +1,40 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A comment about an entry, submitted by a user */ -export type Comment = { - __typename?: 'Comment'; - /** The text of the comment */ - content: Scalars['String']['output']; - /** A timestamp of when the comment was posted */ - createdAt: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who posted the comment */ - postedBy: User; - /** The repository which this comment is about */ - repoName: Scalars['String']['output']; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type Entry = { - __typename?: 'Entry'; - /** The number of comments posted about this repository */ - commentCount: Scalars['Int']['output']; - /** Comments posted about this repository */ - comments: Array>; - /** A timestamp of when the entry was submitted */ - createdAt: Scalars['Float']['output']; - /** The hot score of this repository */ - hotScore: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who submitted this entry */ - postedBy: User; - /** Information about the repository from GitHub */ - repository: Repository; - /** The score of this repository, upvotes - downvotes */ - score: Scalars['Int']['output']; - /** XXX to be changed */ - vote: Vote; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type EntryCommentsArgs = { - limit?: InputMaybe; - offset?: InputMaybe; -}; - -/** 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 */ - | 'HOT' - /** Newest entries first */ - | 'NEW' - /** Highest score entries first */ - | 'TOP'; - -export type Mutation = { - __typename?: 'Mutation'; - /** Comment on a repository, returns the new comment */ - submitComment?: Maybe; - /** Submit a new repository, returns the new submission */ - submitRepository?: Maybe; - /** Vote on a repository submission, returns the submission that was voted on */ - vote?: Maybe; -}; - -export type MutationSubmitCommentArgs = { - commentContent: Scalars['String']['input']; - repoFullName: Scalars['String']['input']; -}; - -export type MutationSubmitRepositoryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type MutationVoteArgs = { - repoFullName: Scalars['String']['input']; - type: VoteType; -}; - -export type Query = { - __typename?: 'Query'; - /** Return the currently logged in user, or null if nobody is logged in */ - currentUser?: Maybe; - /** A single entry */ - entry?: Maybe; - /** A feed of repository submissions */ - feed?: Maybe>>; -}; - -export type QueryEntryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type QueryFeedArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - type: FeedType; -}; - -/** - * A repository object from the GitHub API. This uses the exact field names returned by the - * GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. - */ -export type Repository = { - __typename?: 'Repository'; - /** The description of the repository */ - description?: Maybe; - /** The full name of the repository with the username, e.g. apollostack/GitHunt-API */ - full_name: Scalars['String']['output']; - /** The link to the repository on GitHub */ - html_url: Scalars['String']['output']; - /** Just the name of the repository, e.g. GitHunt-API */ - name: Scalars['String']['output']; - /** The number of open issues on this repository on GitHub */ - open_issues_count?: Maybe; - /** The owner of this repository on GitHub, e.g. apollostack */ - owner?: Maybe; - /** The number of people who have starred this repository on GitHub */ - stargazers_count: Scalars['Int']['output']; -}; - -export type Subscription = { - __typename?: 'Subscription'; - /** Subscription fires on every comment added */ - commentAdded?: Maybe; -}; - -export type SubscriptionCommentAddedArgs = { - repoFullName: Scalars['String']['input']; -}; - -/** A user object from the GitHub API. This uses the exact field names returned from the GitHub API. */ -export type User = { - __typename?: 'User'; - /** The URL to a directly embeddable image for this user's avatar */ - avatar_url: Scalars['String']['output']; - /** The URL of this user's GitHub page */ - html_url: Scalars['String']['output']; - /** The name of the user, e.g. apollostack */ - login: Scalars['String']['output']; -}; - -/** XXX to be removed */ -export type Vote = { - __typename?: 'Vote'; - vote_value: Scalars['Int']['output']; -}; - -/** The type of vote to record, when submitting a vote */ -export type VoteType = 'CANCEL' | 'DOWN' | 'UP'; - export type OnCommentAddedSubscriptionVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; export type OnCommentAddedSubscription = { - __typename?: 'Subscription'; - commentAdded?: { - __typename?: 'Comment'; + commentAdded: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; export type CommentQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - limit?: InputMaybe; - offset?: InputMaybe; + repoFullName: string; + limit?: number | null; + offset?: number | null; }>; export type CommentQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { - __typename?: 'Entry'; + currentUser: { login: string; html_url: string } | null; + entry: { id: number; createdAt: number; commentCount: number; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; comments: Array<{ - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | 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; @@ -212,117 +43,90 @@ export type CommentQuery = { }; export type CommentsPageCommentFragment = { - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; }; export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never }>; -export type CurrentUserForProfileQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; -}; +export type CurrentUserForProfileQuery = { currentUser: { login: string; avatar_url: string } | null }; export type FeedEntryFragment = { - __typename?: 'Entry'; id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; }; export type FeedQueryVariables = Exact<{ type: FeedType; - offset?: InputMaybe; - limit?: InputMaybe; + offset?: number | null; + limit?: number | null; }>; export type FeedQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ - __typename?: 'Entry'; + currentUser: { login: string } | null; + feed: Array<{ id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; } | null> | null; }; export type SubmitRepositoryMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; -export type SubmitRepositoryMutation = { - __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; -}; +export type SubmitRepositoryMutation = { submitRepository: { createdAt: number } | null }; export type RepoInfoFragment = { - __typename?: 'Entry'; createdAt: number; - repository: { - __typename?: 'Repository'; - description?: string | null; - stargazers_count: number; - open_issues_count?: number | null; - }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + repository: { description: string | null; stargazers_count: number; open_issues_count: number | null }; + postedBy: { html_url: string; login: string }; }; export type SubmitCommentMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; - commentContent: Scalars['String']['input']; + repoFullName: string; + commentContent: string; }>; export type SubmitCommentMutation = { - __typename?: 'Mutation'; - submitComment?: { - __typename?: 'Comment'; + submitComment: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; -export type VoteButtonsFragment = { - __typename?: 'Entry'; - score: number; - vote: { __typename?: 'Vote'; vote_value: number }; -}; +export type VoteButtonsFragment = { score: number; vote: { vote_value: number } }; export type VoteMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; type: VoteType; }>; -export type VoteMutation = { - __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; -}; +export type VoteMutation = { vote: { score: number; id: number; vote: { vote_value: number } } | null }; diff --git a/dev-test/githunt/types.enumsAsTypes.ts b/dev-test/githunt/types.enumsAsTypes.ts index a3214fa9248..87793fe2a3f 100644 --- a/dev-test/githunt/types.enumsAsTypes.ts +++ b/dev-test/githunt/types.enumsAsTypes.ts @@ -1,209 +1,40 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A comment about an entry, submitted by a user */ -export type Comment = { - __typename?: 'Comment'; - /** The text of the comment */ - content: Scalars['String']['output']; - /** A timestamp of when the comment was posted */ - createdAt: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who posted the comment */ - postedBy: User; - /** The repository which this comment is about */ - repoName: Scalars['String']['output']; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type Entry = { - __typename?: 'Entry'; - /** The number of comments posted about this repository */ - commentCount: Scalars['Int']['output']; - /** Comments posted about this repository */ - comments: Array>; - /** A timestamp of when the entry was submitted */ - createdAt: Scalars['Float']['output']; - /** The hot score of this repository */ - hotScore: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who submitted this entry */ - postedBy: User; - /** Information about the repository from GitHub */ - repository: Repository; - /** The score of this repository, upvotes - downvotes */ - score: Scalars['Int']['output']; - /** XXX to be changed */ - vote: Vote; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type EntryCommentsArgs = { - limit?: InputMaybe; - offset?: InputMaybe; -}; - -/** 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 */ - | 'HOT' - /** Newest entries first */ - | 'NEW' - /** Highest score entries first */ - | 'TOP'; - -export type Mutation = { - __typename?: 'Mutation'; - /** Comment on a repository, returns the new comment */ - submitComment?: Maybe; - /** Submit a new repository, returns the new submission */ - submitRepository?: Maybe; - /** Vote on a repository submission, returns the submission that was voted on */ - vote?: Maybe; -}; - -export type MutationSubmitCommentArgs = { - commentContent: Scalars['String']['input']; - repoFullName: Scalars['String']['input']; -}; - -export type MutationSubmitRepositoryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type MutationVoteArgs = { - repoFullName: Scalars['String']['input']; - type: VoteType; -}; - -export type Query = { - __typename?: 'Query'; - /** Return the currently logged in user, or null if nobody is logged in */ - currentUser?: Maybe; - /** A single entry */ - entry?: Maybe; - /** A feed of repository submissions */ - feed?: Maybe>>; -}; - -export type QueryEntryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type QueryFeedArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - type: FeedType; -}; - -/** - * A repository object from the GitHub API. This uses the exact field names returned by the - * GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. - */ -export type Repository = { - __typename?: 'Repository'; - /** The description of the repository */ - description?: Maybe; - /** The full name of the repository with the username, e.g. apollostack/GitHunt-API */ - full_name: Scalars['String']['output']; - /** The link to the repository on GitHub */ - html_url: Scalars['String']['output']; - /** Just the name of the repository, e.g. GitHunt-API */ - name: Scalars['String']['output']; - /** The number of open issues on this repository on GitHub */ - open_issues_count?: Maybe; - /** The owner of this repository on GitHub, e.g. apollostack */ - owner?: Maybe; - /** The number of people who have starred this repository on GitHub */ - stargazers_count: Scalars['Int']['output']; -}; - -export type Subscription = { - __typename?: 'Subscription'; - /** Subscription fires on every comment added */ - commentAdded?: Maybe; -}; - -export type SubscriptionCommentAddedArgs = { - repoFullName: Scalars['String']['input']; -}; - -/** A user object from the GitHub API. This uses the exact field names returned from the GitHub API. */ -export type User = { - __typename?: 'User'; - /** The URL to a directly embeddable image for this user's avatar */ - avatar_url: Scalars['String']['output']; - /** The URL of this user's GitHub page */ - html_url: Scalars['String']['output']; - /** The name of the user, e.g. apollostack */ - login: Scalars['String']['output']; -}; - -/** XXX to be removed */ -export type Vote = { - __typename?: 'Vote'; - vote_value: Scalars['Int']['output']; -}; - -/** The type of vote to record, when submitting a vote */ -export type VoteType = 'CANCEL' | 'DOWN' | 'UP'; - export type OnCommentAddedSubscriptionVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; export type OnCommentAddedSubscription = { - __typename?: 'Subscription'; - commentAdded?: { - __typename?: 'Comment'; + commentAdded: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; export type CommentQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - limit?: InputMaybe; - offset?: InputMaybe; + repoFullName: string; + limit?: number | null; + offset?: number | null; }>; export type CommentQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { - __typename?: 'Entry'; + currentUser: { login: string; html_url: string } | null; + entry: { id: number; createdAt: number; commentCount: number; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; comments: Array<{ - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | 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; @@ -212,117 +43,90 @@ export type CommentQuery = { }; export type CommentsPageCommentFragment = { - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; }; export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never }>; -export type CurrentUserForProfileQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; -}; +export type CurrentUserForProfileQuery = { currentUser: { login: string; avatar_url: string } | null }; export type FeedEntryFragment = { - __typename?: 'Entry'; id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; }; export type FeedQueryVariables = Exact<{ type: FeedType; - offset?: InputMaybe; - limit?: InputMaybe; + offset?: number | null; + limit?: number | null; }>; export type FeedQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ - __typename?: 'Entry'; + currentUser: { login: string } | null; + feed: Array<{ id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; } | null> | null; }; export type SubmitRepositoryMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; -export type SubmitRepositoryMutation = { - __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; -}; +export type SubmitRepositoryMutation = { submitRepository: { createdAt: number } | null }; export type RepoInfoFragment = { - __typename?: 'Entry'; createdAt: number; - repository: { - __typename?: 'Repository'; - description?: string | null; - stargazers_count: number; - open_issues_count?: number | null; - }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + repository: { description: string | null; stargazers_count: number; open_issues_count: number | null }; + postedBy: { html_url: string; login: string }; }; export type SubmitCommentMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; - commentContent: Scalars['String']['input']; + repoFullName: string; + commentContent: string; }>; export type SubmitCommentMutation = { - __typename?: 'Mutation'; - submitComment?: { - __typename?: 'Comment'; + submitComment: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; -export type VoteButtonsFragment = { - __typename?: 'Entry'; - score: number; - vote: { __typename?: 'Vote'; vote_value: number }; -}; +export type VoteButtonsFragment = { score: number; vote: { vote_value: number } }; export type VoteMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; type: VoteType; }>; -export type VoteMutation = { - __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; -}; +export type VoteMutation = { vote: { score: number; id: number; vote: { vote_value: number } } | null }; diff --git a/dev-test/githunt/types.flatten.preResolveTypes.ts b/dev-test/githunt/types.flatten.preResolveTypes.ts index 6a71babaaf6..5315ce1bae5 100644 --- a/dev-test/githunt/types.flatten.preResolveTypes.ts +++ b/dev-test/githunt/types.flatten.preResolveTypes.ts @@ -1,216 +1,42 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A comment about an entry, submitted by a user */ -export type Comment = { - __typename?: 'Comment'; - /** The text of the comment */ - content: Scalars['String']['output']; - /** A timestamp of when the comment was posted */ - createdAt: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who posted the comment */ - postedBy: User; - /** The repository which this comment is about */ - repoName: Scalars['String']['output']; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type Entry = { - __typename?: 'Entry'; - /** The number of comments posted about this repository */ - commentCount: Scalars['Int']['output']; - /** Comments posted about this repository */ - comments: Array>; - /** A timestamp of when the entry was submitted */ - createdAt: Scalars['Float']['output']; - /** The hot score of this repository */ - hotScore: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who submitted this entry */ - postedBy: User; - /** Information about the repository from GitHub */ - repository: Repository; - /** The score of this repository, upvotes - downvotes */ - score: Scalars['Int']['output']; - /** XXX to be changed */ - vote: Vote; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type EntryCommentsArgs = { - limit?: InputMaybe; - offset?: InputMaybe; -}; - -/** A list of options for the sort order of the feed */ -export enum FeedType { - /** Sort by a combination of freshness and score, using Reddit's algorithm */ - Hot = 'HOT', - /** Newest entries first */ - New = 'NEW', - /** Highest score entries first */ - Top = 'TOP', -} - -export type Mutation = { - __typename?: 'Mutation'; - /** Comment on a repository, returns the new comment */ - submitComment?: Maybe; - /** Submit a new repository, returns the new submission */ - submitRepository?: Maybe; - /** Vote on a repository submission, returns the submission that was voted on */ - vote?: Maybe; -}; - -export type MutationSubmitCommentArgs = { - commentContent: Scalars['String']['input']; - repoFullName: Scalars['String']['input']; -}; - -export type MutationSubmitRepositoryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type MutationVoteArgs = { - repoFullName: Scalars['String']['input']; - type: VoteType; -}; - -export type Query = { - __typename?: 'Query'; - /** Return the currently logged in user, or null if nobody is logged in */ - currentUser?: Maybe; - /** A single entry */ - entry?: Maybe; - /** A feed of repository submissions */ - feed?: Maybe>>; -}; - -export type QueryEntryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type QueryFeedArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - type: FeedType; -}; - -/** - * A repository object from the GitHub API. This uses the exact field names returned by the - * GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. - */ -export type Repository = { - __typename?: 'Repository'; - /** The description of the repository */ - description?: Maybe; - /** The full name of the repository with the username, e.g. apollostack/GitHunt-API */ - full_name: Scalars['String']['output']; - /** The link to the repository on GitHub */ - html_url: Scalars['String']['output']; - /** Just the name of the repository, e.g. GitHunt-API */ - name: Scalars['String']['output']; - /** The number of open issues on this repository on GitHub */ - open_issues_count?: Maybe; - /** The owner of this repository on GitHub, e.g. apollostack */ - owner?: Maybe; - /** The number of people who have starred this repository on GitHub */ - stargazers_count: Scalars['Int']['output']; -}; - -export type Subscription = { - __typename?: 'Subscription'; - /** Subscription fires on every comment added */ - commentAdded?: Maybe; -}; - -export type SubscriptionCommentAddedArgs = { - repoFullName: Scalars['String']['input']; -}; - -/** A user object from the GitHub API. This uses the exact field names returned from the GitHub API. */ -export type User = { - __typename?: 'User'; - /** The URL to a directly embeddable image for this user's avatar */ - avatar_url: Scalars['String']['output']; - /** The URL of this user's GitHub page */ - html_url: Scalars['String']['output']; - /** The name of the user, e.g. apollostack */ - login: Scalars['String']['output']; -}; - -/** XXX to be removed */ -export type Vote = { - __typename?: 'Vote'; - vote_value: Scalars['Int']['output']; -}; - -/** The type of vote to record, when submitting a vote */ -export enum VoteType { - Cancel = 'CANCEL', - Down = 'DOWN', - Up = 'UP', -} - export type OnCommentAddedSubscriptionVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; export type OnCommentAddedSubscription = { - __typename?: 'Subscription'; - commentAdded?: { - __typename?: 'Comment'; + commentAdded: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; export type CommentQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - limit?: InputMaybe; - offset?: InputMaybe; + repoFullName: string; + limit?: number | null; + offset?: number | null; }>; export type CommentQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { - __typename?: 'Entry'; + currentUser: { login: string; html_url: string } | null; + entry: { id: number; createdAt: number; commentCount: number; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; comments: Array<{ - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null>; repository: { - __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; @@ -218,71 +44,57 @@ export type CommentQuery = { export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never }>; -export type CurrentUserForProfileQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; -}; +export type CurrentUserForProfileQuery = { currentUser: { login: string; avatar_url: string } | null }; export type FeedQueryVariables = Exact<{ type: FeedType; - offset?: InputMaybe; - limit?: InputMaybe; + offset?: number | null; + limit?: number | null; }>; export type FeedQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ - __typename?: 'Entry'; + currentUser: { login: string } | null; + feed: Array<{ id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + vote: { vote_value: number }; + postedBy: { login: string; html_url: string }; } | null> | null; }; export type SubmitRepositoryMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; -export type SubmitRepositoryMutation = { - __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; -}; +export type SubmitRepositoryMutation = { submitRepository: { createdAt: number } | null }; export type SubmitCommentMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; - commentContent: Scalars['String']['input']; + repoFullName: string; + commentContent: string; }>; export type SubmitCommentMutation = { - __typename?: 'Mutation'; - submitComment?: { - __typename?: 'Comment'; + submitComment: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; export type VoteMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; type: VoteType; }>; -export type VoteMutation = { - __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; -}; +export type VoteMutation = { vote: { score: number; id: number; vote: { vote_value: number } } | null }; diff --git a/dev-test/githunt/types.immutableTypes.ts b/dev-test/githunt/types.immutableTypes.ts index df6b6d82851..2ed4050f66c 100644 --- a/dev-test/githunt/types.immutableTypes.ts +++ b/dev-test/githunt/types.immutableTypes.ts @@ -1,214 +1,40 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A comment about an entry, submitted by a user */ -export type Comment = { - readonly __typename?: 'Comment'; - /** The text of the comment */ - readonly content: Scalars['String']['output']; - /** A timestamp of when the comment was posted */ - readonly createdAt: Scalars['Float']['output']; - /** The SQL ID of this entry */ - readonly id: Scalars['Int']['output']; - /** The GitHub user who posted the comment */ - readonly postedBy: User; - /** The repository which this comment is about */ - readonly repoName: Scalars['String']['output']; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type Entry = { - readonly __typename?: 'Entry'; - /** The number of comments posted about this repository */ - readonly commentCount: Scalars['Int']['output']; - /** Comments posted about this repository */ - readonly comments: ReadonlyArray>; - /** A timestamp of when the entry was submitted */ - readonly createdAt: Scalars['Float']['output']; - /** The hot score of this repository */ - readonly hotScore: Scalars['Float']['output']; - /** The SQL ID of this entry */ - readonly id: Scalars['Int']['output']; - /** The GitHub user who submitted this entry */ - readonly postedBy: User; - /** Information about the repository from GitHub */ - readonly repository: Repository; - /** The score of this repository, upvotes - downvotes */ - readonly score: Scalars['Int']['output']; - /** XXX to be changed */ - readonly vote: Vote; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type EntryCommentsArgs = { - limit?: InputMaybe; - offset?: InputMaybe; -}; - -/** A list of options for the sort order of the feed */ -export enum FeedType { - /** Sort by a combination of freshness and score, using Reddit's algorithm */ - Hot = 'HOT', - /** Newest entries first */ - New = 'NEW', - /** Highest score entries first */ - Top = 'TOP', -} - -export type Mutation = { - readonly __typename?: 'Mutation'; - /** Comment on a repository, returns the new comment */ - readonly submitComment?: Maybe; - /** Submit a new repository, returns the new submission */ - readonly submitRepository?: Maybe; - /** Vote on a repository submission, returns the submission that was voted on */ - readonly vote?: Maybe; -}; - -export type MutationSubmitCommentArgs = { - commentContent: Scalars['String']['input']; - repoFullName: Scalars['String']['input']; -}; - -export type MutationSubmitRepositoryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type MutationVoteArgs = { - repoFullName: Scalars['String']['input']; - type: VoteType; -}; - -export type Query = { - readonly __typename?: 'Query'; - /** Return the currently logged in user, or null if nobody is logged in */ - readonly currentUser?: Maybe; - /** A single entry */ - readonly entry?: Maybe; - /** A feed of repository submissions */ - readonly feed?: Maybe>>; -}; - -export type QueryEntryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type QueryFeedArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - type: FeedType; -}; - -/** - * A repository object from the GitHub API. This uses the exact field names returned by the - * GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. - */ -export type Repository = { - readonly __typename?: 'Repository'; - /** The description of the repository */ - readonly description?: Maybe; - /** The full name of the repository with the username, e.g. apollostack/GitHunt-API */ - readonly full_name: Scalars['String']['output']; - /** The link to the repository on GitHub */ - readonly html_url: Scalars['String']['output']; - /** Just the name of the repository, e.g. GitHunt-API */ - readonly name: Scalars['String']['output']; - /** The number of open issues on this repository on GitHub */ - readonly open_issues_count?: Maybe; - /** The owner of this repository on GitHub, e.g. apollostack */ - readonly owner?: Maybe; - /** The number of people who have starred this repository on GitHub */ - readonly stargazers_count: Scalars['Int']['output']; -}; - -export type Subscription = { - readonly __typename?: 'Subscription'; - /** Subscription fires on every comment added */ - readonly commentAdded?: Maybe; -}; - -export type SubscriptionCommentAddedArgs = { - repoFullName: Scalars['String']['input']; -}; - -/** A user object from the GitHub API. This uses the exact field names returned from the GitHub API. */ -export type User = { - readonly __typename?: 'User'; - /** The URL to a directly embeddable image for this user's avatar */ - readonly avatar_url: Scalars['String']['output']; - /** The URL of this user's GitHub page */ - readonly html_url: Scalars['String']['output']; - /** The name of the user, e.g. apollostack */ - readonly login: Scalars['String']['output']; -}; - -/** XXX to be removed */ -export type Vote = { - readonly __typename?: 'Vote'; - readonly vote_value: Scalars['Int']['output']; -}; - -/** The type of vote to record, when submitting a vote */ -export enum VoteType { - Cancel = 'CANCEL', - Down = 'DOWN', - Up = 'UP', -} - export type OnCommentAddedSubscriptionVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; export type OnCommentAddedSubscription = { - readonly __typename?: 'Subscription'; - readonly commentAdded?: { - readonly __typename?: 'Comment'; + readonly commentAdded: { readonly id: number; readonly createdAt: number; readonly content: string; - readonly postedBy: { readonly __typename?: 'User'; readonly login: string; readonly html_url: string }; + readonly postedBy: { readonly login: string; readonly html_url: string }; } | null; }; export type CommentQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - limit?: InputMaybe; - offset?: InputMaybe; + repoFullName: string; + limit?: number | null; + offset?: number | null; }>; export type CommentQuery = { - readonly __typename?: 'Query'; - readonly currentUser?: { readonly __typename?: 'User'; readonly login: string; readonly html_url: string } | null; - readonly entry?: { - readonly __typename?: 'Entry'; + readonly currentUser: { readonly login: string; readonly html_url: string } | null; + readonly entry: { readonly id: number; readonly createdAt: number; readonly commentCount: number; - readonly postedBy: { readonly __typename?: 'User'; readonly login: string; readonly html_url: string }; + readonly postedBy: { readonly login: string; readonly html_url: string }; readonly comments: ReadonlyArray<{ - readonly __typename?: 'Comment'; readonly id: number; readonly createdAt: number; readonly content: string; - readonly postedBy: { readonly __typename?: 'User'; readonly login: string; readonly html_url: string }; + readonly postedBy: { readonly login: string; readonly html_url: string }; } | 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; @@ -217,122 +43,98 @@ export type CommentQuery = { }; export type CommentsPageCommentFragment = { - readonly __typename?: 'Comment'; readonly id: number; readonly createdAt: number; readonly content: string; - readonly postedBy: { readonly __typename?: 'User'; readonly login: string; readonly html_url: string }; + readonly postedBy: { readonly login: string; readonly html_url: string }; }; 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 login: string; readonly avatar_url: string } | null; }; export type FeedEntryFragment = { - readonly __typename?: 'Entry'; readonly id: number; readonly commentCount: number; readonly score: number; readonly createdAt: number; readonly repository: { - 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 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 }; + readonly vote: { readonly vote_value: number }; + readonly postedBy: { readonly html_url: string; readonly login: string }; }; export type FeedQueryVariables = Exact<{ type: FeedType; - offset?: InputMaybe; - limit?: InputMaybe; + offset?: number | null; + limit?: number | null; }>; export type FeedQuery = { - readonly __typename?: 'Query'; - readonly currentUser?: { readonly __typename?: 'User'; readonly login: string } | null; - readonly feed?: ReadonlyArray<{ - readonly __typename?: 'Entry'; + readonly currentUser: { readonly login: string } | null; + readonly feed: ReadonlyArray<{ readonly id: number; readonly commentCount: number; readonly score: number; readonly createdAt: number; readonly repository: { - 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 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 }; + readonly vote: { readonly vote_value: number }; + readonly postedBy: { readonly html_url: string; readonly login: string }; } | null> | null; }; export type SubmitRepositoryMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; -export type SubmitRepositoryMutation = { - readonly __typename?: 'Mutation'; - readonly submitRepository?: { readonly __typename?: 'Entry'; readonly createdAt: number } | null; -}; +export type SubmitRepositoryMutation = { readonly submitRepository: { readonly createdAt: number } | null }; export type RepoInfoFragment = { - readonly __typename?: 'Entry'; 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 }; + readonly postedBy: { readonly html_url: string; readonly login: string }; }; export type SubmitCommentMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; - commentContent: Scalars['String']['input']; + repoFullName: string; + commentContent: string; }>; export type SubmitCommentMutation = { - readonly __typename?: 'Mutation'; - readonly submitComment?: { - readonly __typename?: 'Comment'; + readonly submitComment: { readonly id: number; readonly createdAt: number; readonly content: string; - readonly postedBy: { readonly __typename?: 'User'; readonly login: string; readonly html_url: string }; + readonly postedBy: { readonly login: string; readonly html_url: string }; } | null; }; -export type VoteButtonsFragment = { - readonly __typename?: 'Entry'; - readonly score: number; - readonly vote: { readonly __typename?: 'Vote'; readonly vote_value: number }; -}; +export type VoteButtonsFragment = { readonly score: number; readonly vote: { readonly vote_value: number } }; export type VoteMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; type: VoteType; }>; export type VoteMutation = { - readonly __typename?: 'Mutation'; - readonly vote?: { - readonly __typename?: 'Entry'; - readonly score: number; - readonly id: number; - readonly vote: { readonly __typename?: 'Vote'; readonly vote_value: number }; - } | null; + readonly vote: { readonly score: number; readonly id: number; readonly vote: { readonly vote_value: number } } | null; }; diff --git a/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts b/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts index cdda2177e51..87793fe2a3f 100644 --- a/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts +++ b/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts @@ -1,77 +1,40 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A list of options for the sort order of the feed */ -export enum FeedType { - /** Sort by a combination of freshness and score, using Reddit's algorithm */ - Hot = 'HOT', - /** Newest entries first */ - New = 'NEW', - /** Highest score entries first */ - Top = 'TOP', -} - -/** The type of vote to record, when submitting a vote */ -export enum VoteType { - Cancel = 'CANCEL', - Down = 'DOWN', - Up = 'UP', -} - export type OnCommentAddedSubscriptionVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; export type OnCommentAddedSubscription = { - __typename?: 'Subscription'; - commentAdded?: { - __typename?: 'Comment'; + commentAdded: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; export type CommentQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - limit?: InputMaybe; - offset?: InputMaybe; + repoFullName: string; + limit?: number | null; + offset?: number | null; }>; export type CommentQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { - __typename?: 'Entry'; + currentUser: { login: string; html_url: string } | null; + entry: { id: number; createdAt: number; commentCount: number; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; comments: Array<{ - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | 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; @@ -80,117 +43,90 @@ export type CommentQuery = { }; export type CommentsPageCommentFragment = { - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; }; export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never }>; -export type CurrentUserForProfileQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; -}; +export type CurrentUserForProfileQuery = { currentUser: { login: string; avatar_url: string } | null }; export type FeedEntryFragment = { - __typename?: 'Entry'; id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; }; export type FeedQueryVariables = Exact<{ type: FeedType; - offset?: InputMaybe; - limit?: InputMaybe; + offset?: number | null; + limit?: number | null; }>; export type FeedQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ - __typename?: 'Entry'; + currentUser: { login: string } | null; + feed: Array<{ id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; } | null> | null; }; export type SubmitRepositoryMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; -export type SubmitRepositoryMutation = { - __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; -}; +export type SubmitRepositoryMutation = { submitRepository: { createdAt: number } | null }; export type RepoInfoFragment = { - __typename?: 'Entry'; createdAt: number; - repository: { - __typename?: 'Repository'; - description?: string | null; - stargazers_count: number; - open_issues_count?: number | null; - }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + repository: { description: string | null; stargazers_count: number; open_issues_count: number | null }; + postedBy: { html_url: string; login: string }; }; export type SubmitCommentMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; - commentContent: Scalars['String']['input']; + repoFullName: string; + commentContent: string; }>; export type SubmitCommentMutation = { - __typename?: 'Mutation'; - submitComment?: { - __typename?: 'Comment'; + submitComment: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; -export type VoteButtonsFragment = { - __typename?: 'Entry'; - score: number; - vote: { __typename?: 'Vote'; vote_value: number }; -}; +export type VoteButtonsFragment = { score: number; vote: { vote_value: number } }; export type VoteMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; type: VoteType; }>; -export type VoteMutation = { - __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; -}; +export type VoteMutation = { vote: { score: number; id: number; vote: { vote_value: number } } | null }; diff --git a/dev-test/githunt/types.preResolveTypes.ts b/dev-test/githunt/types.preResolveTypes.ts index 91e23917b8c..87793fe2a3f 100644 --- a/dev-test/githunt/types.preResolveTypes.ts +++ b/dev-test/githunt/types.preResolveTypes.ts @@ -1,214 +1,40 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A comment about an entry, submitted by a user */ -export type Comment = { - __typename?: 'Comment'; - /** The text of the comment */ - content: Scalars['String']['output']; - /** A timestamp of when the comment was posted */ - createdAt: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who posted the comment */ - postedBy: User; - /** The repository which this comment is about */ - repoName: Scalars['String']['output']; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type Entry = { - __typename?: 'Entry'; - /** The number of comments posted about this repository */ - commentCount: Scalars['Int']['output']; - /** Comments posted about this repository */ - comments: Array>; - /** A timestamp of when the entry was submitted */ - createdAt: Scalars['Float']['output']; - /** The hot score of this repository */ - hotScore: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who submitted this entry */ - postedBy: User; - /** Information about the repository from GitHub */ - repository: Repository; - /** The score of this repository, upvotes - downvotes */ - score: Scalars['Int']['output']; - /** XXX to be changed */ - vote: Vote; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type EntryCommentsArgs = { - limit?: InputMaybe; - offset?: InputMaybe; -}; - -/** A list of options for the sort order of the feed */ -export enum FeedType { - /** Sort by a combination of freshness and score, using Reddit's algorithm */ - Hot = 'HOT', - /** Newest entries first */ - New = 'NEW', - /** Highest score entries first */ - Top = 'TOP', -} - -export type Mutation = { - __typename?: 'Mutation'; - /** Comment on a repository, returns the new comment */ - submitComment?: Maybe; - /** Submit a new repository, returns the new submission */ - submitRepository?: Maybe; - /** Vote on a repository submission, returns the submission that was voted on */ - vote?: Maybe; -}; - -export type MutationSubmitCommentArgs = { - commentContent: Scalars['String']['input']; - repoFullName: Scalars['String']['input']; -}; - -export type MutationSubmitRepositoryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type MutationVoteArgs = { - repoFullName: Scalars['String']['input']; - type: VoteType; -}; - -export type Query = { - __typename?: 'Query'; - /** Return the currently logged in user, or null if nobody is logged in */ - currentUser?: Maybe; - /** A single entry */ - entry?: Maybe; - /** A feed of repository submissions */ - feed?: Maybe>>; -}; - -export type QueryEntryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type QueryFeedArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - type: FeedType; -}; - -/** - * A repository object from the GitHub API. This uses the exact field names returned by the - * GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. - */ -export type Repository = { - __typename?: 'Repository'; - /** The description of the repository */ - description?: Maybe; - /** The full name of the repository with the username, e.g. apollostack/GitHunt-API */ - full_name: Scalars['String']['output']; - /** The link to the repository on GitHub */ - html_url: Scalars['String']['output']; - /** Just the name of the repository, e.g. GitHunt-API */ - name: Scalars['String']['output']; - /** The number of open issues on this repository on GitHub */ - open_issues_count?: Maybe; - /** The owner of this repository on GitHub, e.g. apollostack */ - owner?: Maybe; - /** The number of people who have starred this repository on GitHub */ - stargazers_count: Scalars['Int']['output']; -}; - -export type Subscription = { - __typename?: 'Subscription'; - /** Subscription fires on every comment added */ - commentAdded?: Maybe; -}; - -export type SubscriptionCommentAddedArgs = { - repoFullName: Scalars['String']['input']; -}; - -/** A user object from the GitHub API. This uses the exact field names returned from the GitHub API. */ -export type User = { - __typename?: 'User'; - /** The URL to a directly embeddable image for this user's avatar */ - avatar_url: Scalars['String']['output']; - /** The URL of this user's GitHub page */ - html_url: Scalars['String']['output']; - /** The name of the user, e.g. apollostack */ - login: Scalars['String']['output']; -}; - -/** XXX to be removed */ -export type Vote = { - __typename?: 'Vote'; - vote_value: Scalars['Int']['output']; -}; - -/** The type of vote to record, when submitting a vote */ -export enum VoteType { - Cancel = 'CANCEL', - Down = 'DOWN', - Up = 'UP', -} - export type OnCommentAddedSubscriptionVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; export type OnCommentAddedSubscription = { - __typename?: 'Subscription'; - commentAdded?: { - __typename?: 'Comment'; + commentAdded: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; export type CommentQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - limit?: InputMaybe; - offset?: InputMaybe; + repoFullName: string; + limit?: number | null; + offset?: number | null; }>; export type CommentQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { - __typename?: 'Entry'; + currentUser: { login: string; html_url: string } | null; + entry: { id: number; createdAt: number; commentCount: number; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; comments: Array<{ - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | 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; @@ -217,117 +43,90 @@ export type CommentQuery = { }; export type CommentsPageCommentFragment = { - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; }; export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never }>; -export type CurrentUserForProfileQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; -}; +export type CurrentUserForProfileQuery = { currentUser: { login: string; avatar_url: string } | null }; export type FeedEntryFragment = { - __typename?: 'Entry'; id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; }; export type FeedQueryVariables = Exact<{ type: FeedType; - offset?: InputMaybe; - limit?: InputMaybe; + offset?: number | null; + limit?: number | null; }>; export type FeedQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ - __typename?: 'Entry'; + currentUser: { login: string } | null; + feed: Array<{ id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; } | null> | null; }; export type SubmitRepositoryMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; -export type SubmitRepositoryMutation = { - __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; -}; +export type SubmitRepositoryMutation = { submitRepository: { createdAt: number } | null }; export type RepoInfoFragment = { - __typename?: 'Entry'; createdAt: number; - repository: { - __typename?: 'Repository'; - description?: string | null; - stargazers_count: number; - open_issues_count?: number | null; - }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + repository: { description: string | null; stargazers_count: number; open_issues_count: number | null }; + postedBy: { html_url: string; login: string }; }; export type SubmitCommentMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; - commentContent: Scalars['String']['input']; + repoFullName: string; + commentContent: string; }>; export type SubmitCommentMutation = { - __typename?: 'Mutation'; - submitComment?: { - __typename?: 'Comment'; + submitComment: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; -export type VoteButtonsFragment = { - __typename?: 'Entry'; - score: number; - vote: { __typename?: 'Vote'; vote_value: number }; -}; +export type VoteButtonsFragment = { score: number; vote: { vote_value: number } }; export type VoteMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; type: VoteType; }>; -export type VoteMutation = { - __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; -}; +export type VoteMutation = { vote: { score: number; id: number; vote: { vote_value: number } } | null }; diff --git a/dev-test/githunt/types.ts b/dev-test/githunt/types.ts index 91e23917b8c..87793fe2a3f 100644 --- a/dev-test/githunt/types.ts +++ b/dev-test/githunt/types.ts @@ -1,214 +1,40 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A comment about an entry, submitted by a user */ -export type Comment = { - __typename?: 'Comment'; - /** The text of the comment */ - content: Scalars['String']['output']; - /** A timestamp of when the comment was posted */ - createdAt: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who posted the comment */ - postedBy: User; - /** The repository which this comment is about */ - repoName: Scalars['String']['output']; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type Entry = { - __typename?: 'Entry'; - /** The number of comments posted about this repository */ - commentCount: Scalars['Int']['output']; - /** Comments posted about this repository */ - comments: Array>; - /** A timestamp of when the entry was submitted */ - createdAt: Scalars['Float']['output']; - /** The hot score of this repository */ - hotScore: Scalars['Float']['output']; - /** The SQL ID of this entry */ - id: Scalars['Int']['output']; - /** The GitHub user who submitted this entry */ - postedBy: User; - /** Information about the repository from GitHub */ - repository: Repository; - /** The score of this repository, upvotes - downvotes */ - score: Scalars['Int']['output']; - /** XXX to be changed */ - vote: Vote; -}; - -/** Information about a GitHub repository submitted to GitHunt */ -export type EntryCommentsArgs = { - limit?: InputMaybe; - offset?: InputMaybe; -}; - -/** A list of options for the sort order of the feed */ -export enum FeedType { - /** Sort by a combination of freshness and score, using Reddit's algorithm */ - Hot = 'HOT', - /** Newest entries first */ - New = 'NEW', - /** Highest score entries first */ - Top = 'TOP', -} - -export type Mutation = { - __typename?: 'Mutation'; - /** Comment on a repository, returns the new comment */ - submitComment?: Maybe; - /** Submit a new repository, returns the new submission */ - submitRepository?: Maybe; - /** Vote on a repository submission, returns the submission that was voted on */ - vote?: Maybe; -}; - -export type MutationSubmitCommentArgs = { - commentContent: Scalars['String']['input']; - repoFullName: Scalars['String']['input']; -}; - -export type MutationSubmitRepositoryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type MutationVoteArgs = { - repoFullName: Scalars['String']['input']; - type: VoteType; -}; - -export type Query = { - __typename?: 'Query'; - /** Return the currently logged in user, or null if nobody is logged in */ - currentUser?: Maybe; - /** A single entry */ - entry?: Maybe; - /** A feed of repository submissions */ - feed?: Maybe>>; -}; - -export type QueryEntryArgs = { - repoFullName: Scalars['String']['input']; -}; - -export type QueryFeedArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - type: FeedType; -}; - -/** - * A repository object from the GitHub API. This uses the exact field names returned by the - * GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. - */ -export type Repository = { - __typename?: 'Repository'; - /** The description of the repository */ - description?: Maybe; - /** The full name of the repository with the username, e.g. apollostack/GitHunt-API */ - full_name: Scalars['String']['output']; - /** The link to the repository on GitHub */ - html_url: Scalars['String']['output']; - /** Just the name of the repository, e.g. GitHunt-API */ - name: Scalars['String']['output']; - /** The number of open issues on this repository on GitHub */ - open_issues_count?: Maybe; - /** The owner of this repository on GitHub, e.g. apollostack */ - owner?: Maybe; - /** The number of people who have starred this repository on GitHub */ - stargazers_count: Scalars['Int']['output']; -}; - -export type Subscription = { - __typename?: 'Subscription'; - /** Subscription fires on every comment added */ - commentAdded?: Maybe; -}; - -export type SubscriptionCommentAddedArgs = { - repoFullName: Scalars['String']['input']; -}; - -/** A user object from the GitHub API. This uses the exact field names returned from the GitHub API. */ -export type User = { - __typename?: 'User'; - /** The URL to a directly embeddable image for this user's avatar */ - avatar_url: Scalars['String']['output']; - /** The URL of this user's GitHub page */ - html_url: Scalars['String']['output']; - /** The name of the user, e.g. apollostack */ - login: Scalars['String']['output']; -}; - -/** XXX to be removed */ -export type Vote = { - __typename?: 'Vote'; - vote_value: Scalars['Int']['output']; -}; - -/** The type of vote to record, when submitting a vote */ -export enum VoteType { - Cancel = 'CANCEL', - Down = 'DOWN', - Up = 'UP', -} - export type OnCommentAddedSubscriptionVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; export type OnCommentAddedSubscription = { - __typename?: 'Subscription'; - commentAdded?: { - __typename?: 'Comment'; + commentAdded: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; export type CommentQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - limit?: InputMaybe; - offset?: InputMaybe; + repoFullName: string; + limit?: number | null; + offset?: number | null; }>; export type CommentQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; html_url: string } | null; - entry?: { - __typename?: 'Entry'; + currentUser: { login: string; html_url: string } | null; + entry: { id: number; createdAt: number; commentCount: number; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; comments: Array<{ - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | 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; @@ -217,117 +43,90 @@ export type CommentQuery = { }; export type CommentsPageCommentFragment = { - __typename?: 'Comment'; id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; }; export type CurrentUserForProfileQueryVariables = Exact<{ [key: string]: never }>; -export type CurrentUserForProfileQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string; avatar_url: string } | null; -}; +export type CurrentUserForProfileQuery = { currentUser: { login: string; avatar_url: string } | null }; export type FeedEntryFragment = { - __typename?: 'Entry'; id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; }; export type FeedQueryVariables = Exact<{ type: FeedType; - offset?: InputMaybe; - limit?: InputMaybe; + offset?: number | null; + limit?: number | null; }>; export type FeedQuery = { - __typename?: 'Query'; - currentUser?: { __typename?: 'User'; login: string } | null; - feed?: Array<{ - __typename?: 'Entry'; + currentUser: { login: string } | null; + feed: Array<{ id: number; commentCount: number; score: number; createdAt: number; repository: { - __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: { avatar_url: string } | null; }; - vote: { __typename?: 'Vote'; vote_value: number }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + vote: { vote_value: number }; + postedBy: { html_url: string; login: string }; } | null> | null; }; export type SubmitRepositoryMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; }>; -export type SubmitRepositoryMutation = { - __typename?: 'Mutation'; - submitRepository?: { __typename?: 'Entry'; createdAt: number } | null; -}; +export type SubmitRepositoryMutation = { submitRepository: { createdAt: number } | null }; export type RepoInfoFragment = { - __typename?: 'Entry'; createdAt: number; - repository: { - __typename?: 'Repository'; - description?: string | null; - stargazers_count: number; - open_issues_count?: number | null; - }; - postedBy: { __typename?: 'User'; html_url: string; login: string }; + repository: { description: string | null; stargazers_count: number; open_issues_count: number | null }; + postedBy: { html_url: string; login: string }; }; export type SubmitCommentMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; - commentContent: Scalars['String']['input']; + repoFullName: string; + commentContent: string; }>; export type SubmitCommentMutation = { - __typename?: 'Mutation'; - submitComment?: { - __typename?: 'Comment'; + submitComment: { id: number; createdAt: number; content: string; - postedBy: { __typename?: 'User'; login: string; html_url: string }; + postedBy: { login: string; html_url: string }; } | null; }; -export type VoteButtonsFragment = { - __typename?: 'Entry'; - score: number; - vote: { __typename?: 'Vote'; vote_value: number }; -}; +export type VoteButtonsFragment = { score: number; vote: { vote_value: number } }; export type VoteMutationVariables = Exact<{ - repoFullName: Scalars['String']['input']; + repoFullName: string; type: VoteType; }>; -export type VoteMutation = { - __typename?: 'Mutation'; - vote?: { __typename?: 'Entry'; score: number; id: number; vote: { __typename?: 'Vote'; vote_value: number } } | null; -}; +export type VoteMutation = { vote: { score: number; id: number; 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 e6727b1c25f..f46c9c6e7b7 100644 --- a/dev-test/gql-tag-operations-masking/gql/graphql.ts +++ b/dev-test/gql-tag-operations-masking/gql/graphql.ts @@ -1,134 +1,22 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; - Date: { input: any; output: any }; - Url: { input: any; output: any }; -}; - -export type Meta = { - __typename?: 'Meta'; - count?: Maybe; -}; - -export type Mutation = { - __typename?: 'Mutation'; - createTweet?: Maybe; - deleteTweet?: Maybe; - markTweetRead?: Maybe; -}; - -export type MutationCreateTweetArgs = { - body?: InputMaybe; -}; - -export type MutationDeleteTweetArgs = { - id: Scalars['ID']['input']; -}; - -export type MutationMarkTweetReadArgs = { - id: Scalars['ID']['input']; -}; - -export type Notification = { - __typename?: 'Notification'; - date?: Maybe; - id?: Maybe; - type?: Maybe; -}; - -export type Query = { - __typename?: 'Query'; - Notifications?: Maybe>>; - NotificationsMeta?: Maybe; - Tweet?: Maybe; - Tweets?: Maybe>; - TweetsMeta?: Maybe; - User?: Maybe; -}; - -export type QueryNotificationsArgs = { - limit?: InputMaybe; -}; - -export type QueryTweetArgs = { - id: Scalars['ID']['input']; -}; - -export type QueryTweetsArgs = { - limit?: InputMaybe; - skip?: InputMaybe; - sort_field?: InputMaybe; - sort_order?: InputMaybe; -}; - -export type QueryUserArgs = { - id: Scalars['ID']['input']; -}; - -export type Stat = { - __typename?: 'Stat'; - likes?: Maybe; - responses?: Maybe; - retweets?: Maybe; - views?: Maybe; -}; - -export type Tweet = { - __typename?: 'Tweet'; - Stats?: Maybe; - author: User; - body: Scalars['String']['output']; - date?: Maybe; - id: Scalars['ID']['output']; -}; - -export type User = { - __typename?: 'User'; - avatar_url?: Maybe; - first_name?: Maybe; - full_name?: Maybe; - id: Scalars['ID']['output']; - last_name?: Maybe; - /** @deprecated Field no longer supported */ - name?: Maybe; - username?: Maybe; -}; - -export type TweetFragmentFragment = ({ __typename?: 'Tweet'; id: string; body: string } & { +export type TweetFragmentFragment = ({ id: string; body: string } & { ' $fragmentRefs'?: { TweetAuthorFragmentFragment: TweetAuthorFragmentFragment }; }) & { ' $fragmentName'?: 'TweetFragmentFragment' }; -export type TweetAuthorFragmentFragment = { - __typename?: 'Tweet'; - id: string; - author: { __typename?: 'User'; id: string; username?: string | null }; -} & { ' $fragmentName'?: 'TweetAuthorFragmentFragment' }; +export type TweetAuthorFragmentFragment = { id: string; author: { id: string; username: string | null } } & { + ' $fragmentName'?: 'TweetAuthorFragmentFragment'; +}; export type TweetsFragmentFragment = { - __typename?: 'Query'; - Tweets?: Array< - { __typename?: 'Tweet'; id: string } & { ' $fragmentRefs'?: { TweetFragmentFragment: TweetFragmentFragment } } - > | null; + Tweets: Array<{ id: string } & { ' $fragmentRefs'?: { TweetFragmentFragment: TweetFragmentFragment } }> | null; } & { ' $fragmentName'?: 'TweetsFragmentFragment' }; export type TweetAppQueryQueryVariables = Exact<{ [key: string]: never }>; -export type TweetAppQueryQuery = { __typename?: 'Query' } & { - ' $fragmentRefs'?: { TweetsFragmentFragment: TweetsFragmentFragment }; -}; +export type TweetAppQueryQuery = { ' $fragmentRefs'?: { TweetsFragmentFragment: TweetsFragmentFragment } }; export const TweetAuthorFragmentFragmentDoc = { kind: 'Document', diff --git a/dev-test/gql-tag-operations-urql/gql/graphql.ts b/dev-test/gql-tag-operations-urql/gql/graphql.ts index 9b8455d245e..addcd45db1c 100644 --- a/dev-test/gql-tag-operations-urql/gql/graphql.ts +++ b/dev-test/gql-tag-operations-urql/gql/graphql.ts @@ -1,126 +1,16 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; - Date: { input: any; output: any }; - Url: { input: any; output: any }; -}; - -export type Meta = { - __typename?: 'Meta'; - count?: Maybe; -}; - -export type Mutation = { - __typename?: 'Mutation'; - createTweet?: Maybe; - deleteTweet?: Maybe; - markTweetRead?: Maybe; -}; - -export type MutationCreateTweetArgs = { - body?: InputMaybe; -}; - -export type MutationDeleteTweetArgs = { - id: Scalars['ID']['input']; -}; - -export type MutationMarkTweetReadArgs = { - id: Scalars['ID']['input']; -}; - -export type Notification = { - __typename?: 'Notification'; - date?: Maybe; - id?: Maybe; - type?: Maybe; -}; - -export type Query = { - __typename?: 'Query'; - Notifications?: Maybe>>; - NotificationsMeta?: Maybe; - Tweet?: Maybe; - Tweets?: Maybe>>; - TweetsMeta?: Maybe; - User?: Maybe; -}; - -export type QueryNotificationsArgs = { - limit?: InputMaybe; -}; - -export type QueryTweetArgs = { - id: Scalars['ID']['input']; -}; - -export type QueryTweetsArgs = { - limit?: InputMaybe; - skip?: InputMaybe; - sort_field?: InputMaybe; - sort_order?: InputMaybe; -}; - -export type QueryUserArgs = { - id: Scalars['ID']['input']; -}; - -export type Stat = { - __typename?: 'Stat'; - likes?: Maybe; - responses?: Maybe; - retweets?: Maybe; - views?: Maybe; -}; - -export type Tweet = { - __typename?: 'Tweet'; - Author?: Maybe; - Stats?: Maybe; - body?: Maybe; - date?: Maybe; - id: Scalars['ID']['output']; -}; - -export type User = { - __typename?: 'User'; - avatar_url?: Maybe; - first_name?: Maybe; - full_name?: Maybe; - id: Scalars['ID']['output']; - last_name?: Maybe; - /** @deprecated Field no longer supported */ - name?: Maybe; - username?: Maybe; -}; - export type FooQueryVariables = Exact<{ [key: string]: never }>; -export type FooQuery = { __typename?: 'Query'; Tweets?: Array<{ __typename?: 'Tweet'; id: string } | null> | null }; +export type FooQuery = { Tweets: Array<{ id: string } | null> | null }; -export type LelFragment = { __typename?: 'Tweet'; id: string; body?: string | null } & { - ' $fragmentName'?: 'LelFragment'; -}; +export type LelFragment = { id: string; body: string | null } & { ' $fragmentName'?: 'LelFragment' }; export type BarQueryVariables = Exact<{ [key: string]: never }>; -export type BarQuery = { - __typename?: 'Query'; - Tweets?: Array<({ __typename?: 'Tweet' } & { ' $fragmentRefs'?: { LelFragment: LelFragment } }) | null> | null; -}; +export type BarQuery = { Tweets: Array<{ ' $fragmentRefs'?: { LelFragment: LelFragment } } | null> | null }; export const LelFragmentDoc = { kind: 'Document', diff --git a/dev-test/gql-tag-operations/gql/graphql.ts b/dev-test/gql-tag-operations/gql/graphql.ts index 9b8455d245e..addcd45db1c 100644 --- a/dev-test/gql-tag-operations/gql/graphql.ts +++ b/dev-test/gql-tag-operations/gql/graphql.ts @@ -1,126 +1,16 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; - Date: { input: any; output: any }; - Url: { input: any; output: any }; -}; - -export type Meta = { - __typename?: 'Meta'; - count?: Maybe; -}; - -export type Mutation = { - __typename?: 'Mutation'; - createTweet?: Maybe; - deleteTweet?: Maybe; - markTweetRead?: Maybe; -}; - -export type MutationCreateTweetArgs = { - body?: InputMaybe; -}; - -export type MutationDeleteTweetArgs = { - id: Scalars['ID']['input']; -}; - -export type MutationMarkTweetReadArgs = { - id: Scalars['ID']['input']; -}; - -export type Notification = { - __typename?: 'Notification'; - date?: Maybe; - id?: Maybe; - type?: Maybe; -}; - -export type Query = { - __typename?: 'Query'; - Notifications?: Maybe>>; - NotificationsMeta?: Maybe; - Tweet?: Maybe; - Tweets?: Maybe>>; - TweetsMeta?: Maybe; - User?: Maybe; -}; - -export type QueryNotificationsArgs = { - limit?: InputMaybe; -}; - -export type QueryTweetArgs = { - id: Scalars['ID']['input']; -}; - -export type QueryTweetsArgs = { - limit?: InputMaybe; - skip?: InputMaybe; - sort_field?: InputMaybe; - sort_order?: InputMaybe; -}; - -export type QueryUserArgs = { - id: Scalars['ID']['input']; -}; - -export type Stat = { - __typename?: 'Stat'; - likes?: Maybe; - responses?: Maybe; - retweets?: Maybe; - views?: Maybe; -}; - -export type Tweet = { - __typename?: 'Tweet'; - Author?: Maybe; - Stats?: Maybe; - body?: Maybe; - date?: Maybe; - id: Scalars['ID']['output']; -}; - -export type User = { - __typename?: 'User'; - avatar_url?: Maybe; - first_name?: Maybe; - full_name?: Maybe; - id: Scalars['ID']['output']; - last_name?: Maybe; - /** @deprecated Field no longer supported */ - name?: Maybe; - username?: Maybe; -}; - export type FooQueryVariables = Exact<{ [key: string]: never }>; -export type FooQuery = { __typename?: 'Query'; Tweets?: Array<{ __typename?: 'Tweet'; id: string } | null> | null }; +export type FooQuery = { Tweets: Array<{ id: string } | null> | null }; -export type LelFragment = { __typename?: 'Tweet'; id: string; body?: string | null } & { - ' $fragmentName'?: 'LelFragment'; -}; +export type LelFragment = { id: string; body: string | null } & { ' $fragmentName'?: 'LelFragment' }; export type BarQueryVariables = Exact<{ [key: string]: never }>; -export type BarQuery = { - __typename?: 'Query'; - Tweets?: Array<({ __typename?: 'Tweet' } & { ' $fragmentRefs'?: { LelFragment: LelFragment } }) | null> | null; -}; +export type BarQuery = { Tweets: Array<{ ' $fragmentRefs'?: { LelFragment: LelFragment } } | null> | null }; export const LelFragmentDoc = { kind: 'Document', diff --git a/dev-test/gql-tag-operations/graphql/graphql.ts b/dev-test/gql-tag-operations/graphql/graphql.ts index 9b8455d245e..addcd45db1c 100644 --- a/dev-test/gql-tag-operations/graphql/graphql.ts +++ b/dev-test/gql-tag-operations/graphql/graphql.ts @@ -1,126 +1,16 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; - Date: { input: any; output: any }; - Url: { input: any; output: any }; -}; - -export type Meta = { - __typename?: 'Meta'; - count?: Maybe; -}; - -export type Mutation = { - __typename?: 'Mutation'; - createTweet?: Maybe; - deleteTweet?: Maybe; - markTweetRead?: Maybe; -}; - -export type MutationCreateTweetArgs = { - body?: InputMaybe; -}; - -export type MutationDeleteTweetArgs = { - id: Scalars['ID']['input']; -}; - -export type MutationMarkTweetReadArgs = { - id: Scalars['ID']['input']; -}; - -export type Notification = { - __typename?: 'Notification'; - date?: Maybe; - id?: Maybe; - type?: Maybe; -}; - -export type Query = { - __typename?: 'Query'; - Notifications?: Maybe>>; - NotificationsMeta?: Maybe; - Tweet?: Maybe; - Tweets?: Maybe>>; - TweetsMeta?: Maybe; - User?: Maybe; -}; - -export type QueryNotificationsArgs = { - limit?: InputMaybe; -}; - -export type QueryTweetArgs = { - id: Scalars['ID']['input']; -}; - -export type QueryTweetsArgs = { - limit?: InputMaybe; - skip?: InputMaybe; - sort_field?: InputMaybe; - sort_order?: InputMaybe; -}; - -export type QueryUserArgs = { - id: Scalars['ID']['input']; -}; - -export type Stat = { - __typename?: 'Stat'; - likes?: Maybe; - responses?: Maybe; - retweets?: Maybe; - views?: Maybe; -}; - -export type Tweet = { - __typename?: 'Tweet'; - Author?: Maybe; - Stats?: Maybe; - body?: Maybe; - date?: Maybe; - id: Scalars['ID']['output']; -}; - -export type User = { - __typename?: 'User'; - avatar_url?: Maybe; - first_name?: Maybe; - full_name?: Maybe; - id: Scalars['ID']['output']; - last_name?: Maybe; - /** @deprecated Field no longer supported */ - name?: Maybe; - username?: Maybe; -}; - export type FooQueryVariables = Exact<{ [key: string]: never }>; -export type FooQuery = { __typename?: 'Query'; Tweets?: Array<{ __typename?: 'Tweet'; id: string } | null> | null }; +export type FooQuery = { Tweets: Array<{ id: string } | null> | null }; -export type LelFragment = { __typename?: 'Tweet'; id: string; body?: string | null } & { - ' $fragmentName'?: 'LelFragment'; -}; +export type LelFragment = { id: string; body: string | null } & { ' $fragmentName'?: 'LelFragment' }; export type BarQueryVariables = Exact<{ [key: string]: never }>; -export type BarQuery = { - __typename?: 'Query'; - Tweets?: Array<({ __typename?: 'Tweet' } & { ' $fragmentRefs'?: { LelFragment: LelFragment } }) | null> | null; -}; +export type BarQuery = { Tweets: Array<{ ' $fragmentRefs'?: { LelFragment: LelFragment } } | null> | null }; export const LelFragmentDoc = { kind: 'Document', diff --git a/dev-test/modules/types.ts b/dev-test/modules/types.ts index f516a7e65c6..45e27248ff8 100644 --- a/dev-test/modules/types.ts +++ b/dev-test/modules/types.ts @@ -1,7 +1,6 @@ import { GraphQLResolveInfo } from 'graphql'; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/standalone-operations/import-schema-types/_base.generated.ts b/dev-test/standalone-operations/import-schema-types/_base.generated.ts new file mode 100644 index 00000000000..8df53ac5f67 --- /dev/null +++ b/dev-test/standalone-operations/import-schema-types/_base.generated.ts @@ -0,0 +1,6 @@ +/** UserRole Description */ +export type UserRole = + /** UserRole ADMIN */ + | 'ADMIN' + /** UserRole CUSTOMER */ + | 'CUSTOMER'; diff --git a/dev-test/standalone-operations/import-schema-types/_types.generated.ts b/dev-test/standalone-operations/import-schema-types/_types.generated.ts new file mode 100644 index 00000000000..e2b362b410c --- /dev/null +++ b/dev-test/standalone-operations/import-schema-types/_types.generated.ts @@ -0,0 +1,9 @@ +import type * as Types from './_base.generated'; + +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 WithVariablesQueryVariables = Exact<{ + role?: Types.UserRole | null; +}>; + +export type WithVariablesQuery = { user: { id: string; name: string } | null }; diff --git a/dev-test/standalone-operations/import-schema-types/query.graphql b/dev-test/standalone-operations/import-schema-types/query.graphql new file mode 100644 index 00000000000..e8de0b4506d --- /dev/null +++ b/dev-test/standalone-operations/import-schema-types/query.graphql @@ -0,0 +1,6 @@ +query WithVariables($role: UserRole) { + user(id: "100") { + id + name + } +} diff --git a/dev-test/standalone-operations/schema.graphql b/dev-test/standalone-operations/schema.graphql new file mode 100644 index 00000000000..2fd2cb04bc6 --- /dev/null +++ b/dev-test/standalone-operations/schema.graphql @@ -0,0 +1,17 @@ +type Query { + user(id: ID!, role: UserRole): User +} + +type User { + id: ID! + name: String! + role: UserRole! +} + +"UserRole Description" +enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER +} diff --git a/dev-test/star-wars/types.avoidOptionals.ts b/dev-test/star-wars/types.avoidOptionals.ts index 02b567a168e..5108083b866 100644 --- a/dev-test/star-wars/types.avoidOptionals.ts +++ b/dev-test/star-wars/types.avoidOptionals.ts @@ -1,408 +1,120 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A character from the Star Wars universe */ -export type Character = { - /** The movies this character appears in */ - appearsIn: Array>; - /** The friends of the character, or an empty list if they have none */ - friends: Maybe>>; - /** The friends of the character exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the character */ - id: Scalars['ID']['output']; - /** The name of the character */ - name: Scalars['String']['output']; -}; - -/** A character from the Star Wars universe */ -export type CharacterFriendsConnectionArgs = { - after: InputMaybe; - first: InputMaybe; -}; - -/** The input object sent when passing a color */ -export type ColorInput = { - blue: Scalars['Int']['input']; - green: Scalars['Int']['input']; - red: Scalars['Int']['input']; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type Droid = Character & { - __typename?: 'Droid'; - /** The movies this droid appears in */ - appearsIn: Array>; - /** This droid's friends, or an empty list if they have none */ - friends: Maybe>>; - /** The friends of the droid exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the droid */ - id: Scalars['ID']['output']; - /** What others call this droid */ - name: Scalars['String']['output']; - /** This droid's primary function */ - primaryFunction: Maybe; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type DroidFriendsConnectionArgs = { - after: InputMaybe; - first: InputMaybe; -}; - /** The episodes in the Star Wars trilogy */ -export enum Episode { +export type Episode = /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ - Empire = 'EMPIRE', + | 'EMPIRE' /** Star Wars Episode VI: Return of the Jedi, released in 1983. */ - Jedi = 'JEDI', + | 'JEDI' /** Star Wars Episode IV: A New Hope, released in 1977. */ - Newhope = 'NEWHOPE', -} - -/** A connection object for a character's friends */ -export type FriendsConnection = { - __typename?: 'FriendsConnection'; - /** The edges for each of the character's friends. */ - edges: Maybe>>; - /** A list of the friends, as a convenience when edges are not needed. */ - friends: Maybe>>; - /** Information for paginating this connection */ - pageInfo: PageInfo; - /** The total number of friends */ - totalCount: Maybe; -}; - -/** An edge object for a character's friends */ -export type FriendsEdge = { - __typename?: 'FriendsEdge'; - /** A cursor used for pagination */ - cursor: Scalars['ID']['output']; - /** The character represented by this friendship edge */ - node: Maybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type Human = Character & { - __typename?: 'Human'; - /** The movies this human appears in */ - appearsIn: Array>; - /** This human's friends, or an empty list if they have none */ - friends: Maybe>>; - /** The friends of the human exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** Height in the preferred unit, default is meters */ - height: Maybe; - /** The home planet of the human, or null if unknown */ - homePlanet: Maybe; - /** The ID of the human */ - id: Scalars['ID']['output']; - /** Mass in kilograms, or null if unknown */ - mass: Maybe; - /** What this human calls themselves */ - name: Scalars['String']['output']; - /** A list of starships this person has piloted, or an empty list if none */ - starships: Maybe>>; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanFriendsConnectionArgs = { - after: InputMaybe; - first: InputMaybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanHeightArgs = { - unit?: InputMaybe; -}; - -/** Units of height */ -export enum LengthUnit { - /** Primarily used in the United States */ - Foot = 'FOOT', - /** The standard unit around the world */ - Meter = 'METER', -} - -/** The mutation type, represents all updates we can make to our data */ -export type Mutation = { - __typename?: 'Mutation'; - createReview: Maybe; -}; - -/** The mutation type, represents all updates we can make to our data */ -export type MutationCreateReviewArgs = { - episode: InputMaybe; - review: ReviewInput; -}; - -/** Information for paginating this connection */ -export type PageInfo = { - __typename?: 'PageInfo'; - endCursor: Maybe; - hasNextPage: Scalars['Boolean']['output']; - startCursor: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type Query = { - __typename?: 'Query'; - character: Maybe; - droid: Maybe; - hero: Maybe; - human: Maybe; - reviews: Maybe>>; - search: Maybe>>; - starship: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryCharacterArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryDroidArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHeroArgs = { - episode: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHumanArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryReviewsArgs = { - episode: Episode; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QuerySearchArgs = { - text: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryStarshipArgs = { - id: Scalars['ID']['input']; -}; - -/** Represents a review for a movie */ -export type Review = { - __typename?: 'Review'; - /** Comment about the movie */ - commentary: Maybe; - /** The number of stars this review gave, 1-5 */ - stars: Scalars['Int']['output']; -}; - -/** The input object sent when someone is creating a new review */ -export type ReviewInput = { - /** Comment about the movie, optional */ - commentary: InputMaybe; - /** Favorite color, optional */ - favoriteColor: InputMaybe; - /** 0-5 stars */ - stars: Scalars['Int']['input']; -}; - -export type SearchResult = Droid | Human | Starship; - -export type Starship = { - __typename?: 'Starship'; - /** The ID of the starship */ - id: Scalars['ID']['output']; - /** Length of the starship, along the longest axis */ - length: Maybe; - /** The name of the starship */ - name: Scalars['String']['output']; -}; - -export type StarshipLengthArgs = { - unit?: InputMaybe; -}; + | 'NEWHOPE'; export type CreateReviewForEpisodeMutationVariables = Exact<{ episode: Episode; review: ReviewInput; }>; -export type CreateReviewForEpisodeMutation = { - __typename?: 'Mutation'; - createReview: { __typename?: 'Review'; stars: number; commentary: string | null } | null; -}; +export type CreateReviewForEpisodeMutation = { createReview: { stars: number; commentary: string | null } | null }; export type ExcludeQueryAlphaQueryVariables = Exact<{ - episode: InputMaybe; + episode: Episode | null; }>; -export type ExcludeQueryAlphaQuery = { - __typename?: 'Query'; - hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryAlphaQuery = { hero: { name: string } | { name: string } | null }; export type ExcludeQueryBetaQueryVariables = Exact<{ - episode: InputMaybe; + episode: Episode | null; }>; -export type ExcludeQueryBetaQuery = { - __typename?: 'Query'; - hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryBetaQuery = { hero: { name: string } | { name: string } | null }; export type HeroAndFriendsNamesQueryVariables = Exact<{ - episode: InputMaybe; + episode: Episode | null; }>; export type HeroAndFriendsNamesQuery = { - __typename?: 'Query'; hero: - | { - __typename?: 'Droid'; - name: string; - 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; - } + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } | null; }; export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { - __typename?: 'Query'; - hero: - | { __typename?: 'Droid'; name: string; appearsIn: Array } - | { __typename?: 'Human'; name: string; appearsIn: Array } - | null; + hero: { name: string; appearsIn: Array } | { name: string; appearsIn: Array } | null; }; export type HeroDetailsQueryVariables = Exact<{ - episode: InputMaybe; + episode: Episode | null; }>; export type HeroDetailsQuery = { - __typename?: 'Query'; - hero: - | { __typename?: 'Droid'; primaryFunction: string | null; name: string } - | { __typename?: 'Human'; height: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction: string | null; name: string }; +type HeroDetails_Droid_Fragment = { primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height: number | null; name: string }; +type HeroDetails_Human_Fragment = { height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; export type HeroDetailsWithFragmentQueryVariables = Exact<{ - episode: InputMaybe; + episode: Episode | null; }>; export type HeroDetailsWithFragmentQuery = { - __typename?: 'Query'; - hero: - | { __typename?: 'Droid'; primaryFunction: string | null; name: string } - | { __typename?: 'Human'; height: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; export type HeroNameQueryVariables = Exact<{ - episode: InputMaybe; + episode: Episode | null; }>; -export type HeroNameQuery = { - __typename?: 'Query'; - hero: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type HeroNameQuery = { hero: { name: string } | { name: string } | null }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ - episode: InputMaybe; - includeName: Scalars['Boolean']['input']; + episode: Episode | null; + includeName: boolean; }>; -export type HeroNameConditionalInclusionQuery = { - __typename?: 'Query'; - hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalInclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ - episode: InputMaybe; - skipName: Scalars['Boolean']['input']; + episode: Episode | null; + skipName: boolean; }>; -export type HeroNameConditionalExclusionQuery = { - __typename?: 'Query'; - hero: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalExclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ - episode: InputMaybe; + episode: Episode | null; }>; export type HeroParentTypeDependentFieldQuery = { - __typename?: 'Query'; hero: - | { - __typename?: 'Droid'; - name: string; - 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 - > | null; - } + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } | null; }; export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ - episode: InputMaybe; + episode: Episode | null; }>; export type HeroTypeDependentAliasedFieldQuery = { - __typename?: 'Query'; - hero: { __typename?: 'Droid'; property: string | null } | { __typename?: 'Human'; property: string | null } | null; + hero: { property: string | null } | { property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass: number | null }; +export type HumanFieldsFragment = { 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; -}; +export type HumanWithNullHeightQuery = { 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: { name: string } | { name: string } | null; + luke: { name: string } | { name: string } | null; }; diff --git a/dev-test/star-wars/types.d.ts b/dev-test/star-wars/types.d.ts index 74b3623a681..0fd39f72102 100644 --- a/dev-test/star-wars/types.d.ts +++ b/dev-test/star-wars/types.d.ts @@ -1,239 +1,2 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A character from the Star Wars universe */ -export type Character = { - /** The movies this character appears in */ - appearsIn: Array>; - /** The friends of the character, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the character exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the character */ - id: Scalars['ID']['output']; - /** The name of the character */ - name: Scalars['String']['output']; -}; - -/** A character from the Star Wars universe */ -export type CharacterFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** The input object sent when passing a color */ -export type ColorInput = { - blue: Scalars['Int']['input']; - green: Scalars['Int']['input']; - red: Scalars['Int']['input']; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type Droid = Character & { - __typename?: 'Droid'; - /** The movies this droid appears in */ - appearsIn: Array>; - /** This droid's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the droid exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the droid */ - id: Scalars['ID']['output']; - /** What others call this droid */ - name: Scalars['String']['output']; - /** This droid's primary function */ - primaryFunction?: Maybe; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type DroidFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** The episodes in the Star Wars trilogy */ -export type Episode = - /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ - | 'EMPIRE' - /** Star Wars Episode VI: Return of the Jedi, released in 1983. */ - | 'JEDI' - /** Star Wars Episode IV: A New Hope, released in 1977. */ - | 'NEWHOPE'; - -/** A connection object for a character's friends */ -export type FriendsConnection = { - __typename?: 'FriendsConnection'; - /** The edges for each of the character's friends. */ - edges?: Maybe>>; - /** A list of the friends, as a convenience when edges are not needed. */ - friends?: Maybe>>; - /** Information for paginating this connection */ - pageInfo: PageInfo; - /** The total number of friends */ - totalCount?: Maybe; -}; - -/** An edge object for a character's friends */ -export type FriendsEdge = { - __typename?: 'FriendsEdge'; - /** A cursor used for pagination */ - cursor: Scalars['ID']['output']; - /** The character represented by this friendship edge */ - node?: Maybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type Human = Character & { - __typename?: 'Human'; - /** The movies this human appears in */ - appearsIn: Array>; - /** This human's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the human exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** Height in the preferred unit, default is meters */ - height?: Maybe; - /** The home planet of the human, or null if unknown */ - homePlanet?: Maybe; - /** The ID of the human */ - id: Scalars['ID']['output']; - /** Mass in kilograms, or null if unknown */ - mass?: Maybe; - /** What this human calls themselves */ - name: Scalars['String']['output']; - /** A list of starships this person has piloted, or an empty list if none */ - starships?: Maybe>>; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanHeightArgs = { - unit?: InputMaybe; -}; - -/** Units of height */ -export type LengthUnit = - /** Primarily used in the United States */ - | 'FOOT' - /** The standard unit around the world */ - | 'METER'; - -/** The mutation type, represents all updates we can make to our data */ -export type Mutation = { - __typename?: 'Mutation'; - createReview?: Maybe; -}; - -/** The mutation type, represents all updates we can make to our data */ -export type MutationCreateReviewArgs = { - episode?: InputMaybe; - review: ReviewInput; -}; - -/** Information for paginating this connection */ -export type PageInfo = { - __typename?: 'PageInfo'; - endCursor?: Maybe; - hasNextPage: Scalars['Boolean']['output']; - startCursor?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type Query = { - __typename?: 'Query'; - character?: Maybe; - droid?: Maybe; - hero?: Maybe; - human?: Maybe; - reviews?: Maybe>>; - search?: Maybe>>; - starship?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryCharacterArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryDroidArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHeroArgs = { - episode?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHumanArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryReviewsArgs = { - episode: Episode; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QuerySearchArgs = { - text?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryStarshipArgs = { - id: Scalars['ID']['input']; -}; - -/** Represents a review for a movie */ -export type Review = { - __typename?: 'Review'; - /** Comment about the movie */ - commentary?: Maybe; - /** The number of stars this review gave, 1-5 */ - stars: Scalars['Int']['output']; -}; - -/** The input object sent when someone is creating a new review */ -export type ReviewInput = { - /** Comment about the movie, optional */ - commentary?: InputMaybe; - /** Favorite color, optional */ - favoriteColor?: InputMaybe; - /** 0-5 stars */ - stars: Scalars['Int']['input']; -}; - -export type SearchResult = Droid | Human | Starship; - -export type Starship = { - __typename?: 'Starship'; - /** The ID of the starship */ - id: Scalars['ID']['output']; - /** Length of the starship, along the longest axis */ - length?: Maybe; - /** The name of the starship */ - name: Scalars['String']['output']; -}; - -export type StarshipLengthArgs = { - unit?: InputMaybe; -}; diff --git a/dev-test/star-wars/types.excludeQueryAlpha.ts b/dev-test/star-wars/types.excludeQueryAlpha.ts index c74b2d6c85e..a7cf9605766 100644 --- a/dev-test/star-wars/types.excludeQueryAlpha.ts +++ b/dev-test/star-wars/types.excludeQueryAlpha.ts @@ -1,399 +1,114 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A character from the Star Wars universe */ -export type Character = { - /** The movies this character appears in */ - appearsIn: Array>; - /** The friends of the character, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the character exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the character */ - id: Scalars['ID']['output']; - /** The name of the character */ - name: Scalars['String']['output']; -}; - -/** A character from the Star Wars universe */ -export type CharacterFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** The input object sent when passing a color */ -export type ColorInput = { - blue: Scalars['Int']['input']; - green: Scalars['Int']['input']; - red: Scalars['Int']['input']; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type Droid = Character & { - __typename?: 'Droid'; - /** The movies this droid appears in */ - appearsIn: Array>; - /** This droid's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the droid exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the droid */ - id: Scalars['ID']['output']; - /** What others call this droid */ - name: Scalars['String']['output']; - /** This droid's primary function */ - primaryFunction?: Maybe; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type DroidFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - /** The episodes in the Star Wars trilogy */ -export enum Episode { +export type Episode = /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ - Empire = 'EMPIRE', + | 'EMPIRE' /** Star Wars Episode VI: Return of the Jedi, released in 1983. */ - Jedi = 'JEDI', + | 'JEDI' /** Star Wars Episode IV: A New Hope, released in 1977. */ - Newhope = 'NEWHOPE', -} - -/** A connection object for a character's friends */ -export type FriendsConnection = { - __typename?: 'FriendsConnection'; - /** The edges for each of the character's friends. */ - edges?: Maybe>>; - /** A list of the friends, as a convenience when edges are not needed. */ - friends?: Maybe>>; - /** Information for paginating this connection */ - pageInfo: PageInfo; - /** The total number of friends */ - totalCount?: Maybe; -}; - -/** An edge object for a character's friends */ -export type FriendsEdge = { - __typename?: 'FriendsEdge'; - /** A cursor used for pagination */ - cursor: Scalars['ID']['output']; - /** The character represented by this friendship edge */ - node?: Maybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type Human = Character & { - __typename?: 'Human'; - /** The movies this human appears in */ - appearsIn: Array>; - /** This human's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the human exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** Height in the preferred unit, default is meters */ - height?: Maybe; - /** The home planet of the human, or null if unknown */ - homePlanet?: Maybe; - /** The ID of the human */ - id: Scalars['ID']['output']; - /** Mass in kilograms, or null if unknown */ - mass?: Maybe; - /** What this human calls themselves */ - name: Scalars['String']['output']; - /** A list of starships this person has piloted, or an empty list if none */ - starships?: Maybe>>; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanHeightArgs = { - unit?: InputMaybe; -}; - -/** Units of height */ -export enum LengthUnit { - /** Primarily used in the United States */ - Foot = 'FOOT', - /** The standard unit around the world */ - Meter = 'METER', -} - -/** The mutation type, represents all updates we can make to our data */ -export type Mutation = { - __typename?: 'Mutation'; - createReview?: Maybe; -}; - -/** The mutation type, represents all updates we can make to our data */ -export type MutationCreateReviewArgs = { - episode?: InputMaybe; - review: ReviewInput; -}; - -/** Information for paginating this connection */ -export type PageInfo = { - __typename?: 'PageInfo'; - endCursor?: Maybe; - hasNextPage: Scalars['Boolean']['output']; - startCursor?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type Query = { - __typename?: 'Query'; - character?: Maybe; - droid?: Maybe; - hero?: Maybe; - human?: Maybe; - reviews?: Maybe>>; - search?: Maybe>>; - starship?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryCharacterArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryDroidArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHeroArgs = { - episode?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHumanArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryReviewsArgs = { - episode: Episode; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QuerySearchArgs = { - text?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryStarshipArgs = { - id: Scalars['ID']['input']; -}; - -/** Represents a review for a movie */ -export type Review = { - __typename?: 'Review'; - /** Comment about the movie */ - commentary?: Maybe; - /** The number of stars this review gave, 1-5 */ - stars: Scalars['Int']['output']; -}; - -/** The input object sent when someone is creating a new review */ -export type ReviewInput = { - /** Comment about the movie, optional */ - commentary?: InputMaybe; - /** Favorite color, optional */ - favoriteColor?: InputMaybe; - /** 0-5 stars */ - stars: Scalars['Int']['input']; -}; - -export type SearchResult = Droid | Human | Starship; - -export type Starship = { - __typename?: 'Starship'; - /** The ID of the starship */ - id: Scalars['ID']['output']; - /** Length of the starship, along the longest axis */ - length?: Maybe; - /** The name of the starship */ - name: Scalars['String']['output']; -}; - -export type StarshipLengthArgs = { - unit?: InputMaybe; -}; + | 'NEWHOPE'; export type CreateReviewForEpisodeMutationVariables = Exact<{ episode: Episode; review: ReviewInput; }>; -export type CreateReviewForEpisodeMutation = { - __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; -}; +export type CreateReviewForEpisodeMutation = { createReview: { stars: number; commentary: string | null } | null }; export type ExcludeQueryBetaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryBetaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryBetaQuery = { hero: { name: string } | { name: string } | null }; export type HeroAndFriendsNamesQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroAndFriendsNamesQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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; - } + hero: + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } | null; }; export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; name: string; appearsIn: Array } - | { __typename?: 'Human'; name: string; appearsIn: Array } - | null; + hero: { name: string; appearsIn: Array } | { name: string; appearsIn: Array } | null; }; export type HeroDetailsQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; export type HeroDetailsWithFragmentQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsWithFragmentQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; export type HeroNameQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type HeroNameQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type HeroNameQuery = { hero: { name: string } | { name: string } | null }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ - episode?: InputMaybe; - includeName: Scalars['Boolean']['input']; + episode?: Episode | null; + includeName: boolean; }>; -export type HeroNameConditionalInclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalInclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ - episode?: InputMaybe; - skipName: Scalars['Boolean']['input']; + episode?: Episode | null; + skipName: boolean; }>; -export type HeroNameConditionalExclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalExclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroParentTypeDependentFieldQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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 - > | null; - } + hero: + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } | null; }; export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroTypeDependentAliasedFieldQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { property: string | null } | { property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { 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; -}; +export type HumanWithNullHeightQuery = { 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: { name: string } | { name: string } | null; + luke: { name: string } | { name: string } | null; }; diff --git a/dev-test/star-wars/types.excludeQueryBeta.ts b/dev-test/star-wars/types.excludeQueryBeta.ts index 4a8b70efeaa..f0984cce895 100644 --- a/dev-test/star-wars/types.excludeQueryBeta.ts +++ b/dev-test/star-wars/types.excludeQueryBeta.ts @@ -1,399 +1,114 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A character from the Star Wars universe */ -export type Character = { - /** The movies this character appears in */ - appearsIn: Array>; - /** The friends of the character, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the character exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the character */ - id: Scalars['ID']['output']; - /** The name of the character */ - name: Scalars['String']['output']; -}; - -/** A character from the Star Wars universe */ -export type CharacterFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** The input object sent when passing a color */ -export type ColorInput = { - blue: Scalars['Int']['input']; - green: Scalars['Int']['input']; - red: Scalars['Int']['input']; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type Droid = Character & { - __typename?: 'Droid'; - /** The movies this droid appears in */ - appearsIn: Array>; - /** This droid's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the droid exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the droid */ - id: Scalars['ID']['output']; - /** What others call this droid */ - name: Scalars['String']['output']; - /** This droid's primary function */ - primaryFunction?: Maybe; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type DroidFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - /** The episodes in the Star Wars trilogy */ -export enum Episode { +export type Episode = /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ - Empire = 'EMPIRE', + | 'EMPIRE' /** Star Wars Episode VI: Return of the Jedi, released in 1983. */ - Jedi = 'JEDI', + | 'JEDI' /** Star Wars Episode IV: A New Hope, released in 1977. */ - Newhope = 'NEWHOPE', -} - -/** A connection object for a character's friends */ -export type FriendsConnection = { - __typename?: 'FriendsConnection'; - /** The edges for each of the character's friends. */ - edges?: Maybe>>; - /** A list of the friends, as a convenience when edges are not needed. */ - friends?: Maybe>>; - /** Information for paginating this connection */ - pageInfo: PageInfo; - /** The total number of friends */ - totalCount?: Maybe; -}; - -/** An edge object for a character's friends */ -export type FriendsEdge = { - __typename?: 'FriendsEdge'; - /** A cursor used for pagination */ - cursor: Scalars['ID']['output']; - /** The character represented by this friendship edge */ - node?: Maybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type Human = Character & { - __typename?: 'Human'; - /** The movies this human appears in */ - appearsIn: Array>; - /** This human's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the human exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** Height in the preferred unit, default is meters */ - height?: Maybe; - /** The home planet of the human, or null if unknown */ - homePlanet?: Maybe; - /** The ID of the human */ - id: Scalars['ID']['output']; - /** Mass in kilograms, or null if unknown */ - mass?: Maybe; - /** What this human calls themselves */ - name: Scalars['String']['output']; - /** A list of starships this person has piloted, or an empty list if none */ - starships?: Maybe>>; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanHeightArgs = { - unit?: InputMaybe; -}; - -/** Units of height */ -export enum LengthUnit { - /** Primarily used in the United States */ - Foot = 'FOOT', - /** The standard unit around the world */ - Meter = 'METER', -} - -/** The mutation type, represents all updates we can make to our data */ -export type Mutation = { - __typename?: 'Mutation'; - createReview?: Maybe; -}; - -/** The mutation type, represents all updates we can make to our data */ -export type MutationCreateReviewArgs = { - episode?: InputMaybe; - review: ReviewInput; -}; - -/** Information for paginating this connection */ -export type PageInfo = { - __typename?: 'PageInfo'; - endCursor?: Maybe; - hasNextPage: Scalars['Boolean']['output']; - startCursor?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type Query = { - __typename?: 'Query'; - character?: Maybe; - droid?: Maybe; - hero?: Maybe; - human?: Maybe; - reviews?: Maybe>>; - search?: Maybe>>; - starship?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryCharacterArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryDroidArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHeroArgs = { - episode?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHumanArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryReviewsArgs = { - episode: Episode; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QuerySearchArgs = { - text?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryStarshipArgs = { - id: Scalars['ID']['input']; -}; - -/** Represents a review for a movie */ -export type Review = { - __typename?: 'Review'; - /** Comment about the movie */ - commentary?: Maybe; - /** The number of stars this review gave, 1-5 */ - stars: Scalars['Int']['output']; -}; - -/** The input object sent when someone is creating a new review */ -export type ReviewInput = { - /** Comment about the movie, optional */ - commentary?: InputMaybe; - /** Favorite color, optional */ - favoriteColor?: InputMaybe; - /** 0-5 stars */ - stars: Scalars['Int']['input']; -}; - -export type SearchResult = Droid | Human | Starship; - -export type Starship = { - __typename?: 'Starship'; - /** The ID of the starship */ - id: Scalars['ID']['output']; - /** Length of the starship, along the longest axis */ - length?: Maybe; - /** The name of the starship */ - name: Scalars['String']['output']; -}; - -export type StarshipLengthArgs = { - unit?: InputMaybe; -}; + | 'NEWHOPE'; export type CreateReviewForEpisodeMutationVariables = Exact<{ episode: Episode; review: ReviewInput; }>; -export type CreateReviewForEpisodeMutation = { - __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; -}; +export type CreateReviewForEpisodeMutation = { createReview: { stars: number; commentary: string | null } | null }; export type ExcludeQueryAlphaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryAlphaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryAlphaQuery = { hero: { name: string } | { name: string } | null }; export type HeroAndFriendsNamesQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroAndFriendsNamesQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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; - } + hero: + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } | null; }; export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; name: string; appearsIn: Array } - | { __typename?: 'Human'; name: string; appearsIn: Array } - | null; + hero: { name: string; appearsIn: Array } | { name: string; appearsIn: Array } | null; }; export type HeroDetailsQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; export type HeroDetailsWithFragmentQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsWithFragmentQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; export type HeroNameQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type HeroNameQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type HeroNameQuery = { hero: { name: string } | { name: string } | null }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ - episode?: InputMaybe; - includeName: Scalars['Boolean']['input']; + episode?: Episode | null; + includeName: boolean; }>; -export type HeroNameConditionalInclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalInclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ - episode?: InputMaybe; - skipName: Scalars['Boolean']['input']; + episode?: Episode | null; + skipName: boolean; }>; -export type HeroNameConditionalExclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalExclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroParentTypeDependentFieldQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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 - > | null; - } + hero: + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } | null; }; export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroTypeDependentAliasedFieldQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { property: string | null } | { property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { 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; -}; +export type HumanWithNullHeightQuery = { 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: { name: string } | { name: string } | null; + luke: { name: string } | { name: string } | null; }; diff --git a/dev-test/star-wars/types.globallyAvailable.d.ts b/dev-test/star-wars/types.globallyAvailable.d.ts index 4a40839de60..bd818339896 100644 --- a/dev-test/star-wars/types.globallyAvailable.d.ts +++ b/dev-test/star-wars/types.globallyAvailable.d.ts @@ -1,69 +1,5 @@ -type Maybe = T | null; -type InputMaybe = Maybe; type Exact = { [K in keyof T]: T[K] }; -type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -type MakeEmpty = { [_ in K]?: never }; -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 */ -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 }; -}; - -/** A character from the Star Wars universe */ -type Character = { - /** The movies this character appears in */ - appearsIn: Array>; - /** The friends of the character, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the character exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the character */ - id: Scalars['ID']['output']; - /** The name of the character */ - name: Scalars['String']['output']; -}; - -/** A character from the Star Wars universe */ -type CharacterFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** The input object sent when passing a color */ -type ColorInput = { - blue: Scalars['Int']['input']; - green: Scalars['Int']['input']; - red: Scalars['Int']['input']; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -type Droid = Character & { - __typename?: 'Droid'; - /** The movies this droid appears in */ - appearsIn: Array>; - /** This droid's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the droid exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the droid */ - id: Scalars['ID']['output']; - /** What others call this droid */ - name: Scalars['String']['output']; - /** This droid's primary function */ - primaryFunction?: Maybe; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -type DroidFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - +export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** The episodes in the Star Wars trilogy */ type Episode = /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ @@ -73,334 +9,110 @@ type Episode = /** Star Wars Episode IV: A New Hope, released in 1977. */ | 'NEWHOPE'; -/** A connection object for a character's friends */ -type FriendsConnection = { - __typename?: 'FriendsConnection'; - /** The edges for each of the character's friends. */ - edges?: Maybe>>; - /** A list of the friends, as a convenience when edges are not needed. */ - friends?: Maybe>>; - /** Information for paginating this connection */ - pageInfo: PageInfo; - /** The total number of friends */ - totalCount?: Maybe; -}; - -/** An edge object for a character's friends */ -type FriendsEdge = { - __typename?: 'FriendsEdge'; - /** A cursor used for pagination */ - cursor: Scalars['ID']['output']; - /** The character represented by this friendship edge */ - node?: Maybe; -}; - -/** A humanoid creature from the Star Wars universe */ -type Human = Character & { - __typename?: 'Human'; - /** The movies this human appears in */ - appearsIn: Array>; - /** This human's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the human exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** Height in the preferred unit, default is meters */ - height?: Maybe; - /** The home planet of the human, or null if unknown */ - homePlanet?: Maybe; - /** The ID of the human */ - id: Scalars['ID']['output']; - /** Mass in kilograms, or null if unknown */ - mass?: Maybe; - /** What this human calls themselves */ - name: Scalars['String']['output']; - /** A list of starships this person has piloted, or an empty list if none */ - starships?: Maybe>>; -}; - -/** A humanoid creature from the Star Wars universe */ -type HumanFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** A humanoid creature from the Star Wars universe */ -type HumanHeightArgs = { - unit?: InputMaybe; -}; - -/** Units of height */ -type LengthUnit = - /** Primarily used in the United States */ - | 'FOOT' - /** The standard unit around the world */ - | 'METER'; - -/** The mutation type, represents all updates we can make to our data */ -type Mutation = { - __typename?: 'Mutation'; - createReview?: Maybe; -}; - -/** The mutation type, represents all updates we can make to our data */ -type MutationCreateReviewArgs = { - episode?: InputMaybe; - review: ReviewInput; -}; - -/** Information for paginating this connection */ -type PageInfo = { - __typename?: 'PageInfo'; - endCursor?: Maybe; - hasNextPage: Scalars['Boolean']['output']; - startCursor?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -type Query = { - __typename?: 'Query'; - character?: Maybe; - droid?: Maybe; - hero?: Maybe; - human?: Maybe; - reviews?: Maybe>>; - search?: Maybe>>; - starship?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -type QueryCharacterArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -type QueryDroidArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -type QueryHeroArgs = { - episode?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -type QueryHumanArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -type QueryReviewsArgs = { - episode: Episode; -}; - -/** The query type, represents all of the entry points into our object graph */ -type QuerySearchArgs = { - text?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -type QueryStarshipArgs = { - id: Scalars['ID']['input']; -}; - -/** Represents a review for a movie */ -type Review = { - __typename?: 'Review'; - /** Comment about the movie */ - commentary?: Maybe; - /** The number of stars this review gave, 1-5 */ - stars: Scalars['Int']['output']; -}; - -/** The input object sent when someone is creating a new review */ -type ReviewInput = { - /** Comment about the movie, optional */ - commentary?: InputMaybe; - /** Favorite color, optional */ - favoriteColor?: InputMaybe; - /** 0-5 stars */ - stars: Scalars['Int']['input']; -}; - -type SearchResult = Droid | Human | Starship; - -type Starship = { - __typename?: 'Starship'; - /** The ID of the starship */ - id: Scalars['ID']['output']; - /** Length of the starship, along the longest axis */ - length?: Maybe; - /** The name of the starship */ - name: Scalars['String']['output']; -}; - -type StarshipLengthArgs = { - unit?: InputMaybe; -}; - type CreateReviewForEpisodeMutationVariables = Exact<{ episode: Episode; review: ReviewInput; }>; -type CreateReviewForEpisodeMutation = { - __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; -}; +type CreateReviewForEpisodeMutation = { createReview: { stars: number; commentary: string | null } | null }; type ExcludeQueryAlphaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -type ExcludeQueryAlphaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +type ExcludeQueryAlphaQuery = { hero: { name: string } | { name: string } | null }; type ExcludeQueryBetaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -type ExcludeQueryBetaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +type ExcludeQueryBetaQuery = { hero: { name: string } | { name: string } | null }; type HeroAndFriendsNamesQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; type HeroAndFriendsNamesQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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; - } + hero: + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } | null; }; type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; type HeroAppearsInQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; name: string; appearsIn: Array } - | { __typename?: 'Human'; name: string; appearsIn: Array } - | null; + hero: { name: string; appearsIn: Array } | { name: string; appearsIn: Array } | null; }; type HeroDetailsQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; type HeroDetailsQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { height: number | null; name: string }; type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; type HeroDetailsWithFragmentQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; type HeroDetailsWithFragmentQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; type HeroNameQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -type HeroNameQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +type HeroNameQuery = { hero: { name: string } | { name: string } | null }; type HeroNameConditionalInclusionQueryVariables = Exact<{ - episode?: InputMaybe; - includeName: Scalars['Boolean']['input']; + episode?: Episode | null; + includeName: boolean; }>; -type HeroNameConditionalInclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +type HeroNameConditionalInclusionQuery = { hero: { name?: string } | { name?: string } | null }; type HeroNameConditionalExclusionQueryVariables = Exact<{ - episode?: InputMaybe; - skipName: Scalars['Boolean']['input']; + episode?: Episode | null; + skipName: boolean; }>; -type HeroNameConditionalExclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +type HeroNameConditionalExclusionQuery = { hero: { name?: string } | { name?: string } | null }; type HeroParentTypeDependentFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; type HeroParentTypeDependentFieldQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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 - > | null; - } + hero: + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } | null; }; type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -type HeroTypeDependentAliasedFieldQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; -}; +type HeroTypeDependentAliasedFieldQuery = { hero: { property: string | null } | { property: string | null } | null }; -type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +type HumanFieldsFragment = { name: string; mass: number | null }; type HumanWithNullHeightQueryVariables = Exact<{ [key: string]: never }>; -type HumanWithNullHeightQuery = { - __typename?: 'Query'; - human?: { __typename?: 'Human'; name: string; mass?: number | null } | null; -}; +type HumanWithNullHeightQuery = { 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: { name: string } | { name: string } | null; + luke: { name: string } | { name: string } | null; }; diff --git a/dev-test/star-wars/types.immutableTypes.ts b/dev-test/star-wars/types.immutableTypes.ts index b058821dbb1..06f6c5314e5 100644 --- a/dev-test/star-wars/types.immutableTypes.ts +++ b/dev-test/star-wars/types.immutableTypes.ts @@ -1,244 +1,13 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A character from the Star Wars universe */ -export type Character = { - /** The movies this character appears in */ - readonly appearsIn: ReadonlyArray>; - /** The friends of the character, or an empty list if they have none */ - readonly friends?: Maybe>>; - /** The friends of the character exposed as a connection with edges */ - readonly friendsConnection: FriendsConnection; - /** The ID of the character */ - readonly id: Scalars['ID']['output']; - /** The name of the character */ - readonly name: Scalars['String']['output']; -}; - -/** A character from the Star Wars universe */ -export type CharacterFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** The input object sent when passing a color */ -export type ColorInput = { - readonly blue: Scalars['Int']['input']; - readonly green: Scalars['Int']['input']; - readonly red: Scalars['Int']['input']; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type Droid = Character & { - readonly __typename?: 'Droid'; - /** The movies this droid appears in */ - readonly appearsIn: ReadonlyArray>; - /** This droid's friends, or an empty list if they have none */ - readonly friends?: Maybe>>; - /** The friends of the droid exposed as a connection with edges */ - readonly friendsConnection: FriendsConnection; - /** The ID of the droid */ - readonly id: Scalars['ID']['output']; - /** What others call this droid */ - readonly name: Scalars['String']['output']; - /** This droid's primary function */ - readonly primaryFunction?: Maybe; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type DroidFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - /** The episodes in the Star Wars trilogy */ -export enum Episode { +export type Episode = /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ - Empire = 'EMPIRE', + | 'EMPIRE' /** Star Wars Episode VI: Return of the Jedi, released in 1983. */ - Jedi = 'JEDI', + | 'JEDI' /** Star Wars Episode IV: A New Hope, released in 1977. */ - Newhope = 'NEWHOPE', -} - -/** A connection object for a character's friends */ -export type FriendsConnection = { - readonly __typename?: 'FriendsConnection'; - /** The edges for each of the character's friends. */ - readonly edges?: Maybe>>; - /** A list of the friends, as a convenience when edges are not needed. */ - readonly friends?: Maybe>>; - /** Information for paginating this connection */ - readonly pageInfo: PageInfo; - /** The total number of friends */ - readonly totalCount?: Maybe; -}; - -/** An edge object for a character's friends */ -export type FriendsEdge = { - readonly __typename?: 'FriendsEdge'; - /** A cursor used for pagination */ - readonly cursor: Scalars['ID']['output']; - /** The character represented by this friendship edge */ - readonly node?: Maybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type Human = Character & { - readonly __typename?: 'Human'; - /** The movies this human appears in */ - readonly appearsIn: ReadonlyArray>; - /** This human's friends, or an empty list if they have none */ - readonly friends?: Maybe>>; - /** The friends of the human exposed as a connection with edges */ - readonly friendsConnection: FriendsConnection; - /** Height in the preferred unit, default is meters */ - readonly height?: Maybe; - /** The home planet of the human, or null if unknown */ - readonly homePlanet?: Maybe; - /** The ID of the human */ - readonly id: Scalars['ID']['output']; - /** Mass in kilograms, or null if unknown */ - readonly mass?: Maybe; - /** What this human calls themselves */ - readonly name: Scalars['String']['output']; - /** A list of starships this person has piloted, or an empty list if none */ - readonly starships?: Maybe>>; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanHeightArgs = { - unit?: InputMaybe; -}; - -/** Units of height */ -export enum LengthUnit { - /** Primarily used in the United States */ - Foot = 'FOOT', - /** The standard unit around the world */ - Meter = 'METER', -} - -/** The mutation type, represents all updates we can make to our data */ -export type Mutation = { - readonly __typename?: 'Mutation'; - readonly createReview?: Maybe; -}; - -/** The mutation type, represents all updates we can make to our data */ -export type MutationCreateReviewArgs = { - episode?: InputMaybe; - review: ReviewInput; -}; - -/** Information for paginating this connection */ -export type PageInfo = { - readonly __typename?: 'PageInfo'; - readonly endCursor?: Maybe; - readonly hasNextPage: Scalars['Boolean']['output']; - readonly startCursor?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type Query = { - readonly __typename?: 'Query'; - readonly character?: Maybe; - readonly droid?: Maybe; - readonly hero?: Maybe; - readonly human?: Maybe; - readonly reviews?: Maybe>>; - readonly search?: Maybe>>; - readonly starship?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryCharacterArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryDroidArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHeroArgs = { - episode?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHumanArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryReviewsArgs = { - episode: Episode; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QuerySearchArgs = { - text?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryStarshipArgs = { - id: Scalars['ID']['input']; -}; - -/** Represents a review for a movie */ -export type Review = { - readonly __typename?: 'Review'; - /** Comment about the movie */ - readonly commentary?: Maybe; - /** The number of stars this review gave, 1-5 */ - readonly stars: Scalars['Int']['output']; -}; - -/** The input object sent when someone is creating a new review */ -export type ReviewInput = { - /** Comment about the movie, optional */ - readonly commentary?: InputMaybe; - /** Favorite color, optional */ - readonly favoriteColor?: InputMaybe; - /** 0-5 stars */ - readonly stars: Scalars['Int']['input']; -}; - -export type SearchResult = Droid | Human | Starship; - -export type Starship = { - readonly __typename?: 'Starship'; - /** The ID of the starship */ - readonly id: Scalars['ID']['output']; - /** Length of the starship, along the longest axis */ - readonly length?: Maybe; - /** The name of the starship */ - readonly name: Scalars['String']['output']; -}; - -export type StarshipLengthArgs = { - unit?: InputMaybe; -}; + | 'NEWHOPE'; export type CreateReviewForEpisodeMutationVariables = Exact<{ episode: Episode; @@ -246,62 +15,34 @@ export type CreateReviewForEpisodeMutationVariables = Exact<{ }>; export type CreateReviewForEpisodeMutation = { - readonly __typename?: 'Mutation'; - readonly createReview?: { - readonly __typename?: 'Review'; - readonly stars: number; - readonly commentary?: string | null; - } | null; + readonly createReview: { readonly stars: number; readonly commentary: string | null } | null; }; export type ExcludeQueryAlphaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryAlphaQuery = { - readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly name: string } - | null; -}; +export type ExcludeQueryAlphaQuery = { readonly hero: { readonly name: string } | { readonly name: string } | null }; export type ExcludeQueryBetaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryBetaQuery = { - readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly name: string } - | null; -}; +export type ExcludeQueryBetaQuery = { readonly hero: { readonly name: string } | { readonly name: string } | null }; export type HeroAndFriendsNamesQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroAndFriendsNamesQuery = { - readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { - readonly __typename?: 'Droid'; readonly name: string; - readonly friends?: ReadonlyArray< - | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly name: string } - | null - > | null; + readonly friends: ReadonlyArray<{ readonly name: string } | { readonly name: string } | null> | null; } | { - readonly __typename?: 'Human'; readonly name: string; - readonly friends?: ReadonlyArray< - | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly name: string } - | null - > | null; + readonly friends: ReadonlyArray<{ readonly name: string } | { readonly name: string } | null> | null; } | null; }; @@ -309,152 +50,104 @@ export type HeroAndFriendsNamesQuery = { export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { - readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly name: string; readonly appearsIn: ReadonlyArray } - | { readonly __typename?: 'Human'; readonly name: string; readonly appearsIn: ReadonlyArray } + readonly hero: + | { readonly name: string; readonly appearsIn: ReadonlyArray } + | { readonly name: string; readonly appearsIn: ReadonlyArray } | null; }; export type HeroDetailsQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; 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 primaryFunction: string | null; readonly name: string } + | { readonly height: number | null; readonly name: string } | null; }; -type HeroDetails_Droid_Fragment = { - readonly __typename?: 'Droid'; - readonly primaryFunction?: string | null; - readonly name: string; -}; +type HeroDetails_Droid_Fragment = { readonly primaryFunction: string | null; readonly name: string }; -type HeroDetails_Human_Fragment = { - readonly __typename?: 'Human'; - readonly height?: number | null; - readonly name: string; -}; +type HeroDetails_Human_Fragment = { readonly height: number | null; readonly name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; export type HeroDetailsWithFragmentQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; 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 primaryFunction: string | null; readonly name: string } + | { readonly height: number | null; readonly name: string } | null; }; export type HeroNameQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type HeroNameQuery = { - readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly name: string } - | null; -}; +export type HeroNameQuery = { readonly hero: { readonly name: string } | { readonly name: string } | null }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ - episode?: InputMaybe; - includeName: Scalars['Boolean']['input']; + episode?: Episode | null; + includeName: boolean; }>; export type HeroNameConditionalInclusionQuery = { - readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly name?: string } - | { readonly __typename?: 'Human'; readonly name?: string } - | null; + readonly hero: { readonly name?: string } | { readonly name?: string } | null; }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ - episode?: InputMaybe; - skipName: Scalars['Boolean']['input']; + episode?: Episode | null; + skipName: boolean; }>; export type HeroNameConditionalExclusionQuery = { - readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly name?: string } - | { readonly __typename?: 'Human'; readonly name?: string } - | null; + readonly hero: { readonly name?: string } | { readonly name?: string } | null; }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroParentTypeDependentFieldQuery = { - readonly __typename?: 'Query'; - readonly hero?: + readonly hero: | { - readonly __typename?: 'Droid'; readonly name: string; - readonly friends?: ReadonlyArray< - | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly height?: number | null; readonly name: string } - | null + readonly friends: ReadonlyArray< + { readonly name: string } | { readonly height: number | null; readonly name: string } | null > | null; } | { - readonly __typename?: 'Human'; readonly name: string; - readonly friends?: ReadonlyArray< - | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly height?: number | null; readonly name: string } - | null + readonly friends: ReadonlyArray< + { readonly name: string } | { readonly height: number | null; readonly name: string } | null > | null; } | null; }; export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroTypeDependentAliasedFieldQuery = { - readonly __typename?: 'Query'; - readonly hero?: - | { readonly __typename?: 'Droid'; readonly property?: string | null } - | { readonly __typename?: 'Human'; readonly property?: string | null } - | null; + readonly hero: { readonly property: string | null } | { readonly property: string | null } | null; }; -export type HumanFieldsFragment = { - readonly __typename?: 'Human'; - readonly name: string; - readonly mass?: number | null; -}; +export type HumanFieldsFragment = { readonly name: string; 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 name: string; readonly mass: number | null } | null; }; export type TwoHeroesQueryVariables = Exact<{ [key: string]: never }>; export type TwoHeroesQuery = { - readonly __typename?: 'Query'; - readonly r2?: - | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly name: string } - | null; - readonly luke?: - | { readonly __typename?: 'Droid'; readonly name: string } - | { readonly __typename?: 'Human'; readonly name: string } - | null; + readonly r2: { readonly name: string } | { readonly name: string } | null; + readonly luke: { readonly name: string } | { 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 7ec1e20377e..bbc6c6f53df 100644 --- a/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts +++ b/dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts @@ -1,217 +1,120 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** The input object sent when passing a color */ -export type ColorInput = { - blue: Scalars['Int']['input']; - green: Scalars['Int']['input']; - red: Scalars['Int']['input']; -}; - /** The episodes in the Star Wars trilogy */ -export enum Episode { +export type Episode = /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ - Empire = 'EMPIRE', + | 'EMPIRE' /** Star Wars Episode VI: Return of the Jedi, released in 1983. */ - Jedi = 'JEDI', + | 'JEDI' /** Star Wars Episode IV: A New Hope, released in 1977. */ - Newhope = 'NEWHOPE', -} - -/** Units of height */ -export enum LengthUnit { - /** Primarily used in the United States */ - Foot = 'FOOT', - /** The standard unit around the world */ - Meter = 'METER', -} - -/** The input object sent when someone is creating a new review */ -export type ReviewInput = { - /** Comment about the movie, optional */ - commentary?: InputMaybe; - /** Favorite color, optional */ - favoriteColor?: InputMaybe; - /** 0-5 stars */ - stars: Scalars['Int']['input']; -}; + | 'NEWHOPE'; export type CreateReviewForEpisodeMutationVariables = Exact<{ episode: Episode; review: ReviewInput; }>; -export type CreateReviewForEpisodeMutation = { - __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; -}; +export type CreateReviewForEpisodeMutation = { createReview: { stars: number; commentary: string | null } | null }; export type ExcludeQueryAlphaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryAlphaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryAlphaQuery = { hero: { name: string } | { name: string } | null }; export type ExcludeQueryBetaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryBetaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryBetaQuery = { hero: { name: string } | { name: string } | null }; export type HeroAndFriendsNamesQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroAndFriendsNamesQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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; - } + hero: + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } | null; }; export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; name: string; appearsIn: Array } - | { __typename?: 'Human'; name: string; appearsIn: Array } - | null; + hero: { name: string; appearsIn: Array } | { name: string; appearsIn: Array } | null; }; export type HeroDetailsQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; export type HeroDetailsWithFragmentQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsWithFragmentQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; export type HeroNameQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type HeroNameQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type HeroNameQuery = { hero: { name: string } | { name: string } | null }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ - episode?: InputMaybe; - includeName: Scalars['Boolean']['input']; + episode?: Episode | null; + includeName: boolean; }>; -export type HeroNameConditionalInclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalInclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ - episode?: InputMaybe; - skipName: Scalars['Boolean']['input']; + episode?: Episode | null; + skipName: boolean; }>; -export type HeroNameConditionalExclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalExclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroParentTypeDependentFieldQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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 - > | null; - } + hero: + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } | null; }; export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroTypeDependentAliasedFieldQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { property: string | null } | { property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { 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; -}; +export type HumanWithNullHeightQuery = { 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: { name: string } | { name: string } | null; + luke: { name: string } | { name: string } | null; }; diff --git a/dev-test/star-wars/types.preResolveTypes.ts b/dev-test/star-wars/types.preResolveTypes.ts index d580beb2eb5..bbc6c6f53df 100644 --- a/dev-test/star-wars/types.preResolveTypes.ts +++ b/dev-test/star-wars/types.preResolveTypes.ts @@ -1,408 +1,120 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A character from the Star Wars universe */ -export type Character = { - /** The movies this character appears in */ - appearsIn: Array>; - /** The friends of the character, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the character exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the character */ - id: Scalars['ID']['output']; - /** The name of the character */ - name: Scalars['String']['output']; -}; - -/** A character from the Star Wars universe */ -export type CharacterFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** The input object sent when passing a color */ -export type ColorInput = { - blue: Scalars['Int']['input']; - green: Scalars['Int']['input']; - red: Scalars['Int']['input']; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type Droid = Character & { - __typename?: 'Droid'; - /** The movies this droid appears in */ - appearsIn: Array>; - /** This droid's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the droid exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the droid */ - id: Scalars['ID']['output']; - /** What others call this droid */ - name: Scalars['String']['output']; - /** This droid's primary function */ - primaryFunction?: Maybe; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type DroidFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - /** The episodes in the Star Wars trilogy */ -export enum Episode { +export type Episode = /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ - Empire = 'EMPIRE', + | 'EMPIRE' /** Star Wars Episode VI: Return of the Jedi, released in 1983. */ - Jedi = 'JEDI', + | 'JEDI' /** Star Wars Episode IV: A New Hope, released in 1977. */ - Newhope = 'NEWHOPE', -} - -/** A connection object for a character's friends */ -export type FriendsConnection = { - __typename?: 'FriendsConnection'; - /** The edges for each of the character's friends. */ - edges?: Maybe>>; - /** A list of the friends, as a convenience when edges are not needed. */ - friends?: Maybe>>; - /** Information for paginating this connection */ - pageInfo: PageInfo; - /** The total number of friends */ - totalCount?: Maybe; -}; - -/** An edge object for a character's friends */ -export type FriendsEdge = { - __typename?: 'FriendsEdge'; - /** A cursor used for pagination */ - cursor: Scalars['ID']['output']; - /** The character represented by this friendship edge */ - node?: Maybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type Human = Character & { - __typename?: 'Human'; - /** The movies this human appears in */ - appearsIn: Array>; - /** This human's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the human exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** Height in the preferred unit, default is meters */ - height?: Maybe; - /** The home planet of the human, or null if unknown */ - homePlanet?: Maybe; - /** The ID of the human */ - id: Scalars['ID']['output']; - /** Mass in kilograms, or null if unknown */ - mass?: Maybe; - /** What this human calls themselves */ - name: Scalars['String']['output']; - /** A list of starships this person has piloted, or an empty list if none */ - starships?: Maybe>>; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanHeightArgs = { - unit?: InputMaybe; -}; - -/** Units of height */ -export enum LengthUnit { - /** Primarily used in the United States */ - Foot = 'FOOT', - /** The standard unit around the world */ - Meter = 'METER', -} - -/** The mutation type, represents all updates we can make to our data */ -export type Mutation = { - __typename?: 'Mutation'; - createReview?: Maybe; -}; - -/** The mutation type, represents all updates we can make to our data */ -export type MutationCreateReviewArgs = { - episode?: InputMaybe; - review: ReviewInput; -}; - -/** Information for paginating this connection */ -export type PageInfo = { - __typename?: 'PageInfo'; - endCursor?: Maybe; - hasNextPage: Scalars['Boolean']['output']; - startCursor?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type Query = { - __typename?: 'Query'; - character?: Maybe; - droid?: Maybe; - hero?: Maybe; - human?: Maybe; - reviews?: Maybe>>; - search?: Maybe>>; - starship?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryCharacterArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryDroidArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHeroArgs = { - episode?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHumanArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryReviewsArgs = { - episode: Episode; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QuerySearchArgs = { - text?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryStarshipArgs = { - id: Scalars['ID']['input']; -}; - -/** Represents a review for a movie */ -export type Review = { - __typename?: 'Review'; - /** Comment about the movie */ - commentary?: Maybe; - /** The number of stars this review gave, 1-5 */ - stars: Scalars['Int']['output']; -}; - -/** The input object sent when someone is creating a new review */ -export type ReviewInput = { - /** Comment about the movie, optional */ - commentary?: InputMaybe; - /** Favorite color, optional */ - favoriteColor?: InputMaybe; - /** 0-5 stars */ - stars: Scalars['Int']['input']; -}; - -export type SearchResult = Droid | Human | Starship; - -export type Starship = { - __typename?: 'Starship'; - /** The ID of the starship */ - id: Scalars['ID']['output']; - /** Length of the starship, along the longest axis */ - length?: Maybe; - /** The name of the starship */ - name: Scalars['String']['output']; -}; - -export type StarshipLengthArgs = { - unit?: InputMaybe; -}; + | 'NEWHOPE'; export type CreateReviewForEpisodeMutationVariables = Exact<{ episode: Episode; review: ReviewInput; }>; -export type CreateReviewForEpisodeMutation = { - __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; -}; +export type CreateReviewForEpisodeMutation = { createReview: { stars: number; commentary: string | null } | null }; export type ExcludeQueryAlphaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryAlphaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryAlphaQuery = { hero: { name: string } | { name: string } | null }; export type ExcludeQueryBetaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryBetaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryBetaQuery = { hero: { name: string } | { name: string } | null }; export type HeroAndFriendsNamesQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroAndFriendsNamesQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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; - } + hero: + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } | null; }; export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; name: string; appearsIn: Array } - | { __typename?: 'Human'; name: string; appearsIn: Array } - | null; + hero: { name: string; appearsIn: Array } | { name: string; appearsIn: Array } | null; }; export type HeroDetailsQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; export type HeroDetailsWithFragmentQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsWithFragmentQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; export type HeroNameQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type HeroNameQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type HeroNameQuery = { hero: { name: string } | { name: string } | null }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ - episode?: InputMaybe; - includeName: Scalars['Boolean']['input']; + episode?: Episode | null; + includeName: boolean; }>; -export type HeroNameConditionalInclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalInclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ - episode?: InputMaybe; - skipName: Scalars['Boolean']['input']; + episode?: Episode | null; + skipName: boolean; }>; -export type HeroNameConditionalExclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalExclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroParentTypeDependentFieldQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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 - > | null; - } + hero: + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } | null; }; export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroTypeDependentAliasedFieldQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { property: string | null } | { property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { 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; -}; +export type HumanWithNullHeightQuery = { 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: { name: string } | { name: string } | null; + luke: { name: string } | { name: string } | null; }; diff --git a/dev-test/star-wars/types.skipSchema.ts b/dev-test/star-wars/types.skipSchema.ts index d580beb2eb5..bbc6c6f53df 100644 --- a/dev-test/star-wars/types.skipSchema.ts +++ b/dev-test/star-wars/types.skipSchema.ts @@ -1,408 +1,120 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A character from the Star Wars universe */ -export type Character = { - /** The movies this character appears in */ - appearsIn: Array>; - /** The friends of the character, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the character exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the character */ - id: Scalars['ID']['output']; - /** The name of the character */ - name: Scalars['String']['output']; -}; - -/** A character from the Star Wars universe */ -export type CharacterFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** The input object sent when passing a color */ -export type ColorInput = { - blue: Scalars['Int']['input']; - green: Scalars['Int']['input']; - red: Scalars['Int']['input']; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type Droid = Character & { - __typename?: 'Droid'; - /** The movies this droid appears in */ - appearsIn: Array>; - /** This droid's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the droid exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the droid */ - id: Scalars['ID']['output']; - /** What others call this droid */ - name: Scalars['String']['output']; - /** This droid's primary function */ - primaryFunction?: Maybe; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type DroidFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - /** The episodes in the Star Wars trilogy */ -export enum Episode { +export type Episode = /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ - Empire = 'EMPIRE', + | 'EMPIRE' /** Star Wars Episode VI: Return of the Jedi, released in 1983. */ - Jedi = 'JEDI', + | 'JEDI' /** Star Wars Episode IV: A New Hope, released in 1977. */ - Newhope = 'NEWHOPE', -} - -/** A connection object for a character's friends */ -export type FriendsConnection = { - __typename?: 'FriendsConnection'; - /** The edges for each of the character's friends. */ - edges?: Maybe>>; - /** A list of the friends, as a convenience when edges are not needed. */ - friends?: Maybe>>; - /** Information for paginating this connection */ - pageInfo: PageInfo; - /** The total number of friends */ - totalCount?: Maybe; -}; - -/** An edge object for a character's friends */ -export type FriendsEdge = { - __typename?: 'FriendsEdge'; - /** A cursor used for pagination */ - cursor: Scalars['ID']['output']; - /** The character represented by this friendship edge */ - node?: Maybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type Human = Character & { - __typename?: 'Human'; - /** The movies this human appears in */ - appearsIn: Array>; - /** This human's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the human exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** Height in the preferred unit, default is meters */ - height?: Maybe; - /** The home planet of the human, or null if unknown */ - homePlanet?: Maybe; - /** The ID of the human */ - id: Scalars['ID']['output']; - /** Mass in kilograms, or null if unknown */ - mass?: Maybe; - /** What this human calls themselves */ - name: Scalars['String']['output']; - /** A list of starships this person has piloted, or an empty list if none */ - starships?: Maybe>>; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanHeightArgs = { - unit?: InputMaybe; -}; - -/** Units of height */ -export enum LengthUnit { - /** Primarily used in the United States */ - Foot = 'FOOT', - /** The standard unit around the world */ - Meter = 'METER', -} - -/** The mutation type, represents all updates we can make to our data */ -export type Mutation = { - __typename?: 'Mutation'; - createReview?: Maybe; -}; - -/** The mutation type, represents all updates we can make to our data */ -export type MutationCreateReviewArgs = { - episode?: InputMaybe; - review: ReviewInput; -}; - -/** Information for paginating this connection */ -export type PageInfo = { - __typename?: 'PageInfo'; - endCursor?: Maybe; - hasNextPage: Scalars['Boolean']['output']; - startCursor?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type Query = { - __typename?: 'Query'; - character?: Maybe; - droid?: Maybe; - hero?: Maybe; - human?: Maybe; - reviews?: Maybe>>; - search?: Maybe>>; - starship?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryCharacterArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryDroidArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHeroArgs = { - episode?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHumanArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryReviewsArgs = { - episode: Episode; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QuerySearchArgs = { - text?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryStarshipArgs = { - id: Scalars['ID']['input']; -}; - -/** Represents a review for a movie */ -export type Review = { - __typename?: 'Review'; - /** Comment about the movie */ - commentary?: Maybe; - /** The number of stars this review gave, 1-5 */ - stars: Scalars['Int']['output']; -}; - -/** The input object sent when someone is creating a new review */ -export type ReviewInput = { - /** Comment about the movie, optional */ - commentary?: InputMaybe; - /** Favorite color, optional */ - favoriteColor?: InputMaybe; - /** 0-5 stars */ - stars: Scalars['Int']['input']; -}; - -export type SearchResult = Droid | Human | Starship; - -export type Starship = { - __typename?: 'Starship'; - /** The ID of the starship */ - id: Scalars['ID']['output']; - /** Length of the starship, along the longest axis */ - length?: Maybe; - /** The name of the starship */ - name: Scalars['String']['output']; -}; - -export type StarshipLengthArgs = { - unit?: InputMaybe; -}; + | 'NEWHOPE'; export type CreateReviewForEpisodeMutationVariables = Exact<{ episode: Episode; review: ReviewInput; }>; -export type CreateReviewForEpisodeMutation = { - __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; -}; +export type CreateReviewForEpisodeMutation = { createReview: { stars: number; commentary: string | null } | null }; export type ExcludeQueryAlphaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryAlphaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryAlphaQuery = { hero: { name: string } | { name: string } | null }; export type ExcludeQueryBetaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryBetaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryBetaQuery = { hero: { name: string } | { name: string } | null }; export type HeroAndFriendsNamesQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroAndFriendsNamesQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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; - } + hero: + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } | null; }; export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; name: string; appearsIn: Array } - | { __typename?: 'Human'; name: string; appearsIn: Array } - | null; + hero: { name: string; appearsIn: Array } | { name: string; appearsIn: Array } | null; }; export type HeroDetailsQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; export type HeroDetailsWithFragmentQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsWithFragmentQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; export type HeroNameQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type HeroNameQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type HeroNameQuery = { hero: { name: string } | { name: string } | null }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ - episode?: InputMaybe; - includeName: Scalars['Boolean']['input']; + episode?: Episode | null; + includeName: boolean; }>; -export type HeroNameConditionalInclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalInclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ - episode?: InputMaybe; - skipName: Scalars['Boolean']['input']; + episode?: Episode | null; + skipName: boolean; }>; -export type HeroNameConditionalExclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalExclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroParentTypeDependentFieldQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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 - > | null; - } + hero: + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } | null; }; export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroTypeDependentAliasedFieldQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { property: string | null } | { property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { 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; -}; +export type HumanWithNullHeightQuery = { 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: { name: string } | { name: string } | null; + luke: { name: string } | { name: string } | null; }; diff --git a/dev-test/star-wars/types.ts b/dev-test/star-wars/types.ts index d580beb2eb5..bbc6c6f53df 100644 --- a/dev-test/star-wars/types.ts +++ b/dev-test/star-wars/types.ts @@ -1,408 +1,120 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A character from the Star Wars universe */ -export type Character = { - /** The movies this character appears in */ - appearsIn: Array>; - /** The friends of the character, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the character exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the character */ - id: Scalars['ID']['output']; - /** The name of the character */ - name: Scalars['String']['output']; -}; - -/** A character from the Star Wars universe */ -export type CharacterFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** The input object sent when passing a color */ -export type ColorInput = { - blue: Scalars['Int']['input']; - green: Scalars['Int']['input']; - red: Scalars['Int']['input']; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type Droid = Character & { - __typename?: 'Droid'; - /** The movies this droid appears in */ - appearsIn: Array>; - /** This droid's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the droid exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** The ID of the droid */ - id: Scalars['ID']['output']; - /** What others call this droid */ - name: Scalars['String']['output']; - /** This droid's primary function */ - primaryFunction?: Maybe; -}; - -/** An autonomous mechanical character in the Star Wars universe */ -export type DroidFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - /** The episodes in the Star Wars trilogy */ -export enum Episode { +export type Episode = /** Star Wars Episode V: The Empire Strikes Back, released in 1980. */ - Empire = 'EMPIRE', + | 'EMPIRE' /** Star Wars Episode VI: Return of the Jedi, released in 1983. */ - Jedi = 'JEDI', + | 'JEDI' /** Star Wars Episode IV: A New Hope, released in 1977. */ - Newhope = 'NEWHOPE', -} - -/** A connection object for a character's friends */ -export type FriendsConnection = { - __typename?: 'FriendsConnection'; - /** The edges for each of the character's friends. */ - edges?: Maybe>>; - /** A list of the friends, as a convenience when edges are not needed. */ - friends?: Maybe>>; - /** Information for paginating this connection */ - pageInfo: PageInfo; - /** The total number of friends */ - totalCount?: Maybe; -}; - -/** An edge object for a character's friends */ -export type FriendsEdge = { - __typename?: 'FriendsEdge'; - /** A cursor used for pagination */ - cursor: Scalars['ID']['output']; - /** The character represented by this friendship edge */ - node?: Maybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type Human = Character & { - __typename?: 'Human'; - /** The movies this human appears in */ - appearsIn: Array>; - /** This human's friends, or an empty list if they have none */ - friends?: Maybe>>; - /** The friends of the human exposed as a connection with edges */ - friendsConnection: FriendsConnection; - /** Height in the preferred unit, default is meters */ - height?: Maybe; - /** The home planet of the human, or null if unknown */ - homePlanet?: Maybe; - /** The ID of the human */ - id: Scalars['ID']['output']; - /** Mass in kilograms, or null if unknown */ - mass?: Maybe; - /** What this human calls themselves */ - name: Scalars['String']['output']; - /** A list of starships this person has piloted, or an empty list if none */ - starships?: Maybe>>; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanFriendsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; -}; - -/** A humanoid creature from the Star Wars universe */ -export type HumanHeightArgs = { - unit?: InputMaybe; -}; - -/** Units of height */ -export enum LengthUnit { - /** Primarily used in the United States */ - Foot = 'FOOT', - /** The standard unit around the world */ - Meter = 'METER', -} - -/** The mutation type, represents all updates we can make to our data */ -export type Mutation = { - __typename?: 'Mutation'; - createReview?: Maybe; -}; - -/** The mutation type, represents all updates we can make to our data */ -export type MutationCreateReviewArgs = { - episode?: InputMaybe; - review: ReviewInput; -}; - -/** Information for paginating this connection */ -export type PageInfo = { - __typename?: 'PageInfo'; - endCursor?: Maybe; - hasNextPage: Scalars['Boolean']['output']; - startCursor?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type Query = { - __typename?: 'Query'; - character?: Maybe; - droid?: Maybe; - hero?: Maybe; - human?: Maybe; - reviews?: Maybe>>; - search?: Maybe>>; - starship?: Maybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryCharacterArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryDroidArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHeroArgs = { - episode?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryHumanArgs = { - id: Scalars['ID']['input']; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryReviewsArgs = { - episode: Episode; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QuerySearchArgs = { - text?: InputMaybe; -}; - -/** The query type, represents all of the entry points into our object graph */ -export type QueryStarshipArgs = { - id: Scalars['ID']['input']; -}; - -/** Represents a review for a movie */ -export type Review = { - __typename?: 'Review'; - /** Comment about the movie */ - commentary?: Maybe; - /** The number of stars this review gave, 1-5 */ - stars: Scalars['Int']['output']; -}; - -/** The input object sent when someone is creating a new review */ -export type ReviewInput = { - /** Comment about the movie, optional */ - commentary?: InputMaybe; - /** Favorite color, optional */ - favoriteColor?: InputMaybe; - /** 0-5 stars */ - stars: Scalars['Int']['input']; -}; - -export type SearchResult = Droid | Human | Starship; - -export type Starship = { - __typename?: 'Starship'; - /** The ID of the starship */ - id: Scalars['ID']['output']; - /** Length of the starship, along the longest axis */ - length?: Maybe; - /** The name of the starship */ - name: Scalars['String']['output']; -}; - -export type StarshipLengthArgs = { - unit?: InputMaybe; -}; + | 'NEWHOPE'; export type CreateReviewForEpisodeMutationVariables = Exact<{ episode: Episode; review: ReviewInput; }>; -export type CreateReviewForEpisodeMutation = { - __typename?: 'Mutation'; - createReview?: { __typename?: 'Review'; stars: number; commentary?: string | null } | null; -}; +export type CreateReviewForEpisodeMutation = { createReview: { stars: number; commentary: string | null } | null }; export type ExcludeQueryAlphaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryAlphaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryAlphaQuery = { hero: { name: string } | { name: string } | null }; export type ExcludeQueryBetaQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type ExcludeQueryBetaQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type ExcludeQueryBetaQuery = { hero: { name: string } | { name: string } | null }; export type HeroAndFriendsNamesQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroAndFriendsNamesQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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; - } + hero: + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { name: string } | null> | null } | null; }; export type HeroAppearsInQueryVariables = Exact<{ [key: string]: never }>; export type HeroAppearsInQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; name: string; appearsIn: Array } - | { __typename?: 'Human'; name: string; appearsIn: Array } - | null; + hero: { name: string; appearsIn: Array } | { name: string; appearsIn: Array } | null; }; export type HeroDetailsQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; -type HeroDetails_Droid_Fragment = { __typename?: 'Droid'; primaryFunction?: string | null; name: string }; +type HeroDetails_Droid_Fragment = { primaryFunction: string | null; name: string }; -type HeroDetails_Human_Fragment = { __typename?: 'Human'; height?: number | null; name: string }; +type HeroDetails_Human_Fragment = { height: number | null; name: string }; export type HeroDetailsFragment = HeroDetails_Droid_Fragment | HeroDetails_Human_Fragment; export type HeroDetailsWithFragmentQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroDetailsWithFragmentQuery = { - __typename?: 'Query'; - hero?: - | { __typename?: 'Droid'; primaryFunction?: string | null; name: string } - | { __typename?: 'Human'; height?: number | null; name: string } - | null; + hero: { primaryFunction: string | null; name: string } | { height: number | null; name: string } | null; }; export type HeroNameQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; -export type HeroNameQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name: string } | { __typename?: 'Human'; name: string } | null; -}; +export type HeroNameQuery = { hero: { name: string } | { name: string } | null }; export type HeroNameConditionalInclusionQueryVariables = Exact<{ - episode?: InputMaybe; - includeName: Scalars['Boolean']['input']; + episode?: Episode | null; + includeName: boolean; }>; -export type HeroNameConditionalInclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalInclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroNameConditionalExclusionQueryVariables = Exact<{ - episode?: InputMaybe; - skipName: Scalars['Boolean']['input']; + episode?: Episode | null; + skipName: boolean; }>; -export type HeroNameConditionalExclusionQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; name?: string } | { __typename?: 'Human'; name?: string } | null; -}; +export type HeroNameConditionalExclusionQuery = { hero: { name?: string } | { name?: string } | null }; export type HeroParentTypeDependentFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroParentTypeDependentFieldQuery = { - __typename?: 'Query'; - hero?: - | { - __typename?: 'Droid'; - name: string; - 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 - > | null; - } + hero: + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } + | { name: string; friends: Array<{ name: string } | { height: number | null; name: string } | null> | null } | null; }; export type HeroTypeDependentAliasedFieldQueryVariables = Exact<{ - episode?: InputMaybe; + episode?: Episode | null; }>; export type HeroTypeDependentAliasedFieldQuery = { - __typename?: 'Query'; - hero?: { __typename?: 'Droid'; property?: string | null } | { __typename?: 'Human'; property?: string | null } | null; + hero: { property: string | null } | { property: string | null } | null; }; -export type HumanFieldsFragment = { __typename?: 'Human'; name: string; mass?: number | null }; +export type HumanFieldsFragment = { 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; -}; +export type HumanWithNullHeightQuery = { 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: { name: string } | { name: string } | null; + luke: { name: string } | { name: string } | null; }; diff --git a/dev-test/subpath-import/result.d.ts b/dev-test/subpath-import/result.d.ts index e5bde7c4017..051b99453d7 100644 --- a/dev-test/subpath-import/result.d.ts +++ b/dev-test/subpath-import/result.d.ts @@ -4,7 +4,6 @@ import { TestContext } from '#test-null-value/context'; import { FiedContextType } from '#test/root'; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-federation/generated/types.ts b/dev-test/test-federation/generated/types.ts index a73c3395a90..67bba821349 100644 --- a/dev-test/test-federation/generated/types.ts +++ b/dev-test/test-federation/generated/types.ts @@ -1,7 +1,6 @@ import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; export type Maybe = T | null | undefined; export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-null-value/result.d.ts b/dev-test/test-null-value/result.d.ts index 9e88d265c27..43b53927040 100644 --- a/dev-test/test-null-value/result.d.ts +++ b/dev-test/test-null-value/result.d.ts @@ -1,50 +1,7 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 BaseCartLine = { - id: Scalars['String']['output']; - quantity: Scalars['Int']['output']; -}; - -export type BaseCartLineConnection = { - id: Scalars['String']['output']; - nodes: Array; -}; - -export type Cart = { - id: Scalars['String']['output']; - lines: BaseCartLineConnection; -}; - -export type CartLine = BaseCartLine & { - id: Scalars['String']['output']; - quantity: Scalars['Int']['output']; -}; - -export type ComponentizableCartLine = BaseCartLine & { - id: Scalars['String']['output']; - quantity: Scalars['Int']['output']; -}; - -export type QueryRoot = { - cart?: Maybe; -}; - 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/env.types.ts b/dev-test/test-schema/env.types.ts index a21f1f2cd58..8d5780a3a91 100644 --- a/dev-test/test-schema/env.types.ts +++ b/dev-test/test-schema/env.types.ts @@ -1,6 +1,5 @@ export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-schema/resolvers-federation.ts b/dev-test/test-schema/resolvers-federation.ts index ef01e8ea778..34009d912e4 100644 --- a/dev-test/test-schema/resolvers-federation.ts +++ b/dev-test/test-schema/resolvers-federation.ts @@ -1,7 +1,6 @@ import { GraphQLResolveInfo } from 'graphql'; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-schema/resolvers-root.ts b/dev-test/test-schema/resolvers-root.ts index a3f659b2fdf..7be80681548 100644 --- a/dev-test/test-schema/resolvers-root.ts +++ b/dev-test/test-schema/resolvers-root.ts @@ -1,7 +1,6 @@ import { GraphQLResolveInfo } from 'graphql'; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-schema/resolvers-stitching.ts b/dev-test/test-schema/resolvers-stitching.ts index e5e021f8d28..526a9ab3eef 100644 --- a/dev-test/test-schema/resolvers-stitching.ts +++ b/dev-test/test-schema/resolvers-stitching.ts @@ -1,7 +1,6 @@ import { GraphQLResolveInfo, SelectionSetNode, FieldNode } from 'graphql'; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-schema/resolvers-types.ts b/dev-test/test-schema/resolvers-types.ts index 9f44618642c..87a616a38c3 100644 --- a/dev-test/test-schema/resolvers-types.ts +++ b/dev-test/test-schema/resolvers-types.ts @@ -1,7 +1,6 @@ import { GraphQLResolveInfo } from 'graphql'; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts b/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts index 8c580b61f78..7dfb7db5c1d 100644 --- a/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts +++ b/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts @@ -1,24 +1,9 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 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 472613688cf..7dfb7db5c1d 100644 --- a/dev-test/test-schema/types.preResolveTypes.ts +++ b/dev-test/test-schema/types.preResolveTypes.ts @@ -1,49 +1,9 @@ -export type Maybe = T | null; -export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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'; - allUsers: Array>; - /** - * Generates a new answer for th - * guessing game - */ - answer: Array; - testArr1?: Maybe>>; - testArr2: Array>; - testArr3: Array; - userById?: Maybe; -}; - -export type QueryUserByIdArgs = { - id: Scalars['Int']['input']; -}; - -export type User = { - __typename?: 'User'; - email: Scalars['String']['output']; - id: Scalars['Int']['output']; - name: Scalars['String']['output']; -}; - 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/typings.avoidOptionals.ts b/dev-test/test-schema/typings.avoidOptionals.ts index 43e966058f7..ccc8ef16eb5 100644 --- a/dev-test/test-schema/typings.avoidOptionals.ts +++ b/dev-test/test-schema/typings.avoidOptionals.ts @@ -1,6 +1,5 @@ export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-schema/typings.enum.ts b/dev-test/test-schema/typings.enum.ts index 491b66ac691..51f420793c9 100644 --- a/dev-test/test-schema/typings.enum.ts +++ b/dev-test/test-schema/typings.enum.ts @@ -1,6 +1,5 @@ export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-schema/typings.immutableTypes.ts b/dev-test/test-schema/typings.immutableTypes.ts index c8a55b067b5..035adddd663 100644 --- a/dev-test/test-schema/typings.immutableTypes.ts +++ b/dev-test/test-schema/typings.immutableTypes.ts @@ -1,6 +1,5 @@ export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-schema/typings.ts b/dev-test/test-schema/typings.ts index babf3b6d1b0..56c23a6c71a 100644 --- a/dev-test/test-schema/typings.ts +++ b/dev-test/test-schema/typings.ts @@ -1,7 +1,6 @@ import { GraphQLResolveInfo } from 'graphql'; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/dev-test/test-schema/typings.wrapped.ts b/dev-test/test-schema/typings.wrapped.ts index a17ae3d1de2..e23c85df7ec 100644 --- a/dev-test/test-schema/typings.wrapped.ts +++ b/dev-test/test-schema/typings.wrapped.ts @@ -1,7 +1,6 @@ declare namespace GraphQL { export type Maybe = T | null; export type InputMaybe = Maybe; - export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/examples/persisted-documents-string-mode/src/gql/graphql.ts b/examples/persisted-documents-string-mode/src/gql/graphql.ts index c761f1f13d1..77380d6a05b 100644 --- a/examples/persisted-documents-string-mode/src/gql/graphql.ts +++ b/examples/persisted-documents-string-mode/src/gql/graphql.ts @@ -1,38 +1,10 @@ /* eslint-disable */ import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 Mutation = { - __typename?: 'Mutation'; - echo: Scalars['String']['output']; -}; - -export type MutationEchoArgs = { - message: Scalars['String']['input']; -}; - -export type Query = { - __typename?: 'Query'; - hello: Scalars['String']['output']; -}; - export type HelloQueryQueryVariables = Exact<{ [key: string]: never }>; -export type HelloQueryQuery = { __typename?: 'Query'; hello: string }; +export type HelloQueryQuery = { hello: string }; export class TypedDocumentString extends String diff --git a/examples/persisted-documents/src/gql/graphql.ts b/examples/persisted-documents/src/gql/graphql.ts index 5fa1fa485b9..6ac5d575fab 100644 --- a/examples/persisted-documents/src/gql/graphql.ts +++ b/examples/persisted-documents/src/gql/graphql.ts @@ -1,38 +1,10 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 Mutation = { - __typename?: 'Mutation'; - echo: Scalars['String']['output']; -}; - -export type MutationEchoArgs = { - message: Scalars['String']['input']; -}; - -export type Query = { - __typename?: 'Query'; - hello: Scalars['String']['output']; -}; - export type HelloQueryQueryVariables = Exact<{ [key: string]: never }>; -export type HelloQueryQuery = { __typename?: 'Query'; hello: string }; +export type HelloQueryQuery = { hello: string }; export const HelloQueryDocument = { __meta__: { hash: '86f01e23de1c770cabbc35b2d87f2e5fd7557b6f' }, diff --git a/examples/react/apollo-client-defer/codegen.ts b/examples/react/apollo-client-defer/codegen.ts index e679ef78f6e..dea41622933 100644 --- a/examples/react/apollo-client-defer/codegen.ts +++ b/examples/react/apollo-client-defer/codegen.ts @@ -6,6 +6,10 @@ const config: CodegenConfig = { generates: { './src/gql/': { preset: 'client', + config: { + skipTypeNameForRoot: true, + nonOptionalTypename: true, + }, }, }, hooks: { afterAllFileWrite: ['prettier --write'] }, diff --git a/examples/react/apollo-client-defer/src/gql/graphql.ts b/examples/react/apollo-client-defer/src/gql/graphql.ts index 0ef66e3d56c..6c071d96aef 100644 --- a/examples/react/apollo-client-defer/src/gql/graphql.ts +++ b/examples/react/apollo-client-defer/src/gql/graphql.ts @@ -1,50 +1,15 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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'; - alphabet: Array; - /** A field that resolves fast. */ - fastField: Scalars['String']['output']; - /** - * A field that resolves slowly. - * Maybe you want to @defer this field ;) - */ - slowField: Scalars['String']['output']; -}; - -export type QuerySlowFieldArgs = { - waitFor?: Scalars['Int']['input']; -}; - -export type SlowFieldFragmentFragment = { __typename?: 'Query'; slowField: string } & { - ' $fragmentName'?: 'SlowFieldFragmentFragment'; -}; +export type SlowFieldFragmentFragment = { slowField: string } & { ' $fragmentName'?: 'SlowFieldFragmentFragment' }; export type SlowAndFastFieldWithDeferQueryVariables = Exact<{ [key: string]: never }>; -export type SlowAndFastFieldWithDeferQuery = { __typename?: 'Query'; fastField: string } & ( - | { __typename?: 'Query'; inlinedSlowField: string } - | { __typename?: 'Query'; inlinedSlowField?: never } -) & - ({ __typename?: 'Query' } & { - ' $fragmentRefs'?: { SlowFieldFragmentFragment: Incremental }; - }); +export type SlowAndFastFieldWithDeferQuery = { fastField: string } & ( + | { inlinedSlowField: string } + | { inlinedSlowField?: never } +) & { ' $fragmentRefs'?: { SlowFieldFragmentFragment: Incremental } }; export const SlowFieldFragmentFragmentDoc = { kind: 'Document', diff --git a/examples/react/apollo-client/codegen.ts b/examples/react/apollo-client/codegen.ts index f2aa8f0746b..c0bd3435ce5 100644 --- a/examples/react/apollo-client/codegen.ts +++ b/examples/react/apollo-client/codegen.ts @@ -6,6 +6,10 @@ const config: CodegenConfig = { generates: { './src/gql/': { preset: 'client', + config: { + skipTypeNameForRoot: true, + nonOptionalTypename: true, + }, }, }, hooks: { afterAllFileWrite: ['prettier --write'] }, diff --git a/examples/react/apollo-client/src/gql/graphql.ts b/examples/react/apollo-client/src/gql/graphql.ts index 3e3297f9a59..18d55b9577d 100644 --- a/examples/react/apollo-client/src/gql/graphql.ts +++ b/examples/react/apollo-client/src/gql/graphql.ts @@ -1,1301 +1,27 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQueryQuery = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; + allFilms: { + __typename: 'FilmsConnection'; + edges: Array<{ + __typename: 'FilmsEdge'; + node: ({ __typename: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; } | null> | null; } | null; }; export type FilmItemFragment = { - __typename?: 'Film'; + __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 3e3297f9a59..da59e757081 100644 --- a/examples/react/http-executor/src/gql/graphql.ts +++ b/examples/react/http-executor/src/gql/graphql.ts @@ -1,1301 +1,22 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQueryQuery = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; - } | null> | null; + allFilms: { + edges: Array<{ node: { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } } | null } | null> | null; } | null; }; 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 6a0a756774b..9fc41dafa93 100644 --- a/examples/react/tanstack-react-query/src/gql/graphql.ts +++ b/examples/react/tanstack-react-query/src/gql/graphql.ts @@ -1,1301 +1,22 @@ /* eslint-disable */ import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQueryQuery = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; - } | null> | null; + allFilms: { + edges: Array<{ node: { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } } | null } | null> | null; } | null; }; 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 a16f53cffbf..04123d3bd0b 100644 --- a/examples/react/urql/src/gql/graphql.ts +++ b/examples/react/urql/src/gql/graphql.ts @@ -1,1301 +1,22 @@ /* eslint-disable */ import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - export type AllFilmsWithVariablesQuery199QueryVariables = Exact<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQuery199Query = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; - } | null> | null; + allFilms: { + edges: Array<{ node: { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } } | null } | null> | null; } | null; }; 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 418d7abf6c3..e99329c6584 100644 --- a/examples/typescript-esm/src/gql/graphql.ts +++ b/examples/typescript-esm/src/gql/graphql.ts @@ -1,1313 +1,22 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - export type AllPeopleQueryQueryVariables = Exact<{ [key: string]: never }>; export type AllPeopleQueryQuery = { - __typename?: 'Root'; - allPeople?: { - __typename?: 'PeopleConnection'; - edges?: Array<{ - __typename?: 'PeopleEdge'; - node?: { - __typename?: 'Person'; - name?: string | null; - homeworld?: { __typename?: 'Planet'; name?: string | null } | null; - } | null; - } | null> | null; + allPeople: { + edges: Array<{ node: { name: string | null; homeworld: { name: string | null } | null } | null } | null> | null; } | null; }; export type AllPeopleWithVariablesQueryQueryVariables = Exact<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllPeopleWithVariablesQueryQuery = { - __typename?: 'Root'; - allPeople?: { - __typename?: 'PeopleConnection'; - edges?: Array<{ - __typename?: 'PeopleEdge'; - node?: { - __typename?: 'Person'; - name?: string | null; - homeworld?: { __typename?: 'Planet'; name?: string | null } | null; - } | null; - } | null> | null; + allPeople: { + edges: Array<{ node: { name: string | null; homeworld: { 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 5a7aa68a723..42f3b927d34 100644 --- a/examples/typescript-graphql-request/src/gql/graphql.ts +++ b/examples/typescript-graphql-request/src/gql/graphql.ts @@ -1,1313 +1,22 @@ /* eslint-disable */ import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - export type AllPeopleQueryQueryVariables = Exact<{ [key: string]: never }>; export type AllPeopleQueryQuery = { - __typename?: 'Root'; - allPeople?: { - __typename?: 'PeopleConnection'; - edges?: Array<{ - __typename?: 'PeopleEdge'; - node?: { - __typename?: 'Person'; - name?: string | null; - homeworld?: { __typename?: 'Planet'; name?: string | null } | null; - } | null; - } | null> | null; + allPeople: { + edges: Array<{ node: { name: string | null; homeworld: { name: string | null } | null } | null } | null> | null; } | null; }; export type AllPeopleWithVariablesQueryQueryVariables = Exact<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllPeopleWithVariablesQueryQuery = { - __typename?: 'Root'; - allPeople?: { - __typename?: 'PeopleConnection'; - edges?: Array<{ - __typename?: 'PeopleEdge'; - node?: { - __typename?: 'Person'; - name?: string | null; - homeworld?: { __typename?: 'Planet'; name?: string | null } | null; - } | null; - } | null> | null; + allPeople: { + edges: Array<{ node: { name: string | null; homeworld: { name: string | null } | null } | null } | null> | null; } | null; }; diff --git a/examples/typescript-resolvers/src/type-defs.d.ts b/examples/typescript-resolvers/src/type-defs.d.ts index e0a7559e1f0..00691f3beeb 100644 --- a/examples/typescript-resolvers/src/type-defs.d.ts +++ b/examples/typescript-resolvers/src/type-defs.d.ts @@ -1,7 +1,6 @@ import { GraphQLResolveInfo } from 'graphql'; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/examples/vite/vite-react-cts/src/gql/graphql.ts b/examples/vite/vite-react-cts/src/gql/graphql.ts index 9ec6c267dc5..584c493815e 100644 --- a/examples/vite/vite-react-cts/src/gql/graphql.ts +++ b/examples/vite/vite-react-cts/src/gql/graphql.ts @@ -1,1300 +1,21 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - 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<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQueryQuery = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; - } | null> | null; + allFilms: { + edges: Array<{ node: { ' $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 9ec6c267dc5..584c493815e 100644 --- a/examples/vite/vite-react-mts/src/gql/graphql.ts +++ b/examples/vite/vite-react-mts/src/gql/graphql.ts @@ -1,1300 +1,21 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - 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<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQueryQuery = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; - } | null> | null; + allFilms: { + edges: Array<{ node: { ' $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 9ec6c267dc5..584c493815e 100644 --- a/examples/vite/vite-react-ts/src/gql/graphql.ts +++ b/examples/vite/vite-react-ts/src/gql/graphql.ts @@ -1,1300 +1,21 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - 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<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQueryQuery = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; - } | null> | null; + allFilms: { + edges: Array<{ node: { ' $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 7203b714c50..b58515b3392 100644 --- a/examples/vue/apollo-composable/src/gql/graphql.ts +++ b/examples/vue/apollo-composable/src/gql/graphql.ts @@ -1,1301 +1,22 @@ /* eslint-disable */ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQueryQuery = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; - } | null> | null; + allFilms: { + edges: Array<{ node: { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } } | null } | null> | null; } | null; }; 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 7203b714c50..b58515b3392 100644 --- a/examples/vue/urql/src/gql/graphql.ts +++ b/examples/vue/urql/src/gql/graphql.ts @@ -1,1301 +1,22 @@ /* eslint-disable */ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQueryQuery = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; - } | null> | null; + allFilms: { + edges: Array<{ node: { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } } | null } | null> | null; } | null; }; 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 7203b714c50..b58515b3392 100644 --- a/examples/vue/villus/src/gql/graphql.ts +++ b/examples/vue/villus/src/gql/graphql.ts @@ -1,1301 +1,22 @@ /* eslint-disable */ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 }; -}; - -/** A single film. */ -export type Film = Node & { - __typename?: 'Film'; - characterConnection?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The name of the director of this film. */ - director?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** The episode number of this film. */ - episodeID?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe; - planetConnection?: Maybe; - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>>; - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe; - speciesConnection?: Maybe; - starshipConnection?: Maybe; - /** The title of this film. */ - title?: Maybe; - vehicleConnection?: Maybe; -}; - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: 'FilmCharactersConnection'; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>>; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: 'FilmCharactersEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: 'FilmPlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: 'FilmPlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: 'FilmSpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: 'FilmSpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: 'FilmStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: 'FilmStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: 'FilmVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: 'FilmVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: 'FilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: 'FilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars['ID']['output']; -}; - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: 'PageInfo'; - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe; - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars['Boolean']['output']; - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars['Boolean']['output']; - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe; -}; - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: 'PeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: 'PeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: 'Person'; - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe; - filmConnection?: Maybe; - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe; - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe; - /** The height of the person in centimeters. */ - height?: Maybe; - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The mass of the person in kilograms. */ - mass?: Maybe; - /** The name of this person. */ - name?: Maybe; - /** The skin color of this person. */ - skinColor?: Maybe; - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe; - starshipConnection?: Maybe; - vehicleConnection?: Maybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: 'PersonFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: 'PersonFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: 'PersonStarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: 'PersonStarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: 'PersonVehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: 'PersonVehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: 'Planet'; - /** The climates of this planet. */ - climates?: Maybe>>; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The diameter of this planet in kilometers. */ - diameter?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The name of this planet. */ - name?: Maybe; - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe; - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe; - residentConnection?: Maybe; - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe; - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe; - /** The terrains of this planet. */ - terrains?: Maybe>>; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: 'PlanetFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: 'PlanetFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: 'PlanetResidentsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: 'PlanetResidentsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: 'PlanetsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: 'PlanetsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -export type Root = { - __typename?: 'Root'; - allFilms?: Maybe; - allPeople?: Maybe; - allPlanets?: Maybe; - allSpecies?: Maybe; - allStarships?: Maybe; - allVehicles?: Maybe; - film?: Maybe; - /** Fetches an object given its ID */ - node?: Maybe; - person?: Maybe; - planet?: Maybe; - species?: Maybe; - starship?: Maybe; - vehicle?: Maybe; -}; - -export type RootAllFilmsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPeopleArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllPlanetsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllSpeciesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllStarshipsArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootAllVehiclesArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -export type RootFilmArgs = { - filmID?: InputMaybe; - id?: InputMaybe; -}; - -export type RootNodeArgs = { - id: Scalars['ID']['input']; -}; - -export type RootPersonArgs = { - id?: InputMaybe; - personID?: InputMaybe; -}; - -export type RootPlanetArgs = { - id?: InputMaybe; - planetID?: InputMaybe; -}; - -export type RootSpeciesArgs = { - id?: InputMaybe; - speciesID?: InputMaybe; -}; - -export type RootStarshipArgs = { - id?: InputMaybe; - starshipID?: InputMaybe; -}; - -export type RootVehicleArgs = { - id?: InputMaybe; - vehicleID?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: 'Species'; - /** The average height of this species in centimeters. */ - averageHeight?: Maybe; - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe; - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The designation of this species, such as "sentient". */ - designation?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>>; - filmConnection?: Maybe; - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>>; - /** A planet that this species originates from. */ - homeworld?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The language commonly spoken by this species. */ - language?: Maybe; - /** The name of this species. */ - name?: Maybe; - personConnection?: Maybe; - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>>; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: 'SpeciesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: 'SpeciesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: 'SpeciesFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: 'SpeciesFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: 'SpeciesPeopleConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: 'SpeciesPeopleEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: 'Starship'; - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe; - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this starship in meters. */ - length?: Maybe; - /** The manufacturers of this starship. */ - manufacturers?: Maybe>>; - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe; - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe; - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: 'StarshipFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: 'StarshipFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: 'StarshipPilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: 'StarshipPilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: 'StarshipsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: 'StarshipsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: 'Vehicle'; - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe; - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe; - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe; - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe; - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe; - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe; - filmConnection?: Maybe; - /** The ID of an object */ - id: Scalars['ID']['output']; - /** The length of this vehicle in meters. */ - length?: Maybe; - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>>; - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe; - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe; - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe; - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe; - pilotConnection?: Maybe; - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe; - before?: InputMaybe; - first?: InputMaybe; - last?: InputMaybe; -}; - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: 'VehicleFilmsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: 'VehicleFilmsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: 'VehiclePilotsConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>>; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; -}; - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: 'VehiclePilotsEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: 'VehiclesConnection'; - /** A list of edges. */ - edges?: Maybe>>; - /** Information to aid in pagination. */ - pageInfo: PageInfo; - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe; - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>>; -}; - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: 'VehiclesEdge'; - /** A cursor for use in pagination */ - cursor: Scalars['String']['output']; - /** The item at the end of the edge */ - node?: Maybe; -}; - export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ - first: Scalars['Int']['input']; + first: number; }>; export type AllFilmsWithVariablesQueryQuery = { - __typename?: 'Root'; - allFilms?: { - __typename?: 'FilmsConnection'; - edges?: Array<{ - __typename?: 'FilmsEdge'; - node?: ({ __typename?: 'Film' } & { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } }) | null; - } | null> | null; + allFilms: { + edges: Array<{ node: { ' $fragmentRefs'?: { FilmItemFragment: FilmItemFragment } } | null } | null> | null; } | null; }; 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/yoga-tests/src/gql/graphql.ts b/examples/yoga-tests/src/gql/graphql.ts index 9d9b20ed7e2..86973327b30 100644 --- a/examples/yoga-tests/src/gql/graphql.ts +++ b/examples/yoga-tests/src/gql/graphql.ts @@ -1,44 +1,16 @@ /* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; -export type Maybe = T | null; -export type InputMaybe = T | null | undefined; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type MakeEmpty = { [_ in K]?: never }; +type Exact = { [K in keyof T]: T[K] }; 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 Mutation = { - __typename?: 'Mutation'; - echo: Scalars['String']['output']; -}; - -export type MutationEchoArgs = { - message: Scalars['String']['input']; -}; - -export type Query = { - __typename?: 'Query'; - hello: Scalars['String']['output']; -}; - export type HelloQueryQueryVariables = Exact<{ [key: string]: never }>; -export type HelloQueryQuery = { __typename?: 'Query'; hello: string }; +export type HelloQueryQuery = { hello: string }; export type EchoMutationMutationVariables = Exact<{ - message: Scalars['String']['input']; + message: string; }>; -export type EchoMutationMutation = { __typename?: 'Mutation'; echo: string }; +export type EchoMutationMutation = { echo: string }; export const HelloQueryDocument = { kind: 'Document', diff --git a/packages/plugins/other/visitor-plugin-common/src/base-documents-visitor.ts b/packages/plugins/other/visitor-plugin-common/src/base-documents-visitor.ts index 394804884e3..77045df5c9e 100644 --- a/packages/plugins/other/visitor-plugin-common/src/base-documents-visitor.ts +++ b/packages/plugins/other/visitor-plugin-common/src/base-documents-visitor.ts @@ -28,8 +28,6 @@ function getRootType(operation: OperationTypeNode, schema: GraphQLSchema) { } export interface ParsedDocumentsConfig extends ParsedTypesConfig { - addTypename: boolean; - preResolveTypes: boolean; extractAllFieldsToTypes: boolean; globalNamespace: boolean; operationResultSuffix: string; @@ -41,33 +39,11 @@ export interface ParsedDocumentsConfig extends ParsedTypesConfig { experimentalFragmentVariables: boolean; mergeFragmentTypes: boolean; customDirectives: CustomDirectivesConfig; + generatesOperationTypes: boolean; + importSchemaTypesFrom: string; } export interface RawDocumentsConfig extends RawTypesConfig { - /** - * @default true - * @description Uses primitive types where possible. - * Set to `false` in order to use `Pick` and take use the types generated by `typescript` plugin. - * - * @exampleMarkdown - * ```ts filename="codegen.ts" - * import type { CodegenConfig } from '@graphql-codegen/cli'; - * - * const config: CodegenConfig = { - * // ... - * generates: { - * 'path/to/file': { - * // plugins... - * config: { - * preResolveTypes: false - * }, - * }, - * }, - * }; - * export default config; - * ``` - */ - preResolveTypes?: boolean; /** * @default false * @description Avoid adding `__typename` for root types. This is ignored when a selection explicitly specifies `__typename`. @@ -175,6 +151,54 @@ export interface RawDocumentsConfig extends RawTypesConfig { * ``` */ customDirectives?: CustomDirectivesConfig; + + /** + * @description Whether to generate operation types such as Variables, Query/Mutation/Subscription selection set, and Fragment types + * This can be used with `importSchemaTypesFrom` to generate shared used Enums and Input. + * @default true + * @exampleMarkdown + * ```ts filename="codegen.ts" + * import type { CodegenConfig } from '@graphql-codegen/cli'; + * + * const config: CodegenConfig = { + * // ... + * generates: { + * 'path/to/file.ts': { + * plugins: ['typescript-operations'], + * config: { + * generatesOperationTypes: false, + * }, + * }, + * }, + * }; + * export default config; + * ``` + */ + generatesOperationTypes?: boolean; + + /** + * @description The absolute (prefixed with `~`) or relative path from `cwd` to the shared used Enums and Input (See `generatesOperationTypes`). + * @default true + * @exampleMarkdown + * ```ts filename="codegen.ts" + * import type { CodegenConfig } from '@graphql-codegen/cli'; + * + * const config: CodegenConfig = { + * // ... + * generates: { + * 'path/to/file.ts': { + * plugins: ['typescript-operations'], + * config: { + * importSchemaTypesFrom: './path/to/shared-types.ts', // relative + * importSchemaTypesFrom: '~@my-org/package' // absolute + * }, + * }, + * }, + * }; + * export default config; + * ``` + */ + importSchemaTypesFrom?: string; } export class BaseDocumentsVisitor< @@ -196,17 +220,17 @@ export class BaseDocumentsVisitor< exportFragmentSpreadSubTypes: getConfigValue(rawConfig.exportFragmentSpreadSubTypes, false), enumPrefix: getConfigValue(rawConfig.enumPrefix, true), enumSuffix: getConfigValue(rawConfig.enumSuffix, true), - preResolveTypes: getConfigValue(rawConfig.preResolveTypes, true), dedupeOperationSuffix: getConfigValue(rawConfig.dedupeOperationSuffix, false), omitOperationSuffix: getConfigValue(rawConfig.omitOperationSuffix, false), skipTypeNameForRoot: getConfigValue(rawConfig.skipTypeNameForRoot, false), namespacedImportName: getConfigValue(rawConfig.namespacedImportName, null), experimentalFragmentVariables: getConfigValue(rawConfig.experimentalFragmentVariables, false), - addTypename: !rawConfig.skipTypename, globalNamespace: !!rawConfig.globalNamespace, operationResultSuffix: getConfigValue(rawConfig.operationResultSuffix, ''), scalars: buildScalarsFromConfig(_schema, rawConfig, defaultScalars), customDirectives: getConfigValue(rawConfig.customDirectives, { apolloUnmask: false }), + generatesOperationTypes: getConfigValue(rawConfig.generatesOperationTypes, true), + importSchemaTypesFrom: getConfigValue(rawConfig.importSchemaTypesFrom, ''), ...((additionalConfig || {}) as any), }); @@ -238,10 +262,6 @@ export class BaseDocumentsVisitor< return this._schema; } - public get addTypename(): boolean { - return this._parsedConfig.addTypename; - } - private handleAnonymousOperation(node: OperationDefinitionNode): string { const name = node.name?.value; @@ -261,6 +281,10 @@ export class BaseDocumentsVisitor< } FragmentDefinition(node: FragmentDefinitionNode): string { + if (!this.config.generatesOperationTypes) { + return null; + } + const fragmentRootType = this._schema.getType(node.typeCondition.name.value); const selectionSet = this._selectionSetToObject.createNext(fragmentRootType, node.selectionSet); const fragmentSuffix = this.getFragmentSuffix(node); @@ -289,7 +313,11 @@ export class BaseDocumentsVisitor< return variablesBlock; } - OperationDefinition(node: OperationDefinitionNode): string { + OperationDefinition(node: OperationDefinitionNode): string | null { + if (!this.config.generatesOperationTypes) { + return null; + } + const name = this.handleAnonymousOperation(node); const operationRootType = getRootType(node.operation, this._schema); diff --git a/packages/plugins/other/visitor-plugin-common/src/base-types-visitor.ts b/packages/plugins/other/visitor-plugin-common/src/base-types-visitor.ts index a37350bf7a6..b4d9a405e85 100644 --- a/packages/plugins/other/visitor-plugin-common/src/base-types-visitor.ts +++ b/packages/plugins/other/visitor-plugin-common/src/base-types-visitor.ts @@ -2,9 +2,7 @@ import { DirectiveDefinitionNode, DirectiveNode, EnumTypeDefinitionNode, - EnumValueDefinitionNode, FieldDefinitionNode, - GraphQLEnumType, GraphQLSchema, InputObjectTypeDefinitionNode, InputValueDefinitionNode, @@ -40,9 +38,12 @@ import { indent, isOneOfInputObjectType, transformComment, + getNodeComment, wrapWithSingleQuotes, } from './utils.js'; import { OperationVariablesToObject } from './variables-to-object.js'; +import { buildEnumValuesBlock } from './convert-schema-enum-to-declaration-block-string.js'; +import { buildTypeImport, getEnumsImports } from './imports.js'; export interface ParsedTypesConfig extends ParsedConfig { enumValues: ParsedEnumValuesMap; @@ -493,8 +494,6 @@ export interface RawTypesConfig extends RawConfig { directiveArgumentAndInputFieldMappingTypeSuffix?: string; } -const onlyUnderscoresPattern = /^_+$/; - export class BaseTypesVisitor< TRawConfig extends RawTypesConfig = RawTypesConfig, TPluginConfig extends ParsedTypesConfig = ParsedTypesConfig @@ -561,12 +560,24 @@ export class BaseTypesVisitor< const mappedValue = this.config.scalars[enumName]; if (mappedValue.input.isExternal) { - res.push(this._buildTypeImport(mappedValue.input.import, mappedValue.input.source, mappedValue.input.default)); + res.push( + buildTypeImport({ + identifier: mappedValue.input.import, + source: mappedValue.input.source, + asDefault: mappedValue.input.default, + useTypeImports: this.config.useTypeImports, + }) + ); } if (mappedValue.output.isExternal) { res.push( - this._buildTypeImport(mappedValue.output.import, mappedValue.output.source, mappedValue.output.default) + buildTypeImport({ + identifier: mappedValue.output.import, + source: mappedValue.output.source, + asDefault: mappedValue.output.default, + useTypeImports: this.config.useTypeImports, + }) ); } @@ -580,7 +591,12 @@ export class BaseTypesVisitor< const mappedValue = this.config.directiveArgumentAndInputFieldMappings[directive]; if (mappedValue.isExternal) { - return this._buildTypeImport(mappedValue.import, mappedValue.source, mappedValue.default); + return buildTypeImport({ + identifier: mappedValue.import, + source: mappedValue.source, + asDefault: mappedValue.default, + useTypeImports: this.config.useTypeImports, + }); } return null; @@ -703,7 +719,7 @@ export class BaseTypesVisitor< const typeString = node.type as any as string; const { type } = this._parsedConfig.declarationKind; - const comment = this.getNodeComment(node); + const comment = getNodeComment(node); return comment + indent(`${node.name.value}: ${typeString}${this.getPunctuation(type)}`); } @@ -813,58 +829,11 @@ export class BaseTypesVisitor< return ''; } - protected _buildTypeImport(identifier: string, source: string, asDefault = false): string { - const { useTypeImports } = this.config; - if (asDefault) { - if (useTypeImports) { - return `import type { default as ${identifier} } from '${source}';`; - } - return `import ${identifier} from '${source}';`; - } - return `import${useTypeImports ? ' type' : ''} { ${identifier} } from '${source}';`; - } - - protected handleEnumValueMapper( - typeIdentifier: string, - importIdentifier: string | null, - sourceIdentifier: string | null, - sourceFile: string | null - ): string[] { - if (importIdentifier !== sourceIdentifier) { - // use namespace import to dereference nested enum - // { enumValues: { MyEnum: './my-file#NS.NestedEnum' } } - return [ - this._buildTypeImport(importIdentifier || sourceIdentifier, sourceFile), - `import ${typeIdentifier} = ${sourceIdentifier};`, - ]; - } - if (sourceIdentifier !== typeIdentifier) { - return [this._buildTypeImport(`${sourceIdentifier} as ${typeIdentifier}`, sourceFile)]; - } - return [this._buildTypeImport(importIdentifier || sourceIdentifier, sourceFile)]; - } - public getEnumsImports(): string[] { - return Object.keys(this.config.enumValues) - .flatMap(enumName => { - const mappedValue = this.config.enumValues[enumName]; - - if (mappedValue.sourceFile) { - if (mappedValue.isDefault) { - return [this._buildTypeImport(mappedValue.typeIdentifier, mappedValue.sourceFile, true)]; - } - - return this.handleEnumValueMapper( - mappedValue.typeIdentifier, - mappedValue.importIdentifier, - mappedValue.sourceIdentifier, - mappedValue.sourceFile - ); - } - - return []; - }) - .filter(Boolean); + return getEnumsImports({ + enumValues: this.config.enumValues, + useTypeImports: this.config.useTypeImports, + }); } EnumTypeDefinition(node: EnumTypeDefinitionNode): string { @@ -885,7 +854,23 @@ export class BaseTypesVisitor< }) ) .withComment(node.description.value) - .withBlock(this.buildEnumValuesBlock(enumName, node.values)).string; + .withBlock( + buildEnumValuesBlock({ + typeName: enumName, + values: node.values, + schema: this._schema, + naming: { + convert: this.config.convert, + typesPrefix: this.config.typesPrefix, + useTypesPrefix: this.config.enumPrefix, + typesSuffix: this.config.typesSuffix, + useTypesSuffix: this.config.enumSuffix, + }, + ignoreEnumValuesFromSchema: this.config.ignoreEnumValuesFromSchema, + declarationBlockConfig: this._declarationBlockConfig, + enumValues: this.config.enumValues, + }) + ).string; } protected makeValidEnumIdentifier(identifier: string): string { @@ -895,46 +880,6 @@ export class BaseTypesVisitor< return identifier; } - protected buildEnumValuesBlock(typeName: string, values: ReadonlyArray): string { - const schemaEnumType: GraphQLEnumType | undefined = this._schema - ? (this._schema.getType(typeName) as GraphQLEnumType) - : undefined; - - return values - .map(enumOption => { - const optionName = this.makeValidEnumIdentifier( - this.convertName(enumOption, { - useTypesPrefix: false, - // We can only strip out the underscores if the value contains other - // characters. Otherwise we'll generate syntactically invalid code. - transformUnderscore: !onlyUnderscoresPattern.test(enumOption.name.value), - }) - ); - const comment = this.getNodeComment(enumOption); - const schemaEnumValue = - schemaEnumType && !this.config.ignoreEnumValuesFromSchema - ? schemaEnumType.getValue(enumOption.name.value).value - : undefined; - let enumValue: string | number = - typeof schemaEnumValue === 'undefined' ? enumOption.name.value : schemaEnumValue; - - if (typeof this.config.enumValues[typeName]?.mappedValues?.[enumValue] !== 'undefined') { - enumValue = this.config.enumValues[typeName].mappedValues[enumValue]; - } - - return ( - comment + - indent( - `${optionName}${this._declarationBlockConfig.enumNameValueSeparator} ${wrapWithSingleQuotes( - enumValue, - typeof schemaEnumValue !== 'undefined' - )}` - ) - ); - }) - .join(',\n'); - } - DirectiveDefinition(_node: DirectiveDefinitionNode): string { return ''; } @@ -1050,28 +995,6 @@ export class BaseTypesVisitor< return null; } - getNodeComment(node: FieldDefinitionNode | EnumValueDefinitionNode | InputValueDefinitionNode): string { - let commentText = node.description?.value; - const deprecationDirective = node.directives.find(v => v.name.value === 'deprecated'); - if (deprecationDirective) { - const deprecationReason = this.getDeprecationReason(deprecationDirective); - commentText = `${commentText ? `${commentText}\n` : ''}@deprecated ${deprecationReason}`; - } - const comment = transformComment(commentText, 1); - return comment; - } - - protected getDeprecationReason(directive: DirectiveNode): string | void { - if (directive.name.value === 'deprecated') { - let reason = 'Field no longer supported'; - const deprecatedReason = directive.arguments[0]; - if (deprecatedReason && deprecatedReason.value.kind === Kind.STRING) { - reason = deprecatedReason.value.value; - } - return reason; - } - } - protected wrapWithListType(str: string): string { return `Array<${str}>`; } diff --git a/packages/plugins/other/visitor-plugin-common/src/base-visitor.ts b/packages/plugins/other/visitor-plugin-common/src/base-visitor.ts index 5f83d587e6c..a2c18c8f486 100644 --- a/packages/plugins/other/visitor-plugin-common/src/base-visitor.ts +++ b/packages/plugins/other/visitor-plugin-common/src/base-visitor.ts @@ -29,6 +29,7 @@ export interface ParsedConfig { addTypename: boolean; nonOptionalTypename: boolean; extractAllFieldsToTypes: boolean; + extractAllFieldsToTypesFieldNamesOnly: boolean; externalFragments: LoadedFragment[]; fragmentImports: ImportDeclaration[]; immutableTypes: boolean; @@ -375,6 +376,15 @@ export interface RawConfig { */ extractAllFieldsToTypes?: boolean; + /** + * @default false + * @description When used with `extractAllFieldsToTypes`, generates type names based only on field names, + * without including GraphQL type names. This produces Apollo Tooling-compatible type names. + * For example, `QueryName_fieldName_nestedField` instead of `QueryName_fieldName_TypeName_nestedField_FieldTypeName`. + * Note: This option has no effect when `extractAllFieldsToTypes` is disabled. + */ + extractAllFieldsToTypesFieldNamesOnly?: boolean; + /** * @default false * @description If you prefer to have each field in generated types printed on a new line, set this to true. @@ -411,6 +421,7 @@ export class BaseVisitor { + if (enumValues[enumName]?.sourceFile) { + return `export { ${enumValues[enumName].typeIdentifier} };\n`; + } + + const getValueFromConfig = (enumValue: string | number) => { + if (typeof enumValues[enumName]?.mappedValues?.[enumValue] !== 'undefined') { + return enumValues[enumName].mappedValues[enumValue]; + } + return null; + }; + + const withFutureAddedValue = [futureProofEnums ? [indent('| ' + wrapWithSingleQuotes('%future added value'))] : []]; + + const enumTypeName = convertName({ + options: { + typesPrefix: naming.typesPrefix, + typesSuffix: naming.typesSuffix, + useTypesPrefix: naming.useTypesPrefix, + useTypesSuffix: naming.useTypesSuffix, + }, + convert: () => naming.convert(node), + }); + + if (outputType === 'string-literal') { + return new DeclarationBlock(declarationBlockConfig) + .export() + .asKind('type') + .withComment(node.description?.value) + .withName(enumTypeName) + .withContent( + '\n' + + node.values + .map(enumOption => { + const name = enumOption.name.value; + const enumValue: string | number = getValueFromConfig(name) ?? name; + const comment = transformComment(enumOption.description?.value, 1); + + return comment + indent('| ' + wrapWithSingleQuotes(enumValue)); + }) + .concat(...withFutureAddedValue) + .join('\n') + ).string; + } + + if (outputType === 'native-numeric') { + return new DeclarationBlock(declarationBlockConfig) + .export() + .withComment(node.description?.value) + .withName(enumTypeName) + .asKind('enum') + .withBlock( + node.values + .map((enumOption, i) => { + const valueFromConfig = getValueFromConfig(enumOption.name.value); + const enumValue: string | number = valueFromConfig ?? i; + const comment = transformComment(enumOption.description?.value, 1); + const optionName = makeValidEnumIdentifier( + convertName({ + options: { + typesPrefix: naming.typesPrefix, + typesSuffix: naming.typesSuffix, + useTypesPrefix: false, + }, + convert: () => naming.convert(enumOption, { transformUnderscore: true }), + }) + ); + return comment + indent(optionName) + ` = ${enumValue}`; + }) + .concat(...withFutureAddedValue) + .join(',\n') + ).string; + } + + if (outputType === 'const') { + const typeName = `export type ${enumTypeName} = typeof ${enumTypeName}[keyof typeof ${enumTypeName}];`; + const enumAsConst = new DeclarationBlock({ + ...declarationBlockConfig, + blockTransformer: block => { + return block + ' as const'; + }, + }) + .export() + .asKind('const') + .withName(enumTypeName) + .withComment(node.description?.value) + .withBlock( + node.values + .map(enumOption => { + const optionName = makeValidEnumIdentifier( + convertName({ + options: { + typesPrefix: naming.typesPrefix, + typesSuffix: naming.typesPrefix, + }, + convert: () => + naming.convert(enumOption, { + transformUnderscore: true, + }), + }) + ); + const comment = transformComment(enumOption.description?.value, 1); + const name = enumOption.name.value; + const enumValue: string | number = getValueFromConfig(name) ?? name; + + return comment + indent(`${optionName}: ${wrapWithSingleQuotes(enumValue)}`); + }) + .join(',\n') + ).string; + + return [enumAsConst, typeName].join('\n'); + } + + return new DeclarationBlock(declarationBlockConfig) + .export() + .asKind(outputType === 'native-const' ? 'const enum' : 'enum') + .withName(enumTypeName) + .withComment(node.description?.value) + .withBlock( + buildEnumValuesBlock({ + typeName: enumName, + values: node.values, + schema, + naming, + ignoreEnumValuesFromSchema, + declarationBlockConfig, + enumValues, + }) + ).string; +}; + +export const buildEnumValuesBlock = ({ + typeName, + values, + schema, + naming, + ignoreEnumValuesFromSchema, + declarationBlockConfig, + enumValues, +}: Pick< + ConvertSchemaEnumToDeclarationBlockString, + 'schema' | 'naming' | 'ignoreEnumValuesFromSchema' | 'declarationBlockConfig' | 'enumValues' +> & { + typeName: string; + values: ReadonlyArray; +}): string => { + const schemaEnumType: GraphQLEnumType | undefined = schema + ? (schema.getType(typeName) as GraphQLEnumType) + : undefined; + + return values + .map(enumOption => { + const onlyUnderscoresPattern = /^_+$/; + const optionName = makeValidEnumIdentifier( + convertName({ + options: { + useTypesPrefix: false, + typesPrefix: naming.typesPrefix, + typesSuffix: naming.typesSuffix, + }, + convert: () => + naming.convert(enumOption, { + // We can only strip out the underscores if the value contains other + // characters. Otherwise we'll generate syntactically invalid code. + transformUnderscore: !onlyUnderscoresPattern.test(enumOption.name.value), + }), + }) + ); + const comment = getNodeComment(enumOption); + const schemaEnumValue = + schemaEnumType && !ignoreEnumValuesFromSchema + ? schemaEnumType.getValue(enumOption.name.value).value + : undefined; + let enumValue: string | number = typeof schemaEnumValue === 'undefined' ? enumOption.name.value : schemaEnumValue; + + if (typeof enumValues[typeName]?.mappedValues?.[enumValue] !== 'undefined') { + enumValue = enumValues[typeName].mappedValues[enumValue]; + } + + return ( + comment + + indent( + `${optionName}${declarationBlockConfig.enumNameValueSeparator} ${wrapWithSingleQuotes( + enumValue, + typeof schemaEnumValue !== 'undefined' + )}` + ) + ); + }) + .join(',\n'); +}; + +const makeValidEnumIdentifier = (identifier: string): string => { + if (/^[0-9]/.exec(identifier)) { + return wrapWithSingleQuotes(identifier, true); + } + return identifier; +}; + +const convertName = ({ + convert, + options, +}: { + options: { + typesPrefix: string; + useTypesPrefix?: boolean; + typesSuffix: string; + useTypesSuffix?: boolean; + }; + convert: () => string; +}): string => { + const useTypesPrefix = typeof options.useTypesPrefix === 'boolean' ? options.useTypesPrefix : true; + const useTypesSuffix = typeof options.useTypesSuffix === 'boolean' ? options.useTypesSuffix : true; + + let convertedName = ''; + + if (useTypesPrefix) { + convertedName += options.typesPrefix; + } + + convertedName += convert(); + + if (useTypesSuffix) { + convertedName += options.typesSuffix; + } + + return convertedName; +}; diff --git a/packages/plugins/other/visitor-plugin-common/src/graphql-type-utils.ts b/packages/plugins/other/visitor-plugin-common/src/graphql-type-utils.ts new file mode 100644 index 00000000000..82634cd2849 --- /dev/null +++ b/packages/plugins/other/visitor-plugin-common/src/graphql-type-utils.ts @@ -0,0 +1,13 @@ +import { type GraphQLNamedType, isIntrospectionType, isSpecifiedScalarType } from 'graphql'; + +export const isNativeNamedType = (namedType: GraphQLNamedType): boolean => { + // "Native" NamedType in this context means the following: + // 1. introspection types i.e. with `__` prefixes + // 2. base scalars e.g. Boolean, Int, etc. + // 3. Other natives (mostly base scalars) which was not defined in the schema i.e. no `astNode` + if (isSpecifiedScalarType(namedType) || isIntrospectionType(namedType) || !namedType.astNode) { + return true; + } + + return false; +}; diff --git a/packages/plugins/other/visitor-plugin-common/src/imports.ts b/packages/plugins/other/visitor-plugin-common/src/imports.ts index b9e4cbde6ba..1a04f48e7f9 100644 --- a/packages/plugins/other/visitor-plugin-common/src/imports.ts +++ b/packages/plugins/other/visitor-plugin-common/src/imports.ts @@ -1,5 +1,6 @@ import { dirname, isAbsolute, join, relative, resolve } from 'path'; import parse from 'parse-filepath'; +import type { ParsedEnumValuesMap } from './types'; export type ImportDeclaration = { outputPath: string; @@ -98,3 +99,88 @@ export function clearExtension(path: string): string { export function fixLocalFilePath(path: string): string { return path.startsWith('..') ? path : `./${path}`; } + +export function getEnumsImports({ + enumValues, + useTypeImports, +}: { + enumValues: ParsedEnumValuesMap; + useTypeImports: boolean; +}): string[] { + function handleEnumValueMapper({ + typeIdentifier, + importIdentifier, + sourceIdentifier, + sourceFile, + useTypeImports, + }: { + typeIdentifier: string; + importIdentifier: string | null; + sourceIdentifier: string | null; + sourceFile: string | null; + useTypeImports: boolean; + }): string[] { + if (importIdentifier !== sourceIdentifier) { + // use namespace import to dereference nested enum + // { enumValues: { MyEnum: './my-file#NS.NestedEnum' } } + return [ + buildTypeImport({ identifier: importIdentifier || sourceIdentifier, source: sourceFile, useTypeImports }), + `import ${typeIdentifier} = ${sourceIdentifier};`, + ]; + } + if (sourceIdentifier !== typeIdentifier) { + return [ + buildTypeImport({ identifier: `${sourceIdentifier} as ${typeIdentifier}`, source: sourceFile, useTypeImports }), + ]; + } + return [buildTypeImport({ identifier: importIdentifier || sourceIdentifier, source: sourceFile, useTypeImports })]; + } + + return Object.keys(enumValues) + .flatMap(enumName => { + const mappedValue = enumValues[enumName]; + if (mappedValue.sourceFile) { + if (mappedValue.isDefault) { + return [ + buildTypeImport({ + identifier: mappedValue.typeIdentifier, + source: mappedValue.sourceFile, + asDefault: true, + useTypeImports, + }), + ]; + } + + return handleEnumValueMapper({ + typeIdentifier: mappedValue.typeIdentifier, + importIdentifier: mappedValue.importIdentifier, + sourceIdentifier: mappedValue.sourceIdentifier, + sourceFile: mappedValue.sourceFile, + useTypeImports, + }); + } + + return []; + }) + .filter(Boolean); +} + +export function buildTypeImport({ + identifier, + source, + useTypeImports, + asDefault = false, +}: { + identifier: string; + source: string; + useTypeImports: boolean; + asDefault?: boolean; +}): string { + if (asDefault) { + if (useTypeImports) { + return `import type { default as ${identifier} } from '${source}';`; + } + return `import ${identifier} from '${source}';`; + } + return `import${useTypeImports ? ' type' : ''} { ${identifier} } from '${source}';`; +} diff --git a/packages/plugins/other/visitor-plugin-common/src/index.ts b/packages/plugins/other/visitor-plugin-common/src/index.ts index a196546db4f..f645aa973c3 100644 --- a/packages/plugins/other/visitor-plugin-common/src/index.ts +++ b/packages/plugins/other/visitor-plugin-common/src/index.ts @@ -17,3 +17,5 @@ export * from './selection-set-to-object.js'; export * from './types.js'; export * from './utils.js'; export * from './variables-to-object.js'; +export * from './convert-schema-enum-to-declaration-block-string.js'; +export * from './graphql-type-utils.js'; 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 relevant = grouped[typeName].filter(Boolean); return relevant.map(objDefinition => { - const name = fieldName ? `${fieldName}_${typeName}` : typeName; + // When extractAllFieldsToTypesFieldNamesOnly is enabled, don't append typeName + // to generate Apollo Tooling-compatible type names + let name: string; + if (fieldName) { + name = this._config.extractAllFieldsToTypesFieldNamesOnly ? fieldName : `${fieldName}_${typeName}`; + } else { + name = typeName; + } return { name, content: typeof objDefinition === 'string' ? objDefinition : objDefinition.union.join(' | '), @@ -877,10 +899,6 @@ export class SelectionSetToObject { + let commentText = node.description?.value; + const deprecationDirective = node.directives.find(v => v.name.value === 'deprecated'); + if (deprecationDirective) { + const deprecationReason = getDeprecationReason(deprecationDirective); + commentText = `${commentText ? `${commentText}\n` : ''}@deprecated ${deprecationReason}`; + } + const comment = transformComment(commentText, 1); + return comment; +}; + +const getDeprecationReason = (directive: DirectiveNode): string | void => { + if (directive.name.value === 'deprecated') { + let reason = 'Field no longer supported'; + const deprecatedReason = directive.arguments[0]; + if (deprecatedReason && deprecatedReason.value.kind === Kind.STRING) { + reason = deprecatedReason.value.value; + } + return reason; + } +}; diff --git a/packages/plugins/typescript/operations/package.json b/packages/plugins/typescript/operations/package.json index a890d6a6af8..2e1f8f8424c 100644 --- a/packages/plugins/typescript/operations/package.json +++ b/packages/plugins/typescript/operations/package.json @@ -15,6 +15,7 @@ "dependencies": { "@graphql-codegen/plugin-helpers": "^6.0.0", "@graphql-codegen/typescript": "^5.0.4", + "@graphql-codegen/schema-ast": "^5.0.0", "@graphql-codegen/visitor-plugin-common": "6.1.2", "auto-bind": "~4.0.0", "tslib": "~2.6.0" diff --git a/packages/plugins/typescript/operations/src/config.ts b/packages/plugins/typescript/operations/src/config.ts index ec83928eecc..44fb213b786 100644 --- a/packages/plugins/typescript/operations/src/config.ts +++ b/packages/plugins/typescript/operations/src/config.ts @@ -1,4 +1,9 @@ -import { AvoidOptionalsConfig, RawDocumentsConfig } from '@graphql-codegen/visitor-plugin-common'; +import { + AvoidOptionalsConfig, + type ConvertSchemaEnumToDeclarationBlockString, + type EnumValuesMap, + RawDocumentsConfig, +} from '@graphql-codegen/visitor-plugin-common'; /** * @description This plugin generates TypeScript types based on your GraphQLSchema _and_ your GraphQL operations and fragments. @@ -336,4 +341,121 @@ export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig { nullability?: { errorHandlingClient: boolean; }; + + /** + * @description Controls the enum output type. Options: `string-literal` | `native-numeric` | `const` | `native-const` | `native`; + * @default `string-literal` + * + * @exampleMarkdown + * ```ts filename="codegen.ts" + * import type { CodegenConfig } from '@graphql-codegen/cli' + * + * const config: CodegenConfig = { + * // ... + * generates: { + * 'path/to/file.ts': { + * plugins: ['typescript-operations'], + * config: { + * enumType: 'string-literal', + * } + * } + * } + * } + * export default config + */ + enumType?: ConvertSchemaEnumToDeclarationBlockString['outputType']; + + /** + * @description Overrides the default value of enum values declared in your GraphQL schema. + * You can also map the entire enum to an external type by providing a string that of `module#type`. + * + * @exampleMarkdown + * ## With Custom Values + * ```ts filename="codegen.ts" + * import type { CodegenConfig } from '@graphql-codegen/cli'; + * + * const config: CodegenConfig = { + * // ... + * generates: { + * 'path/to/file': { + * // plugins... + * config: { + * enumValues: { + * MyEnum: { + * A: 'foo' + * } + * } + * }, + * }, + * }, + * }; + * export default config; + * ``` + * + * ## With External Enum + * ```ts filename="codegen.ts" + * import type { CodegenConfig } from '@graphql-codegen/cli'; + * + * const config: CodegenConfig = { + * // ... + * generates: { + * 'path/to/file': { + * // plugins... + * config: { + * enumValues: { + * MyEnum: './my-file#MyCustomEnum', + * } + * }, + * }, + * }, + * }; + * export default config; + * ``` + * + * ## Import All Enums from a file + * ```ts filename="codegen.ts" + * import type { CodegenConfig } from '@graphql-codegen/cli'; + * + * const config: CodegenConfig = { + * // ... + * generates: { + * 'path/to/file': { + * // plugins... + * config: { + * enumValues: { + * MyEnum: './my-file', + * } + * }, + * }, + * }, + * }; + * export default config; + * ``` + */ + enumValues?: EnumValuesMap; + + /** + * @description This option controls whether or not a catch-all entry is added to enum type definitions for values that may be added in the future. + * This is useful if you are using `relay`. + * @default false + * + * @exampleMarkdown + * ```ts filename="codegen.ts" + * import type { CodegenConfig } from '@graphql-codegen/cli' + * + * const config: CodegenConfig = { + * // ... + * generates: { + * 'path/to/file.ts': { + * plugins: ['typescript-operations'], + * config: { + * futureProofEnums: true + * } + * } + * } + * } + * export default config + * ``` + */ + futureProofEnums?: boolean; } diff --git a/packages/plugins/typescript/operations/src/index.ts b/packages/plugins/typescript/operations/src/index.ts index 19f7fe485a9..cbc79218331 100644 --- a/packages/plugins/typescript/operations/src/index.ts +++ b/packages/plugins/typescript/operations/src/index.ts @@ -1,15 +1,17 @@ import { oldVisit, PluginFunction, Types } from '@graphql-codegen/plugin-helpers'; -import { LoadedFragment, optimizeOperations } from '@graphql-codegen/visitor-plugin-common'; -import { concatAST, FragmentDefinitionNode, GraphQLSchema, Kind } from 'graphql'; +import { transformSchemaAST } from '@graphql-codegen/schema-ast'; +import { optimizeOperations } from '@graphql-codegen/visitor-plugin-common'; +import { concatAST, GraphQLSchema } from 'graphql'; import { TypeScriptDocumentsPluginConfig } from './config.js'; import { TypeScriptDocumentsVisitor } from './visitor.js'; export { TypeScriptDocumentsPluginConfig } from './config.js'; export const plugin: PluginFunction = async ( - inputSchema: GraphQLSchema, - rawDocuments: Types.DocumentFile[], - config: TypeScriptDocumentsPluginConfig + inputSchema, + rawDocuments, + config, + { outputFile } ) => { const schema = config.nullability?.errorHandlingClient ? await semanticToStrict(inputSchema) : inputSchema; @@ -20,38 +22,30 @@ export const plugin: PluginFunction v.document)); - const allFragments: LoadedFragment[] = [ - ...(allAst.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION) as FragmentDefinitionNode[]).map( - fragmentDef => ({ - node: fragmentDef, - name: fragmentDef.name.value, - onType: fragmentDef.typeCondition.name.value, - isExternal: false, - }) - ), - ...(config.externalFragments || []), - ]; - - const visitor = new TypeScriptDocumentsVisitor(schema, config, allFragments); + const visitor = new TypeScriptDocumentsVisitor(schema, config, allAst, outputFile); - const visitorResult = oldVisit(allAst, { - leave: visitor, - }); + const operationsResult = oldVisit(allAst, { leave: visitor }); - let content = visitorResult.definitions.join('\n'); + const operationsDefinitions = operationsResult.definitions; if (config.addOperationExport) { - const exportConsts = []; - for (const d of allAst.definitions) { if ('name' in d) { - exportConsts.push(`export declare const ${d.name.value}: import("graphql").DocumentNode;`); + operationsDefinitions.push(`export declare const ${d.name.value}: import("graphql").DocumentNode;`); } } - - content = visitorResult.definitions.concat(exportConsts).join('\n'); } + const schemaTypes = oldVisit(transformSchemaAST(schema, config).ast, { leave: visitor }); + + // IMPORTANT: when a visitor leaves a node with no transformation logic, + // It will leave the node as an object. + // Here, we filter in nodes that have been turned into strings, i.e. they have been transformed + // This way, we do not have to explicitly declare a method for every node type to convert them to null + const schemaTypesDefinitions = schemaTypes.definitions.filter(def => typeof def === 'string'); + + let content = [...schemaTypesDefinitions, ...operationsDefinitions].join('\n'); + if (config.globalNamespace) { content = ` declare global { @@ -60,7 +54,14 @@ export const plugin: PluginFunction { - transformPrimitiveFields( - schemaType: GraphQLObjectType | GraphQLInterfaceType, - fields: PrimitiveField[], - unsetTypes?: boolean - ): ProcessResult { - if (fields.length === 0) { - return []; - } - - const parentName = - (this.config.namespacedImportName ? `${this.config.namespacedImportName}.` : '') + - this.config.convertName(schemaType.name, { - useTypesPrefix: true, - }); - - if (unsetTypes) { - const escapedFieldNames = fields.map(field => `'${field.fieldName}'`); - return [formattedUnionTransform('MakeEmpty', parentName, escapedFieldNames)]; - } - - let hasConditionals = false; - const escapedConditionalsList: string[] = []; - const escapedFieldNames = fields.map(field => { - if (field.isConditional) { - hasConditionals = true; - escapedConditionalsList.push(`'${field.fieldName}'`); - } - return `'${field.fieldName}'`; - }); - let resString = formattedUnionTransform('Pick', parentName, escapedFieldNames); - - if (hasConditionals) { - const avoidOptional = - // TODO: check type and exec only if relevant - this.config.avoidOptionals === true || - (typeof this.config.avoidOptionals === 'object' && - (this.config.avoidOptionals.field || - this.config.avoidOptionals.inputValue || - this.config.avoidOptionals.object)); - - const transform = avoidOptional ? 'MakeMaybe' : 'MakeOptional'; - resString = `${ - this.config.namespacedImportName ? `${this.config.namespacedImportName}.` : '' - }${formattedUnionTransform(transform, resString, escapedConditionalsList)}`; - } - return [resString]; - } - - transformTypenameField(type: string, name: string): ProcessResult { - return [`{ ${name}: ${type} }`]; - } - - transformAliasesPrimitiveFields( - schemaType: GraphQLObjectType | GraphQLInterfaceType, - fields: PrimitiveAliasedFields[] - ): ProcessResult { - if (fields.length === 0) { - return []; - } - - const parentName = - (this.config.namespacedImportName ? `${this.config.namespacedImportName}.` : '') + - this.config.convertName(schemaType.name, { - useTypesPrefix: true, - }); - - const selections = fields.map(aliasedField => { - const value = - aliasedField.fieldName === '__typename' ? `'${schemaType.name}'` : `${parentName}['${aliasedField.fieldName}']`; - - return `${aliasedField.alias}: ${value}`; - }); - return [formatSelections(selections)]; - } - - transformLinkFields(fields: LinkField[]): ProcessResult { - if (fields.length === 0) { - return []; - } - - const selections = fields.map(field => `${field.alias || field.name}: ${field.selectionSet}`); - - return [formatSelections(selections)]; - } -} - -/** Equivalent to `${transformName}<${target}, ${unionElements.join(' | ')}>`, but with line feeds if necessary */ -function formattedUnionTransform(transformName: string, target: string, unionElements: string[]): string { - if (unionElements.length > 3) { - return `${transformName}<\n ${target},\n | ${unionElements.join('\n | ')}\n >`; - } - return `${transformName}<${target}, ${unionElements.join(' | ')}>`; -} - -/** Equivalent to `{ ${selections.join(', ')} }`, but with line feeds if necessary */ -function formatSelections(selections: string[]): string { - if (selections.length > 1) { - return `{\n ${selections.map(s => s.replace(/\n/g, '\n ')).join(',\n ')},\n }`; - } - return `{ ${selections.join(', ')} }`; -} diff --git a/packages/plugins/typescript/operations/src/visitor.ts b/packages/plugins/typescript/operations/src/visitor.ts index f6121c0ce00..f7ca9946591 100644 --- a/packages/plugins/typescript/operations/src/visitor.ts +++ b/packages/plugins/typescript/operations/src/visitor.ts @@ -1,22 +1,51 @@ import { BaseDocumentsVisitor, + type ConvertSchemaEnumToDeclarationBlockString, + convertSchemaEnumToDeclarationBlockString, + DeclarationBlock, DeclarationKind, generateFragmentImportStatement, + generateImportStatement, getConfigValue, + indent, + isOneOfInputObjectType, + getEnumsImports, + isNativeNamedType, LoadedFragment, normalizeAvoidOptionals, NormalizedAvoidOptionalsConfig, ParsedDocumentsConfig, + type ParsedEnumValuesMap, + parseEnumValues, PreResolveTypesProcessor, SelectionSetProcessorConfig, SelectionSetToObject, + getNodeComment, wrapTypeWithModifiers, } from '@graphql-codegen/visitor-plugin-common'; import autoBind from 'auto-bind'; -import { GraphQLNamedType, GraphQLOutputType, GraphQLSchema, isEnumType, isNonNullType } from 'graphql'; +import { + type DocumentNode, + EnumTypeDefinitionNode, + type FragmentDefinitionNode, + getNamedType, + GraphQLEnumType, + GraphQLInputObjectType, + type GraphQLNamedInputType, + GraphQLScalarType, + type GraphQLSchema, + InputObjectTypeDefinitionNode, + InputValueDefinitionNode, + isEnumType, + Kind, + type TypeDefinitionNode, + TypeInfo, + type TypeNode, + visit, + visitWithTypeInfo, +} from 'graphql'; import { TypeScriptDocumentsPluginConfig } from './config.js'; -import { TypeScriptOperationVariablesToObject } from './ts-operation-variables-to-object.js'; -import { TypeScriptSelectionSetProcessor } from './ts-selection-set-processor.js'; +import { TypeScriptOperationVariablesToObject, SCALARS } from './ts-operation-variables-to-object.js'; export interface TypeScriptDocumentsParsedConfig extends ParsedDocumentsConfig { arrayInputCoercion: boolean; @@ -25,13 +54,31 @@ export interface TypeScriptDocumentsParsedConfig extends ParsedDocumentsConfig { noExport: boolean; maybeValue: string; allowUndefinedQueryVariables: boolean; + enumType: ConvertSchemaEnumToDeclarationBlockString['outputType']; + futureProofEnums: boolean; + enumValues: ParsedEnumValuesMap; } +type UsedNamedInputTypes = Record< + string, + | { type: 'GraphQLScalarType'; node: GraphQLScalarType; tsType: string } + | { type: 'GraphQLEnumType'; node: GraphQLEnumType; tsType: string } + | { type: 'GraphQLInputObjectType'; node: GraphQLInputObjectType; tsType: string } +>; + export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< TypeScriptDocumentsPluginConfig, TypeScriptDocumentsParsedConfig > { - constructor(schema: GraphQLSchema, config: TypeScriptDocumentsPluginConfig, allFragments: LoadedFragment[]) { + protected _usedNamedInputTypes: UsedNamedInputTypes = {}; + private _outputPath: string; + + constructor( + schema: GraphQLSchema, + config: TypeScriptDocumentsPluginConfig, + documentNode: DocumentNode, + outputPath: string + ) { super( config, { @@ -40,41 +87,38 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< avoidOptionals: normalizeAvoidOptionals(getConfigValue(config.avoidOptionals, false)), immutableTypes: getConfigValue(config.immutableTypes, false), nonOptionalTypename: getConfigValue(config.nonOptionalTypename, false), - preResolveTypes: getConfigValue(config.preResolveTypes, true), mergeFragmentTypes: getConfigValue(config.mergeFragmentTypes, false), allowUndefinedQueryVariables: getConfigValue(config.allowUndefinedQueryVariables, false), + enumType: getConfigValue(config.enumType, 'string-literal'), + enumValues: parseEnumValues({ + schema, + mapOrStr: config.enumValues, + ignoreEnumValuesFromSchema: config.ignoreEnumValuesFromSchema, + }), + futureProofEnums: getConfigValue(config.futureProofEnums, false), } as TypeScriptDocumentsParsedConfig, schema ); + this._outputPath = outputPath; autoBind(this); - const preResolveTypes = getConfigValue(config.preResolveTypes, true); const defaultMaybeValue = 'T | null'; const maybeValue = getConfigValue(config.maybeValue, defaultMaybeValue); - const wrapOptional = (type: string) => { - if (preResolveTypes === true) { - return maybeValue.replace('T', type); - } - const prefix = this.config.namespacedImportName ? `${this.config.namespacedImportName}.` : ''; - return `${prefix}Maybe<${type}>`; - }; - const wrapArray = (type: string) => { - const listModifier = this.config.immutableTypes ? 'ReadonlyArray' : 'Array'; - return `${listModifier}<${type}>`; - }; + const allFragments: LoadedFragment[] = [ + ...(documentNode.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION) as FragmentDefinitionNode[]).map( + fragmentDef => ({ + node: fragmentDef, + name: fragmentDef.name.value, + onType: fragmentDef.typeCondition.name.value, + isExternal: false, + }) + ), + ...(config.externalFragments || []), + ]; - 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 ? '?' : ''); - }; + this._usedNamedInputTypes = this.collectUsedInputTypes({ schema, documentNode }); const processorConfig: SelectionSetProcessorConfig = { namespacedImportName: this.config.namespacedImportName, @@ -82,16 +126,21 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< enumPrefix: this.config.enumPrefix, enumSuffix: this.config.enumSuffix, scalars: this.scalars, - formatNamedField, - wrapTypeWithModifiers(baseType, type) { - return wrapTypeWithModifiers(baseType, type, { wrapOptional, wrapArray }); + formatNamedField: ({ name, isOptional }) => { + return (this.config.immutableTypes ? `readonly ${name}` : name) + (isOptional ? '?' : ''); + }, + wrapTypeWithModifiers: (baseType, type) => { + return wrapTypeWithModifiers(baseType, type, { + wrapOptional: type => maybeValue.replace('T', type), + wrapArray: type => { + const listModifier = this.config.immutableTypes ? 'ReadonlyArray' : 'Array'; + return `${listModifier}<${type}>`; + }, + }); }, - avoidOptionals: this.config.avoidOptionals, printFieldsOnNewLines: this.config.printFieldsOnNewLines, }; - const processor = new (preResolveTypes ? PreResolveTypesProcessor : TypeScriptSelectionSetProcessor)( - processorConfig - ); + const processor = new PreResolveTypesProcessor(processorConfig); this.setSelectionSetHandler( new SelectionSetToObject( processor, @@ -108,6 +157,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, @@ -117,14 +169,176 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< this.config.enumValues, this.config.arrayInputCoercion, undefined, - 'InputMaybe' + undefined ) ); this._declarationBlockConfig = { ignoreExport: this.config.noExport, + enumNameValueSeparator: ' =', }; } + EnumTypeDefinition(node: EnumTypeDefinitionNode): string | null { + const enumName = node.name.value; + if (!this._usedNamedInputTypes[enumName] || this.config.importSchemaTypesFrom) { + return null; + } + + return convertSchemaEnumToDeclarationBlockString({ + schema: this._schema, + node, + declarationBlockConfig: this._declarationBlockConfig, + enumName, + enumValues: this.config.enumValues, + futureProofEnums: this.config.futureProofEnums, + ignoreEnumValuesFromSchema: this.config.ignoreEnumValuesFromSchema, + outputType: this.config.enumType, + naming: { + convert: this.config.convert, + typesPrefix: this.config.typesPrefix, + typesSuffix: this.config.typesSuffix, + useTypesPrefix: this.config.enumPrefix, + useTypesSuffix: this.config.enumSuffix, + }, + }); + } + + InputObjectTypeDefinition(node: InputObjectTypeDefinitionNode): string | null { + const inputTypeName = node.name.value; + if (!this._usedNamedInputTypes[inputTypeName]) { + return null; + } + + if (isOneOfInputObjectType(this._schema.getType(inputTypeName))) { + return new DeclarationBlock(this._declarationBlockConfig) + .asKind('type') + .withName(this.convertName(node)) + .withComment(node.description?.value) + .withContent(`\n` + (node.fields || []).join('\n |')).string; + } + + return new DeclarationBlock(this._declarationBlockConfig) + .asKind('type') + .withName(this.convertName(node)) + .withComment(node.description?.value) + .withBlock((node.fields || []).join('\n')).string; + } + + InputValueDefinition( + node: InputValueDefinitionNode, + _key?: number | string, + _parent?: any, + _path?: Array, + ancestors?: Array + ): string { + const oneOfDetails = parseOneOfInputValue({ + node, + schema: this._schema, + ancestors, + }); + + // 1. Flatten GraphQL type nodes to make it easier to turn into string + // GraphQL type nodes may have `NonNullType` type before each `ListType` or `NamedType` + // This make it a bit harder to know whether a `ListType` or `Namedtype` is nullable without looking at the node before it. + // Flattening it into an array where the nullability is in `ListType` and `NamedType` makes it easier to code, + // + // So, we recursively call `collectAndFlattenTypeNodes` to handle the following scenarios: + // - [Thing] + // - [Thing!] + // - [Thing]! + // - [Thing!]! + const typeNodes: Parameters[0]['typeNodes'] = []; + collectAndFlattenTypeNodes({ + currentTypeNode: node.type, + isPreviousNodeNonNullable: oneOfDetails.isOneOfInputValue, // If the InputValue is part of @oneOf input, we treat it as non-null (even if it must be null in the schema) + typeNodes, + }); + + // 2. Generate the type of a TypeScript field declaration + // e.g. `field?: string`, then the `string` is the `typePart` + let typePart: string = ''; + // We call `.reverse()` here to get the base type node first + for (const typeNode of typeNodes.reverse()) { + if (typeNode.type === 'NamedType') { + const usedInputType = this._usedNamedInputTypes[typeNode.name]; + if (!usedInputType) { + continue; + } + + typePart = usedInputType.tsType; // If the schema is correct, when reversing typeNodes, the first node would be `NamedType`, which means we can safely set it as the base for typePart + if (usedInputType.tsType !== 'any' && !typeNode.isNonNullable) { + typePart += ' | null | undefined'; + } + continue; + } + + if (typeNode.type === 'ListType') { + typePart = `Array<${typePart}>`; + if (!typeNode.isNonNullable) { + typePart += ' | null | undefined'; + } + } + } + + // TODO: eddeee888 check if we want to support `directiveArgumentAndInputFieldMappings` for operations + // if (node.directives && this.config.directiveArgumentAndInputFieldMappings) { + // typePart = + // getDirectiveOverrideType({ + // directives: node.directives, + // directiveArgumentAndInputFieldMappings: this.config.directiveArgumentAndInputFieldMappings, + // }) || typePart; + // } + + const addOptionalSign = + !oneOfDetails.isOneOfInputValue && + !this.config.avoidOptionals.inputValue && + (node.type.kind !== Kind.NON_NULL_TYPE || + (!this.config.avoidOptionals.defaultValue && node.defaultValue !== undefined)); + + // 3. Generate the keyPart of the TypeScript field declaration + // e.g. `field?: string`, then the `field?` is the `keyPart` + const keyPart = `${node.name.value}${addOptionalSign ? '?' : ''}`; + + // 4. other parts of TypeScript field declaration + const commentPart = getNodeComment(node); + const readonlyPart = this.config.immutableTypes ? 'readonly ' : ''; + + const currentInputValue = commentPart + indent(`${readonlyPart}${keyPart}: ${typePart};`); + + // 5. Check if field is part of `@oneOf` input type + // If yes, we must generate a union member where the current inputValue must be provieded, and the others are not + // e.g. + // ```graphql + // input UserInput { + // byId: ID + // byEmail: String + // byLegacyId: ID + // } + // ``` + // + // Then, the generated type is: + // ```ts + // type UserInput = + // | { byId: string | number; byEmail?: never; byLegacyId?: never } + // | { byId?: never; byEmail: string; byLegacyId?: never } + // | { byId?: never; byEmail?: never; byLegacyId: string | number } + // ``` + if (oneOfDetails.isOneOfInputValue) { + const fieldParts: Array = []; + for (const fieldName of Object.keys(oneOfDetails.parentType.getFields())) { + if (fieldName === node.name.value) { + fieldParts.push(currentInputValue); + continue; + } + fieldParts.push(`${readonlyPart}${fieldName}?: never;`); + } + return indent(`{ ${fieldParts.join(' ')} }`); + } + + // If field is not part of @oneOf input type, then it's a input value, just return as-is + return currentInputValue; + } + public getImports(): Array { return !this.config.globalNamespace && (this.config.inlineFragmentTypes === 'combine' || this.config.inlineFragmentTypes === 'mask') @@ -132,14 +346,224 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< : []; } + public getExternalSchemaTypeImports(): Array { + if (!this.config.importSchemaTypesFrom) { + return []; + } + + const hasTypesToImport = Object.keys(this._usedNamedInputTypes).length > 0; + + if (!hasTypesToImport) { + return []; + } + + return [ + generateImportStatement({ + baseDir: process.cwd(), + baseOutputDir: '', + outputPath: this._outputPath, + importSource: { + path: this.config.importSchemaTypesFrom, + namespace: this.config.namespacedImportName, + identifiers: [], + }, + typesImport: true, + // FIXME: rebase with master for the new extension + emitLegacyCommonJSImports: true, + }), + ]; + } + protected getPunctuation(_declarationKind: DeclarationKind): string { return ';'; } protected applyVariablesWrapper(variablesBlock: string, operationType: string): string { - const prefix = this.config.namespacedImportName ? `${this.config.namespacedImportName}.` : ''; const extraType = this.config.allowUndefinedQueryVariables && operationType === 'Query' ? ' | undefined' : ''; - return `${prefix}Exact<${variablesBlock === '{}' ? `{ [key: string]: never; }` : variablesBlock}>${extraType}`; + return `Exact<${variablesBlock === '{}' ? `{ [key: string]: never; }` : variablesBlock}>${extraType}`; + } + + private collectInnerTypesRecursively(node: GraphQLNamedInputType, usedInputTypes: UsedNamedInputTypes): void { + if (usedInputTypes[node.name]) { + return; + } + + if (node instanceof GraphQLEnumType) { + usedInputTypes[node.name] = { + type: 'GraphQLEnumType', + node, + tsType: this.convertName(node.name), + }; + return; + } + + if (node instanceof GraphQLScalarType) { + usedInputTypes[node.name] = { + type: 'GraphQLScalarType', + node, + tsType: (SCALARS[node.name] || this.config.scalars?.[node.name]?.input.type) ?? 'any', + }; + return; + } + + // GraphQLInputObjectType + usedInputTypes[node.name] = { + type: 'GraphQLInputObjectType', + node, + tsType: this.convertName(node.name), + }; + + const fields = node.getFields(); + for (const field of Object.values(fields)) { + const fieldType = getNamedType(field.type); + this.collectInnerTypesRecursively(fieldType, usedInputTypes); + } + } + + private collectUsedInputTypes({ + schema, + documentNode, + }: { + schema: GraphQLSchema; + documentNode: DocumentNode; + }): UsedNamedInputTypes { + const schemaTypes = schema.getTypeMap(); + + const usedInputTypes: UsedNamedInputTypes = {}; + + // Collect input enums and input types + visit(documentNode, { + VariableDefinition: variableDefinitionNode => { + visit(variableDefinitionNode, { + NamedType: namedTypeNode => { + const foundInputType = schemaTypes[namedTypeNode.name.value]; + if ( + foundInputType && + (foundInputType instanceof GraphQLInputObjectType || + foundInputType instanceof GraphQLScalarType || + foundInputType instanceof GraphQLEnumType) && + !isNativeNamedType(foundInputType) + ) { + this.collectInnerTypesRecursively(foundInputType, usedInputTypes); + } + }, + }); + }, + }); + + // Collect output enums + const typeInfo = new TypeInfo(schema); + visit( + documentNode, + // AST doesn’t include field types (they are defined in schema) - only names. + // TypeInfo is a stateful helper that tracks typing context while walking the AST + // visitWithTypeInfo wires that context into a visitor. + visitWithTypeInfo(typeInfo, { + Field: () => { + const fieldType = typeInfo.getType(); + if (fieldType) { + const namedType = getNamedType(fieldType); + + if (namedType instanceof GraphQLEnumType) { + usedInputTypes[namedType.name] = { + type: 'GraphQLEnumType', + node: namedType, + tsType: this.convertName(namedType.name), + }; + } + } + }, + }) + ); + + return usedInputTypes; + } + + public getEnumsImports(): string[] { + const usedEnumMap: ParsedEnumValuesMap = {}; + for (const [enumName, enumDetails] of Object.entries(this.config.enumValues)) { + if (this._usedNamedInputTypes[enumName]) { + usedEnumMap[enumName] = enumDetails; + } + } + + return getEnumsImports({ + enumValues: usedEnumMap, + useTypeImports: this.config.useTypeImports, + }); + } + + getExactUtilityType(): string | null { + if (!this.config.generatesOperationTypes) { + return null; + } + + return 'type Exact = { [K in keyof T]: T[K] };'; + } + + getIncrementalUtilityType(): string | null { + if (!this.config.generatesOperationTypes) { + return null; + } + + // 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 };"; + } +} + +function parseOneOfInputValue({ + node, + schema, + ancestors, +}: { + node: InputValueDefinitionNode; + schema: GraphQLSchema; + ancestors?: Array; +}): + | { isOneOfInputValue: true; realParentDef: TypeDefinitionNode; parentType: GraphQLInputObjectType } + | { isOneOfInputValue: false } { + const realParentDef = ancestors?.[ancestors.length - 1]; + if (realParentDef) { + const parentType = schema.getType(realParentDef.name.value); + if (isOneOfInputObjectType(parentType)) { + if (node.type.kind === Kind.NON_NULL_TYPE) { + throw new Error( + 'Fields on an input object type can not be non-nullable. It seems like the schema was not validated.' + ); + } + return { isOneOfInputValue: true, realParentDef, parentType }; + } + } + return { isOneOfInputValue: false }; +} + +function collectAndFlattenTypeNodes({ + currentTypeNode, + isPreviousNodeNonNullable, + typeNodes, +}: { + currentTypeNode: TypeNode; + isPreviousNodeNonNullable: boolean; + typeNodes: Array< + { type: 'ListType'; isNonNullable: boolean } | { type: 'NamedType'; isNonNullable: boolean; name: string } + >; +}): void { + if (currentTypeNode.kind === Kind.NON_NULL_TYPE) { + const nextTypeNode = currentTypeNode.type; + collectAndFlattenTypeNodes({ currentTypeNode: nextTypeNode, isPreviousNodeNonNullable: true, typeNodes }); + } else if (currentTypeNode.kind === Kind.LIST_TYPE) { + typeNodes.push({ type: 'ListType', isNonNullable: isPreviousNodeNonNullable }); + + const nextTypeNode = currentTypeNode.type; + collectAndFlattenTypeNodes({ currentTypeNode: nextTypeNode, isPreviousNodeNonNullable: false, typeNodes }); + } else if (currentTypeNode.kind === Kind.NAMED_TYPE) { + typeNodes.push({ + type: 'NamedType', + isNonNullable: isPreviousNodeNonNullable, + name: currentTypeNode.name.value, + }); } } 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 3bdd6ab1a15..760b49909be 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 @@ -1,36 +1,36 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`TypeScript Operations Plugin > Config > should include fragment variable definitions when experimentalFragmentVariables is set 1`] = ` -"export type TextNotificationFragmentFragment = { __typename?: 'TextNotification', text?: string }; +"export type TextNotificationFragmentFragment = { text?: string }; export type TextNotificationFragmentFragmentVariables = Exact<{ - skip: Scalars['Boolean']['input']; + skip: boolean; }>; " `; exports[`TypeScript Operations Plugin > Issues > #2699 - Issues with multiple interfaces and unions 1`] = ` "export type GetEntityBrandDataQueryVariables = Exact<{ - gid: Scalars['ID']['input']; - brand: Scalars['ID']['input']; + gid: string; + brand: string; }>; -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 } +export type GetEntityBrandDataQuery = { node: + | { __typename: 'Company', active: boolean, id: string, createdAt: any, updatedAt: any, brandData: { active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null, createdBy: { id: string, name: string } | null, updatedBy: { id: string, name: string } | null } + | { __typename: 'Theater', active: boolean, id: string, createdAt: any, updatedAt: any, brandData: { active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null, createdBy: { id: string, name: string } | null, updatedBy: { id: string, name: string } | null } + | { __typename: 'Movie', id: string, createdAt: any, updatedAt: any, brandData: { active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null, createdBy: { id: string, name: string } | null, updatedBy: { id: string, name: string } | null } + | { __typename: 'User', id: string, createdAt: any, updatedAt: any, brandData: { active: boolean, browsable: boolean, title: string, alternateTitle: string | null, description: string } | null, createdBy: { id: string, name: string } | null, updatedBy: { 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 = { brandData: { 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 = { brandData: { 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 = { brandData: { 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 = { brandData: { 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 = { createdAt: any, updatedAt: any, createdBy: { id: string, name: string } | null, updatedBy: { 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 = { createdAt: any, updatedAt: any, createdBy: { id: string, name: string } | null, updatedBy: { 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 = { createdAt: any, updatedAt: any, createdBy: { id: string, name: string } | null, updatedBy: { 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 = { createdAt: any, updatedAt: any, createdBy: { id: string, name: string } | null, updatedBy: { id: string, name: string } | null }; export type ElementMetadataFragment = | ElementMetadata_Company_Fragment @@ -56,8 +56,12 @@ export type ElementMetadataFragment = " `; -exports[`TypeScript Operations Plugin > Issues > #2916 - Missing import prefix with preResolveTypes: true and near-operation-file preset 1`] = ` -"export type UserQueryVariables = Types.Exact<{ [key: string]: never; }>; +exports[`TypeScript Operations Plugin > Issues > #2916 - Missing import prefix with near-operation-file preset 1`] = ` +"export type Department = + | 'Direction' + | 'Development'; + +export type UserQueryVariables = Exact<{ [key: string]: never; }>; export type UserQuery = { user: { id: string, username: string, email: string, dep: Types.Department } }; @@ -65,76 +69,9 @@ export type UserQuery = { user: { id: string, username: string, email: string, d `; exports[`TypeScript Operations Plugin > Issues > #3064 - fragments over interfaces causes issues with fields 1`] = ` -"type Venue_Hotel_Fragment = { __typename?: 'Hotel', id: string, gpsPosition: { __typename?: 'GPSPosition', lat: number, lng: number } }; - -type Venue_Transport_Fragment = { __typename?: 'Transport', id: string }; - -export type VenueFragment = - | Venue_Hotel_Fragment - | Venue_Transport_Fragment -; - -export type QQueryVariables = Exact<{ [key: string]: never; }>; +"type Venue_Hotel_Fragment = { id: string, gpsPosition: { lat: number, lng: number } }; - -export type QQuery = { __typename?: 'Query', hotel: { __typename?: 'Hotel', id: string, gpsPosition: { __typename?: 'GPSPosition', lat: number, lng: number } }, transport: { __typename?: 'Transport', id: string } }; -" -`; - -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 Exact = { [K in keyof T]: T[K] }; -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_Transport_Fragment = { __typename?: 'Transport', id: string }; +type Venue_Transport_Fragment = { id: string }; export type VenueFragment = | Venue_Hotel_Fragment @@ -144,7 +81,7 @@ export type VenueFragment = export type QQueryVariables = Exact<{ [key: string]: never; }>; -export type QQuery = { __typename?: 'Query', hotel: { __typename?: 'Hotel', id: string, gpsPosition: { __typename?: 'GPSPosition', lat: number, lng: number } }, transport: { __typename?: 'Transport', id: string } }; +export type QQuery = { hotel: { id: string, gpsPosition: { lat: number, lng: number } }, transport: { id: string } }; function test(q: QQuery) { if (q.hotel) { const t1 = q.hotel.gpsPosition.lat @@ -156,18 +93,18 @@ function test(q: QQuery) { }" `; -exports[`TypeScript Operations Plugin > Issues > #6874 - generates types when parent type differs from spread fragment member types and preResolveTypes=true 1`] = ` +exports[`TypeScript Operations Plugin > Issues > #6874 - generates types when parent type differs from spread fragment member types 1`] = ` "export type SnakeQueryQueryVariables = Exact<{ [key: string]: never; }>; -export type SnakeQueryQuery = { __typename?: 'Query', snake: - | { __typename?: 'Snake', name: string, features: { __typename?: 'SnakeFeatures', color: string, length: number } } - | { __typename?: 'Error' } +export type SnakeQueryQuery = { snake: + | { name: string, features: { color: string, length: number } } + | Record }; -type AnimalFragment_Bat_Fragment = { __typename?: 'Bat', features: { __typename?: 'BatFeatures', color: string, wingspan: number } }; +type AnimalFragment_Bat_Fragment = { features: { color: string, wingspan: number } }; -type AnimalFragment_Snake_Fragment = { __typename?: 'Snake', features: { __typename?: 'SnakeFeatures', color: string, length: number } }; +type AnimalFragment_Snake_Fragment = { features: { color: string, length: number } }; export type AnimalFragmentFragment = | AnimalFragment_Bat_Fragment @@ -176,33 +113,13 @@ export type AnimalFragmentFragment = " `; -exports[`TypeScript Operations Plugin > Issues > #8793 selecting __typename should not be optional 1`] = ` -"export type SnakeQueryQueryVariables = Exact<{ [key: string]: never; }>; - - -export type SnakeQueryQuery = { __typename: 'Query', snake: - | { __typename: 'Snake' } - | { __typename: 'Error' } - }; -" -`; - exports[`TypeScript Operations Plugin > Selection Set > Should generate the correct __typename when using both inline fragment and spread over type 1`] = ` "export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; -export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user?: Maybe<( - { __typename?: 'User' } - & Pick - )> } -); +export type UserQueryQuery = { user: { id: string, name: string | null } | null }; -export type UserFragment = ( - { __typename?: 'User' } - & Pick -); +export type UserFragment = { id: string, name: string | null }; " `; @@ -210,13 +127,7 @@ exports[`TypeScript Operations Plugin > Selection Set > Should generate the corr "export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; -export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user?: Maybe<( - { __typename?: 'User' } - & Pick - )> } -); +export type UserQueryQuery = { user: { id: string, name: string | null } | null }; " `; @@ -224,86 +135,29 @@ exports[`TypeScript Operations Plugin > Selection Set > Should generate the corr "export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; -export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user?: Maybe<( - { __typename?: 'User' } - & Pick - )> } -); +export type UserQueryQuery = { user: { id: string, name: string | null } | null }; -export type UserFragment = ( - { __typename?: 'User' } - & Pick -); +export type UserFragment = { id: string, name: string | null }; " `; exports[`TypeScript Operations Plugin > Selection Set > Should generate the correct __typename when using fragment spread over union 1`] = ` -"export type UserFragmentFragment = ( - { __typename?: 'User' } - & Pick -); +"export type UserFragmentFragment = { id: string }; export type AaaQueryVariables = Exact<{ [key: string]: never; }>; -export type AaaQuery = ( - { __typename?: 'Query' } - & { user: - | ( - { __typename?: 'User' } - & Pick - ) - | { __typename?: 'Error' } - } -); -" -`; - -exports[`TypeScript Operations Plugin > Selection Set > Should generate the correct intersection for fragments when using with interfaces with same type 1`] = ` -"export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - - -export type Unnamed_1_Query = ( - { __typename?: 'Query' } - & { b?: Maybe< - | ( - { __typename?: 'A' } - & Pick - ) - | { __typename?: 'B' } - > } -); - -export type AFragment = ( - { __typename?: 'A' } - & Pick -); - -export type BFragment = ( - { __typename?: 'A' } - & Pick -); +export type AaaQuery = { user: + | { id: string } + | Record + }; " `; exports[`TypeScript Operations Plugin > Selection Set > Should have valid __typename usage and split types according to that (with usage) 1`] = ` -"type NetRoute_Ipv4Route_Fragment = ( - { __typename: 'IPV4Route' } - & { - ipv4Address: Ipv4Route['address'], - ipv4Gateway: Ipv4Route['gateway'], - } -); - -type NetRoute_Ipv6Route_Fragment = ( - { __typename: 'IPV6Route' } - & { - ipv6Address: Ipv6Route['address'], - ipv6Gateway: Ipv6Route['gateway'], - } -); +"type NetRoute_Ipv4Route_Fragment = { __typename: 'IPV4Route', ipv4Address: any | null, ipv4Gateway: any | null }; + +type NetRoute_Ipv6Route_Fragment = { __typename: 'IPV6Route', ipv6Address: any | null, ipv6Gateway: any | null }; export type NetRouteFragment = | NetRoute_Ipv4Route_Fragment @@ -313,103 +167,43 @@ export type NetRouteFragment = export type QqQueryVariables = Exact<{ [key: string]: never; }>; -export type QqQuery = ( - { __typename?: 'Query' } - & { routes: Array< - | ( - { __typename: 'IPV4Route' } - & { - ipv4Address: Ipv4Route['address'], - ipv4Gateway: Ipv4Route['gateway'], - } - ) - | ( - { __typename: 'IPV6Route' } - & { - ipv6Address: Ipv6Route['address'], - ipv6Gateway: Ipv6Route['gateway'], - } - ) - > } -); +export type QqQuery = { routes: Array< + | { __typename: 'IPV4Route', ipv4Address: any | null, ipv4Gateway: any | null } + | { __typename: 'IPV6Route', ipv6Address: any | null, ipv6Gateway: any | null } + > }; " `; exports[`TypeScript Operations Plugin > Selection Set > Should have valid __typename usage and split types according to that (with usage) 2`] = ` -"type NetRoute_Ipv4Route_Fragment = ( - { __typename: 'IPV4Route' } - & { - ipv4Address: Ipv4Route['address'], - ipv4Gateway: Ipv4Route['gateway'], - } -); - -type NetRoute_Ipv6Route_Fragment = ( - { __typename: 'IPV6Route' } - & { - ipv6Address: Ipv6Route['address'], - ipv6Gateway: Ipv6Route['gateway'], - } -); +"type NetRoute_Ipv4Route_Fragment = { __typename: 'IPV4Route', ipv4Address: any | null, ipv4Gateway: any | null }; + +type NetRoute_Ipv6Route_Fragment = { __typename: 'IPV6Route', ipv6Address: any | null, ipv6Gateway: any | null }; export type NetRouteFragment = | NetRoute_Ipv4Route_Fragment | NetRoute_Ipv6Route_Fragment ; -export type TestFragment = ( - { __typename?: 'IPV6Route' } - & { - ipv6Address: Ipv6Route['address'], - ipv6Gateway: Ipv6Route['gateway'], - } -); +export type TestFragment = { ipv6Address: any | null, ipv6Gateway: any | null }; export type QqQueryVariables = Exact<{ [key: string]: never; }>; -export type QqQuery = ( - { __typename?: 'Query' } - & { routes: Array< - | ( - { __typename: 'IPV4Route' } - & { - ipv4Address: Ipv4Route['address'], - ipv4Gateway: Ipv4Route['gateway'], - } - ) - | ( - { __typename: 'IPV6Route' } - & { - ipv6Address: Ipv6Route['address'], - ipv6Gateway: Ipv6Route['gateway'], - } - ) - > } -); +export type QqQuery = { routes: Array< + | { __typename: 'IPV4Route', ipv4Address: any | null, ipv4Gateway: any | null } + | { __typename: 'IPV6Route', ipv6Address: any | null, ipv6Gateway: any | null } + > }; " `; exports[`TypeScript Operations Plugin > Selection Set > Should have valid fragments intersection on different types (with usage) #2498 1`] = ` -"export type TomFragment = ( - { __typename?: 'Tom' } - & Pick -); - -export type JerryFragment = ( - { __typename?: 'Jerry' } - & Pick -); - -type User_Tom_Fragment = ( - { __typename?: 'Tom' } - & Pick -); - -type User_Jerry_Fragment = ( - { __typename?: 'Jerry' } - & Pick -); +"export type TomFragment = { id: string, foo: string }; + +export type JerryFragment = { id: string, bar: string }; + +type User_Tom_Fragment = { id: string, foo: string }; + +type User_Jerry_Fragment = { id: string, bar: string }; export type UserFragment = | User_Tom_Fragment @@ -419,357 +213,9 @@ export type UserFragment = export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; -export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user?: Maybe< - | ( - { __typename?: 'Tom' } - & Pick - ) - | ( - { __typename?: 'Jerry' } - & Pick - ) - > } -); +export type UserQueryQuery = { user: + | { id: string, foo: string } + | { id: string, bar: string } + | null }; " `; - -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 Exact = { [K in keyof T]: T[K] }; -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<( - { __typename?: 'Dimension' } - & Pick - )> } - ) - >> } -); -" -`; - -exports[`TypeScript Operations Plugin > Union & Interfaces > Should handle union selection sets with both FragmentSpreads and InlineFragments 1`] = ` -"export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; - - -export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user: - | ( - { __typename?: 'User' } - & Pick - ) - | ( - { __typename?: 'Error2' } - & Pick - ) - | ( - { __typename?: 'Error3' } - & Pick - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } - ) - } -); - -export type AdditionalInfoFragment = ( - { __typename?: 'AdditionalInfo' } - & Pick -); - -type UserResult1_User_Fragment = ( - { __typename?: 'User' } - & Pick -); - -type UserResult1_Error2_Fragment = { __typename?: 'Error2' }; - -type UserResult1_Error3_Fragment = ( - { __typename?: 'Error3' } - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } -); - -export type UserResult1Fragment = - | UserResult1_User_Fragment - | UserResult1_Error2_Fragment - | UserResult1_Error3_Fragment -; - -type UserResult_User_Fragment = ( - { __typename?: 'User' } - & Pick -); - -type UserResult_Error2_Fragment = ( - { __typename?: 'Error2' } - & Pick -); - -type UserResult_Error3_Fragment = { __typename?: 'Error3' }; - -export type UserResultFragment = - | UserResult_User_Fragment - | UserResult_Error2_Fragment - | UserResult_Error3_Fragment -; -" -`; - -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 Exact = { [K in keyof T]: T[K] }; -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 UserQueryQuery = ( - { __typename?: 'Query' } - & { user: - | ( - { __typename?: 'User' } - & Pick - ) - | ( - { __typename?: 'Error2' } - & Pick - ) - | ( - { __typename?: 'Error3' } - & Pick - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } - ) - } -); - - function t(q: UserQueryQuery) { - if (q.user) { - if (q.user.__typename === 'User') { - if (q.user.id) { - const u = q.user.login; - } - } - if (q.user.__typename === 'Error2') { - console.log(q.user.message); - } - if (q.user.__typename === 'Error3') { - if (q.user.info) { - console.log(q.user.info.__typename) - } - } - } - }" -`; - -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 Exact = { [K in keyof T]: T[K] }; -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 UserQueryQuery = ( - { __typename?: 'Query' } - & { user: - | ( - { __typename?: 'User' } - & Pick< - User, - | 'id' - | 'test2' - | 'login' - | 'test' - > - ) - | ( - { __typename?: 'Error2' } - & Pick - ) - | ( - { __typename?: 'Error3' } - & Pick - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } - ) - } -); - - function t(q: UserQueryQuery) { - if (q.user) { - if (q.user.__typename === 'User') { - if (q.user.id) { - const u = q.user.login; - } - } - if (q.user.__typename === 'Error2') { - console.log(q.user.message); - } - if (q.user.__typename === 'Error3') { - if (q.user.info) { - console.log(q.user.info.__typename) - } - } - } - }" -`; diff --git a/packages/plugins/typescript/operations/tests/extract-all-types-field-names-only.spec.ts b/packages/plugins/typescript/operations/tests/extract-all-types-field-names-only.spec.ts new file mode 100644 index 00000000000..a4c8da8b5c1 --- /dev/null +++ b/packages/plugins/typescript/operations/tests/extract-all-types-field-names-only.spec.ts @@ -0,0 +1,278 @@ +import { mergeOutputs, Types } from '@graphql-codegen/plugin-helpers'; +import { validateTs } from '@graphql-codegen/testing'; +import { buildSchema, parse } from 'graphql'; +import { plugin as tsPlugin } from '../../typescript/src/index.js'; +import { plugin, TypeScriptDocumentsPluginConfig } from '../src/index.js'; + +describe('extractAllFieldsToTypesFieldNamesOnly: true', () => { + const validate = async (content: Types.PluginOutput, config: any = {}, pluginSchema: any) => { + const m = mergeOutputs([await tsPlugin(pluginSchema, [], config, { outputFile: '' }), content]); + validateTs(m, undefined, undefined, undefined, []); + + return m; + }; + + // Test schema similar to the example in prompt.md + const fooSchema = buildSchema(/* GraphQL */ ` + type Query { + foo(id: ID!): Foo + } + + type Foo { + id: ID! + name: String! + rating: Float + numCount: Int + location: FooLocation + } + + type FooLocation { + id: ID + address: FooAddress + } + + type FooAddress { + formatted: String + } + `); + + const fooDoc = parse(/* GraphQL */ ` + query FooDemoGetBarInfo($id: ID!) { + foo(id: $id) { + id + name + rating + numCount + location { + id + address { + formatted + } + } + } + } + `); + + it('should generate Apollo Tooling-compatible type names (field names only, without GraphQL type names)', async () => { + const config: TypeScriptDocumentsPluginConfig = { + extractAllFieldsToTypes: true, + extractAllFieldsToTypesFieldNamesOnly: true, + printFieldsOnNewLines: true, + omitOperationSuffix: true, + }; + const { content } = await plugin(fooSchema, [{ location: 'test-file.ts', document: fooDoc }], config, { + outputFile: '', + }); + + await validate(content, config, fooSchema); + + // Check that type names follow Apollo Tooling pattern: QueryName_fieldName_nestedField + // NOT the default pattern: QueryName_fieldName_TypeName_nestedField_FieldTypeName + expect(content).toContain('FooDemoGetBarInfo_foo_location_address'); + expect(content).toContain('FooDemoGetBarInfo_foo_location'); + expect(content).toContain('FooDemoGetBarInfo_foo'); + + // Make sure it does NOT contain the GraphQL type names in the field type names + expect(content).not.toContain('FooDemoGetBarInfo_foo_Foo_location'); + expect(content).not.toContain('FooLocation_address_FooAddress'); + + // Make sure it does NOT contain the Query suffix in extracted field types + expect(content).not.toContain('FooDemoGetBarInfoQuery_foo_location'); + + expect(content).toMatchInlineSnapshot(` + "export type FooDemoGetBarInfo_foo_location_address = { + formatted: string | null + }; + + export type FooDemoGetBarInfo_foo_location = { + id: string | null, + address: FooDemoGetBarInfo_foo_location_address | null + }; + + export type FooDemoGetBarInfo_foo = { + id: string, + name: string, + rating: number | null, + numCount: number | null, + location: FooDemoGetBarInfo_foo_location | null + }; + + export type FooDemoGetBarInfo = { + foo: FooDemoGetBarInfo_foo | null + }; + + + export type FooDemoGetBarInfoVariables = Exact<{ + id: string; + }>; + + + export type FooDemoGetBarInfo = FooDemoGetBarInfo; + " + `); + }); + + it('should work with fragments and field names only mode', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user: User + } + + interface User { + id: ID! + } + + type AdminUser implements User { + id: ID! + profile: UserProfile + } + + type RegularUser implements User { + id: ID! + profile: UserProfile + } + + type UserProfile { + bio: String + avatar: Avatar + } + + type Avatar { + url: String! + } + `); + + const doc = parse(/* GraphQL */ ` + fragment UserProfileFragment on UserProfile { + bio + avatar { + url + } + } + + query GetUser { + user { + id + ... on AdminUser { + profile { + ...UserProfileFragment + } + } + } + } + `); + + const config: TypeScriptDocumentsPluginConfig = { + extractAllFieldsToTypes: true, + extractAllFieldsToTypesFieldNamesOnly: true, + printFieldsOnNewLines: true, + omitOperationSuffix: true, + }; + + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: doc }], config, { + outputFile: '', + }); + + await validate(content, config, schema); + + // Verify field names only pattern + expect(content).toContain('UserProfileFragment_avatar'); + expect(content).toContain('GetUser_user_profile'); + + // Verify type names are NOT included + expect(content).not.toContain('UserProfileFragment_avatar_Avatar'); + expect(content).not.toContain('UserProfile_avatar_Avatar'); + expect(content).not.toContain('GetUser_user_AdminUser_profile'); + + // Make sure operation suffix is omitted + expect(content).not.toContain('GetUserQuery_user_profile'); + expect(content).not.toContain('UserProfileFragmentFragment_avatar'); + }); + + it('should not affect type names when extractAllFieldsToTypes is false', async () => { + const config: TypeScriptDocumentsPluginConfig = { + extractAllFieldsToTypes: false, + extractAllFieldsToTypesFieldNamesOnly: true, // This should have no effect on extraction, but still affects operation suffix + printFieldsOnNewLines: true, + omitOperationSuffix: true, + }; + + const { content } = await plugin(fooSchema, [{ location: 'test-file.ts', document: fooDoc }], config, { + outputFile: '', + }); + + await validate(content, config, fooSchema); + + // When extractAllFieldsToTypes is false, types should be inlined + // Field types are not extracted + expect(content).not.toContain('FooDemoGetBarInfo_foo_location_address'); + + // But the operation suffix should still be omitted since extractAllFieldsToTypesFieldNamesOnly affects getOperationSuffix + expect(content).toContain('FooDemoGetBarInfo'); + expect(content).not.toContain('FooDemoGetBarInfoQuery {'); + }); + + it('should handle deeply nested fields with field names only', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + root: Level1 + } + + type Level1 { + field1: Level2 + } + + type Level2 { + field2: Level3 + } + + type Level3 { + field3: Level4 + } + + type Level4 { + value: String! + } + `); + + const doc = parse(/* GraphQL */ ` + query DeeplyNested { + root { + field1 { + field2 { + field3 { + value + } + } + } + } + } + `); + + const config: TypeScriptDocumentsPluginConfig = { + extractAllFieldsToTypes: true, + extractAllFieldsToTypesFieldNamesOnly: true, + printFieldsOnNewLines: true, + omitOperationSuffix: true, + }; + + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: doc }], config, { + outputFile: '', + }); + + await validate(content, config, schema); + + // Check Apollo Tooling style: QueryName_field1_field2_field3 + expect(content).toContain('DeeplyNested_root_field1_field2_field3'); + expect(content).toContain('DeeplyNested_root_field1_field2'); + expect(content).toContain('DeeplyNested_root_field1'); + expect(content).toContain('DeeplyNested_root'); + + // Check that type names are NOT included + expect(content).not.toContain('DeeplyNested_root_Level1_field1'); + expect(content).not.toContain('Level2_field2_Level3'); + + // Make sure Query suffix is omitted + expect(content).not.toContain('DeeplyNestedQuery_root_field1'); + }); +}); 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..bf09922b3f2 100644 --- a/packages/plugins/typescript/operations/tests/extract-all-types.spec.ts +++ b/packages/plugins/typescript/operations/tests/extract-all-types.spec.ts @@ -70,7 +70,6 @@ describe('extractAllFieldsToTypes: true', () => { it('should extract types from queries', async () => { const config: TypeScriptDocumentsPluginConfig = { - preResolveTypes: true, extractAllFieldsToTypes: true, printFieldsOnNewLines: true, nonOptionalTypename: true, @@ -157,7 +156,7 @@ describe('extractAllFieldsToTypes: true', () => { export type OverlappingFieldsMergingTestQuery_Query = { __typename: 'Query', - me?: OverlappingFieldsMergingTestQuery_me | null + me: OverlappingFieldsMergingTestQuery_me | null }; @@ -187,7 +186,7 @@ describe('extractAllFieldsToTypes: true', () => { export type NestedOverlappingFieldsMergingTestQuery_Query = { __typename: 'Query', - me?: NestedOverlappingFieldsMergingTestQuery_me | null + me: NestedOverlappingFieldsMergingTestQuery_me | null }; @@ -389,7 +388,6 @@ describe('extractAllFieldsToTypes: true', () => { it('should extract types from multiple fragments', async () => { const config: TypeScriptDocumentsPluginConfig = { - preResolveTypes: true, extractAllFieldsToTypes: true, nonOptionalTypename: true, dedupeOperationSuffix: true, @@ -401,7 +399,13 @@ describe('extractAllFieldsToTypes: true', () => { { outputFile: '' } ); expect(content).toMatchInlineSnapshot(` - "export type ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle = { __typename: 'ArchivedArticle', id: string, htmlUrl: string, title: string, url: string }; + "export type CallType = + | 'OUTGOING' + | 'INCOMING' + | 'VOICEMAIL' + | 'UNKNOWN'; + + export type ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle = { __typename: 'ArchivedArticle', id: string, htmlUrl: string, title: string, url: string }; export type ConversationBotSolutionFragment_BotSolution_originatedFrom_EmailInteraction = { __typename: 'EmailInteraction', originalEmailURLPath: string }; @@ -409,11 +413,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 +443,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 +505,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 +529,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' }; @@ -552,7 +556,6 @@ describe('extractAllFieldsToTypes: true', () => { it('should extract types from multiple fragments (mergeFragmentTypes: true)', async () => { const config: TypeScriptDocumentsPluginConfig = { - preResolveTypes: true, extractAllFieldsToTypes: true, nonOptionalTypename: true, dedupeOperationSuffix: true, @@ -565,7 +568,13 @@ describe('extractAllFieldsToTypes: true', () => { { outputFile: '' } ); expect(content).toMatchInlineSnapshot(` - "export type ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle = ( + "export type CallType = + | 'OUTGOING' + | 'INCOMING' + | 'VOICEMAIL' + | 'UNKNOWN'; + + export type ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle = ( { id: string, htmlUrl: string, title: string, url: string } & { __typename: 'ArchivedArticle' } ); @@ -583,7 +592,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 +631,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 +677,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 +704,7 @@ describe('extractAllFieldsToTypes: true', () => { ); export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_NativeMessagingInteraction_WhatsAppInteraction_WeChatInteraction = ( - { conversationId?: string | null } + { conversationId: string | null } & { __typename: 'NativeMessagingInteraction' | 'WhatsAppInteraction' | 'WeChatInteraction' } ); @@ -721,7 +730,6 @@ describe('extractAllFieldsToTypes: true', () => { it("should extract types from multiple fragments (inlineFragmentTypes: 'combine')", async () => { const config: TypeScriptDocumentsPluginConfig = { - preResolveTypes: true, extractAllFieldsToTypes: true, nonOptionalTypename: true, dedupeOperationSuffix: true, @@ -734,7 +742,13 @@ describe('extractAllFieldsToTypes: true', () => { { outputFile: '' } ); expect(content).toMatchInlineSnapshot(` - "export type ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle = { __typename: 'ArchivedArticle', id: string, htmlUrl: string, title: string, url: string }; + "export type CallType = + | 'OUTGOING' + | 'INCOMING' + | 'VOICEMAIL' + | 'UNKNOWN'; + + export type ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle = { __typename: 'ArchivedArticle', id: string, htmlUrl: string, title: string, url: string }; export type ConversationBotSolutionFragment_BotSolution_originatedFrom_EmailInteraction = ( { __typename: 'EmailInteraction' } @@ -890,17 +904,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 ); @@ -959,7 +973,6 @@ describe('extractAllFieldsToTypes: true', () => { it("should extract types from multiple fragments (inlineFragmentTypes: 'mask')", async () => { const config: TypeScriptDocumentsPluginConfig = { - preResolveTypes: true, extractAllFieldsToTypes: true, nonOptionalTypename: true, dedupeOperationSuffix: true, @@ -972,7 +985,13 @@ describe('extractAllFieldsToTypes: true', () => { { outputFile: '' } ); expect(content).toMatchInlineSnapshot(` - "export type ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle = { __typename: 'ArchivedArticle', id: string, htmlUrl: string, title: string, url: string }; + "export type CallType = + | 'OUTGOING' + | 'INCOMING' + | 'VOICEMAIL' + | 'UNKNOWN'; + + export type ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle = { __typename: 'ArchivedArticle', id: string, htmlUrl: string, title: string, url: string }; export type ConversationBotSolutionFragment_BotSolution_originatedFrom_EmailInteraction = ( { __typename: 'EmailInteraction' } @@ -1127,17 +1146,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' }; @@ -1192,274 +1211,4 @@ describe('extractAllFieldsToTypes: true', () => { await validate(content, config, complexTestSchemaWithUnionsAndInterfaces); }); - - it('should extract types from multiple fragments (preResolveTypes: false)', async () => { - const config: TypeScriptDocumentsPluginConfig = { - preResolveTypes: false, - extractAllFieldsToTypes: true, - nonOptionalTypename: true, - dedupeOperationSuffix: true, - }; - const { content } = await plugin( - complexTestSchemaWithUnionsAndInterfaces, - [{ location: 'test-file.ts', document: fragmentsOnComplexSchema }], - config, - { outputFile: '' } - ); - expect(content).toMatchInlineSnapshot(` - "export type ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle = ( - { __typename: 'ArchivedArticle' } - & Pick< - ArchivedArticle, - | 'id' - | 'htmlUrl' - | 'title' - | 'url' - > - ); - - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_EmailInteraction = ( - { __typename: 'EmailInteraction' } - & Pick - ); - - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_CustomChannelInteraction = ( - { __typename: 'CustomChannelInteraction' } - & Pick - ); - - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_TalkInteraction = { __typename: 'TalkInteraction' }; - - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_NativeMessagingInteraction = ( - { __typename: 'NativeMessagingInteraction' } - & Pick - ); - - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_WhatsAppInteraction = ( - { __typename: 'WhatsAppInteraction' } - & Pick - ); - - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_WeChatInteraction = ( - { __typename: 'WeChatInteraction' } - & Pick - ); - - export type ConversationBotSolutionFragment_BotSolution_originatedFrom_NotImplementedOriginatedFrom = { __typename: 'NotImplementedOriginatedFrom' }; - - export type ConversationBotSolutionFragment_BotSolution_originatedFrom = - | ConversationBotSolutionFragment_BotSolution_originatedFrom_EmailInteraction - | ConversationBotSolutionFragment_BotSolution_originatedFrom_CustomChannelInteraction - | ConversationBotSolutionFragment_BotSolution_originatedFrom_TalkInteraction - | ConversationBotSolutionFragment_BotSolution_originatedFrom_NativeMessagingInteraction - | ConversationBotSolutionFragment_BotSolution_originatedFrom_WhatsAppInteraction - | ConversationBotSolutionFragment_BotSolution_originatedFrom_WeChatInteraction - | ConversationBotSolutionFragment_BotSolution_originatedFrom_NotImplementedOriginatedFrom - ; - - export type ConversationBotSolutionFragment = ( - { __typename: 'BotSolution' } - & Pick - & { - article: ConversationBotSolutionFragment_BotSolution_article_ArchivedArticle, - originatedFrom: ConversationBotSolutionFragment_BotSolution_originatedFrom, - } - ); - - export type ConversationGenericCallSummaryFragment = ( - { __typename: 'TalkPublicCallSummary' } - & Pick - ); - - export type ConversationTalkInteractionFragment = ( - { __typename: 'TalkInteraction' } - & Pick - ); - - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_EmailInteraction = ( - { __typename: 'EmailInteraction' } - & Pick - ); - - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_CustomChannelInteraction = ( - { __typename: 'CustomChannelInteraction' } - & Pick - ); - - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_TalkInteraction = { __typename: 'TalkInteraction' }; - - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_NativeMessagingInteraction = ( - { __typename: 'NativeMessagingInteraction' } - & Pick - ); - - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_WhatsAppInteraction = ( - { __typename: 'WhatsAppInteraction' } - & Pick - ); - - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_WeChatInteraction = ( - { __typename: 'WeChatInteraction' } - & Pick - ); - - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_NotImplementedOriginatedFrom = { __typename: 'NotImplementedOriginatedFrom' }; - - export type ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom = - | ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_EmailInteraction - | ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_CustomChannelInteraction - | ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_TalkInteraction - | ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_NativeMessagingInteraction - | ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_WhatsAppInteraction - | ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_WeChatInteraction - | ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom_NotImplementedOriginatedFrom - ; - - type ConversationConversationEvent_BrokenConversationEvent_Fragment = ( - { __typename: 'BrokenConversationEvent' } - & Pick - & { originatedFrom: ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom } - ); - - type ConversationConversationEvent_BotSolution_Fragment = ( - { __typename: 'BotSolution' } - & Pick - & { originatedFrom: ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom } - ); - - type ConversationConversationEvent_TalkPublicCallSummary_Fragment = ( - { __typename: 'TalkPublicCallSummary' } - & Pick - & { originatedFrom: ConversationConversationEventFragment_BrokenConversationEvent_originatedFrom } - ); - - export type ConversationConversationEventFragment = - | ConversationConversationEvent_BrokenConversationEvent_Fragment - | ConversationConversationEvent_BotSolution_Fragment - | ConversationConversationEvent_TalkPublicCallSummary_Fragment - ; - - type MessageEnvelopeData_EmailInteraction_Fragment = ( - { __typename: 'EmailInteraction' } - & Pick - ); - - type MessageEnvelopeData_CustomChannelInteraction_Fragment = { __typename: 'CustomChannelInteraction' }; - - type MessageEnvelopeData_TalkInteraction_Fragment = { __typename: 'TalkInteraction' }; - - type MessageEnvelopeData_NativeMessagingInteraction_Fragment = { __typename: 'NativeMessagingInteraction' }; - - type MessageEnvelopeData_WhatsAppInteraction_Fragment = { __typename: 'WhatsAppInteraction' }; - - type MessageEnvelopeData_WeChatInteraction_Fragment = { __typename: 'WeChatInteraction' }; - - type MessageEnvelopeData_NotImplementedOriginatedFrom_Fragment = { __typename: 'NotImplementedOriginatedFrom' }; - - export type MessageEnvelopeDataFragment = - | MessageEnvelopeData_EmailInteraction_Fragment - | MessageEnvelopeData_CustomChannelInteraction_Fragment - | MessageEnvelopeData_TalkInteraction_Fragment - | MessageEnvelopeData_NativeMessagingInteraction_Fragment - | MessageEnvelopeData_WhatsAppInteraction_Fragment - | MessageEnvelopeData_WeChatInteraction_Fragment - | MessageEnvelopeData_NotImplementedOriginatedFrom_Fragment - ; - - export type AnyChannelOriginatedFromFragment = ( - { __typename: 'CustomChannelInteraction' } - & Pick - ); - - type ConversationOriginatedFrom_EmailInteraction_Fragment = ( - { __typename: 'EmailInteraction' } - & Pick - ); - - type ConversationOriginatedFrom_CustomChannelInteraction_Fragment = ( - { __typename: 'CustomChannelInteraction' } - & Pick - ); - - type ConversationOriginatedFrom_TalkInteraction_Fragment = { __typename: 'TalkInteraction' }; - - type ConversationOriginatedFrom_NativeMessagingInteraction_Fragment = ( - { __typename: 'NativeMessagingInteraction' } - & Pick - ); - - type ConversationOriginatedFrom_WhatsAppInteraction_Fragment = ( - { __typename: 'WhatsAppInteraction' } - & Pick - ); - - type ConversationOriginatedFrom_WeChatInteraction_Fragment = ( - { __typename: 'WeChatInteraction' } - & Pick - ); - - type ConversationOriginatedFrom_NotImplementedOriginatedFrom_Fragment = { __typename: 'NotImplementedOriginatedFrom' }; - - export type ConversationOriginatedFromFragment = - | ConversationOriginatedFrom_EmailInteraction_Fragment - | ConversationOriginatedFrom_CustomChannelInteraction_Fragment - | ConversationOriginatedFrom_TalkInteraction_Fragment - | ConversationOriginatedFrom_NativeMessagingInteraction_Fragment - | ConversationOriginatedFrom_WhatsAppInteraction_Fragment - | ConversationOriginatedFrom_WeChatInteraction_Fragment - | ConversationOriginatedFrom_NotImplementedOriginatedFrom_Fragment - ; - - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_EmailInteraction = ( - { __typename: 'EmailInteraction' } - & Pick - ); - - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_CustomChannelInteraction = ( - { __typename: 'CustomChannelInteraction' } - & Pick - ); - - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_TalkInteraction = ( - { __typename: 'TalkInteraction' } - & Pick - ); - - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_NativeMessagingInteraction = ( - { __typename: 'NativeMessagingInteraction' } - & Pick - ); - - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_WhatsAppInteraction = ( - { __typename: 'WhatsAppInteraction' } - & Pick - ); - - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_WeChatInteraction = ( - { __typename: 'WeChatInteraction' } - & Pick - ); - - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_NotImplementedOriginatedFrom = { __typename: 'NotImplementedOriginatedFrom' }; - - export type ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom = - | ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_EmailInteraction - | ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_CustomChannelInteraction - | ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_TalkInteraction - | ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_NativeMessagingInteraction - | ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_WhatsAppInteraction - | ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_WeChatInteraction - | ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom_NotImplementedOriginatedFrom - ; - - export type ConversationTalkPublicCallSummaryFragment = ( - { __typename: 'TalkPublicCallSummary' } - & Pick - & { originatedFrom: ConversationTalkPublicCallSummaryFragment_TalkPublicCallSummary_originatedFrom } - ); - " - `); - - await validate(content, config, complexTestSchemaWithUnionsAndInterfaces); - }); }); 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..3aa34bd69b9 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.apolloUnmask.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.apolloUnmask.spec.ts @@ -25,9 +25,9 @@ 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 = { me: { id: string } | null }; - export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; + export type UserFragmentFragment = { id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; " `); }); @@ -53,12 +53,9 @@ describe('TypeScript Operations Plugin - apolloUnmask', () => { "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( - { __typename?: 'User' } - & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } } - ) | null }; + export type Unnamed_1_Query = { me: { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } } | null }; - export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; + export type UserFragmentFragment = { id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; " `); }); @@ -84,12 +81,9 @@ describe('TypeScript Operations Plugin - apolloUnmask', () => { "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( - { __typename?: 'User' } - & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } } - ) | null }; + export type Unnamed_1_Query = { me: { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } } | null }; - export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; + export type UserFragmentFragment = { id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; " `); }); @@ -120,14 +114,14 @@ 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 } + export type Unnamed_1_Query = { me: ( + { id: string } & { ' $fragmentRefs'?: { 'UserFragment2Fragment': UserFragment2Fragment } } ) | null }; - export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; + export type UserFragmentFragment = { id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; - export type UserFragment2Fragment = { __typename?: 'User', email: string } & { ' $fragmentName'?: 'UserFragment2Fragment' }; + export type UserFragment2Fragment = { email: string } & { ' $fragmentName'?: 'UserFragment2Fragment' }; " `); }); @@ -159,14 +153,14 @@ 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, email: string } + export type Unnamed_1_Query = { me: ( + { id: string, email: string } & { ' $fragmentRefs'?: { 'UserFragment2Fragment': UserFragment2Fragment } } ) | null }; - export type UserFragmentFragment = { __typename?: 'User', id: string, email: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; + export type UserFragmentFragment = { id: string, email: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; - export type UserFragment2Fragment = { __typename?: 'User', email: string } & { ' $fragmentName'?: 'UserFragment2Fragment' }; + export type UserFragment2Fragment = { email: string } & { ' $fragmentName'?: 'UserFragment2Fragment' }; " `); }); 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 8f7e8a7c6ee..36dca772464 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.nullability.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.nullability.spec.ts @@ -62,27 +62,30 @@ const document = parse(/* GraphQL */ ` describe('TypeScript Operations Plugin - nullability', () => { it('converts semanticNonNull to nonNull when nullability.errorHandlingClient=true', async () => { - const result = await plugin(schema, [{ document }], { - nullability: { - errorHandlingClient: true, + const result = await plugin( + schema, + [{ document }], + { + nullability: { + errorHandlingClient: true, + }, }, - }); + { outputFile: '' } + ); const formattedContent = prettier.format(result.content, { parser: 'typescript' }); expect(formattedContent).toMatchInlineSnapshot(` "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never }>; export type Unnamed_1_Query = { - __typename?: "Query"; - me?: { - __typename?: "User"; + me: { 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; @@ -90,7 +93,7 @@ describe('TypeScript Operations Plugin - nullability', () => { nonNullableListBothLevels: Array; listWithNonNullableItem: Array; listWithNonNullableItemLevel0: Array; - listWithNonNullableItemLevel1?: Array | null; + listWithNonNullableItemLevel1: Array | null; listWithNonNullableItemBothLevels: Array; nonNullableListWithNonNullableItem: Array; nonNullableListWithNonNullableItemLevel0: Array; @@ -103,36 +106,39 @@ describe('TypeScript Operations Plugin - nullability', () => { }); it('does not convert nullability to nonNull when nullability.errorHandlingClient=false', async () => { - const result = await plugin(schema, [{ document }], { - nullability: { - errorHandlingClient: false, + const result = await plugin( + schema, + [{ document }], + { + nullability: { + errorHandlingClient: false, + }, }, - }); + { outputFile: '' } + ); const formattedContent = prettier.format(result.content, { parser: 'typescript' }); expect(formattedContent).toMatchInlineSnapshot(` "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never }>; export type Unnamed_1_Query = { - __typename?: "Query"; - 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; + me: { + 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 89945dcc0a9..3976a631b8c 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.spec.ts @@ -1,21 +1,14 @@ import { mergeOutputs, Types } from '@graphql-codegen/plugin-helpers'; import { validateTs } from '@graphql-codegen/testing'; import { buildClientSchema, buildSchema, parse } from 'graphql'; -import { plugin as tsPlugin } from '../../typescript/src/index.js'; import { plugin } from '../src/index.js'; 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; @@ -41,62 +34,15 @@ describe('TypeScript Operations Plugin', () => { } } `); - const config = { noExport: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { noExport: true }, + { outputFile: '' } + ); expect(content).not.toContain('export'); - await validate(content, config); - }); - - it('Should handle "namespacedImportName" and add it when specified', async () => { - const ast = parse(/* GraphQL */ ` - query notifications { - notifications { - id - - ... on TextNotification { - text - textAlias: text - } - - ... on TextNotification { - text - } - - ... on ImageNotification { - imageUrl - metadata { - created: createdBy - } - } - } - } - `); - const config = { preResolveTypes: false, namespacedImportName: 'Types' }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - - expect(content).toBeSimilarStringTo(` - export type NotificationsQuery = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - & { textAlias: Types.TextNotification['text'] } - ) | ( - { __typename?: 'ImageNotification' } - & Pick - & { metadata: ( - { __typename?: 'ImageMetadata' } - & { created: Types.ImageMetadata['createdBy'] } - ) } - )> } - ); - `); - await validate(content, config, schema, '', [`Cannot find namespace 'Types'.`]); + await validate(content); }); it('Can merge an inline fragment with a spread', async () => { @@ -146,57 +92,20 @@ describe('TypeScript Operations Plugin', () => { testSchema, [{ location: 'test-file.ts', document: ast }], {}, - { - outputFile: '', - } + { outputFile: '' } ); - expect(content).toBeSimilarStringTo(` - export type PostFragment = { __typename?: 'Post', id: string, comments: Array<{ __typename?: 'TextComment', text: string } | { __typename?: 'ImageComment' }> }; - - export type PostPlusFragment = { __typename?: 'Post', id: string, comments: Array<{ __typename?: 'TextComment', text: string, id: string } | { __typename?: 'ImageComment', id: string }> }; - `); - }); - - it('Should handle "namespacedImportName" and "preResolveTypes" together', async () => { - const testSchema = buildSchema(/* GraphQL */ ` - type Query { - f: E - user: User! - } - - enum E { - A - B - } - - scalar JSON + expect(content).toMatchInlineSnapshot(` + "export type PostFragment = { id: string, comments: Array< + | { text: string } + | Record + > }; - type User { - id: ID! - f: E - j: JSON - } - `); - const ast = parse(/* GraphQL */ ` - query test { - f - user { - id - f - j - } - } + export type PostPlusFragment = { id: string, comments: Array< + | { text: string, id: string } + | { id: string } + > }; + " `); - const config = { namespacedImportName: 'Types', preResolveTypes: true }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - - expect(content).toBeSimilarStringTo( - `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'.`]); }); it('Should generate the correct output when using immutableTypes config', async () => { @@ -218,28 +127,28 @@ describe('TypeScript Operations Plugin', () => { } } `); - const config = { preResolveTypes: false, namingConvention: 'change-case-all#lowerCase', immutableTypes: true }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type notificationsquery = ( - { readonly __typename?: 'Query' } - & { readonly notifications: ReadonlyArray<( - { readonly __typename?: 'TextNotification' } - & Pick - ) | ( - { readonly __typename?: 'ImageNotification' } - & Pick - & { readonly metadata: ( - { readonly __typename?: 'ImageMetadata' } - & Pick - ) } - )> } - ); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { + namingConvention: 'change-case-all#lowerCase', + immutableTypes: true, + }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type notificationsqueryvariables = Exact<{ [key: string]: never; }>; + + + export type notificationsquery = { readonly notifications: ReadonlyArray< + | { readonly text: string, readonly id: string } + | { readonly imageUrl: string, readonly id: string, readonly metadata: { readonly createdBy: string } } + > }; + " `); - await validate(content, config); + await validate(content); }); it('should include fragment variable definitions when experimentalFragmentVariables is set', async () => { @@ -290,15 +199,20 @@ describe('TypeScript Operations Plugin', () => { schema, [{ location: '', document: fragment }], { - preResolveTypes: true, maybeValue: "T | 'specialType'", }, { outputFile: 'graphql.ts', } ); - expect(content).toBeSimilarStringTo(` - export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', name: string, age?: number | 'specialType', address?: string, nicknames?: Array | 'specialType', parents?: Array } }; + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ + showProperty: boolean; + }>; + + + export type UserQuery = { user: { name: string, age: number | 'specialType', address?: string, nicknames?: Array | 'specialType', parents?: Array } }; + " `); }); @@ -333,49 +247,20 @@ describe('TypeScript Operations Plugin', () => { schema, [{ location: '', document: fragment }], { - preResolveTypes: true, allowUndefinedQueryVariables: true, }, - { - outputFile: 'graphql.ts', - } + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ - showProperty: Scalars['Boolean']['input']; + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ + showProperty: boolean; }> | undefined; - `); - }); - }); - describe('Scalars', () => { - it('Should include scalars when doing pick', async () => { - const testSchema = buildSchema(/* GraphQL */ ` - scalar Date - type Query { - me: User - } - type User { - id: ID! - joinDate: Date! - } - `); - const doc = parse(/* GraphQL */ ` - query { - me { - id - joinDate - } - } + export type UserQuery = { user: { name: string, age: number | null, address?: string, nicknames?: Array | null, parents?: Array } }; + " `); - const config = { preResolveTypes: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: doc }], config, { - outputFile: '', - }); - expect(content).toContain(`Pick`); - await validate(content, config, testSchema); }); }); @@ -399,32 +284,38 @@ describe('TypeScript Operations Plugin', () => { } } `); - const config = { operationResultSuffix: 'Result', preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo( - `export type NotificationsQueryVariables = Exact<{ [key: string]: never; }>;` + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { operationResultSuffix: 'Result' }, + { outputFile: '' } ); - expect(content).toBeSimilarStringTo(` - export type NotificationsQueryResult = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - & { metadata: ( - { __typename?: 'ImageMetadata' } - & Pick - ) } - )> } - ); + + expect(content).toMatchInlineSnapshot( + ` + "export type NotificationsQueryVariables = Exact<{ [key: string]: never; }>; + + + export type NotificationsQueryResult = { notifications: Array< + | { text: string, id: string } + | { imageUrl: string, id: string, metadata: { createdBy: string } } + > }; + " + ` + ); + expect(content).toMatchInlineSnapshot(` + "export type NotificationsQueryVariables = Exact<{ [key: string]: never; }>; + + + export type NotificationsQueryResult = { notifications: Array< + | { text: string, id: string } + | { imageUrl: string, id: string, metadata: { createdBy: string } } + > }; + " `); - await validate(content, config); + await validate(content); }); }); @@ -448,28 +339,25 @@ describe('TypeScript Operations Plugin', () => { } } `); - const config = { preResolveTypes: false, namingConvention: 'change-case-all#lowerCase' }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type notificationsquery = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - & { metadata: ( - { __typename?: 'ImageMetadata' } - & Pick - ) } - )> } - ); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { namingConvention: 'change-case-all#lowerCase' }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type notificationsqueryvariables = Exact<{ [key: string]: never; }>; + + + export type notificationsquery = { notifications: Array< + | { text: string, id: string } + | { imageUrl: string, id: string, metadata: { createdBy: string } } + > }; + " `); - await validate(content, config); + await validate(content); }); it('Should allow custom naming and point to the correct type - with custom prefix', async () => { @@ -492,31 +380,27 @@ describe('TypeScript Operations Plugin', () => { } `); - const config = { preResolveTypes: false, typesPrefix: 'i', namingConvention: 'change-case-all#lowerCase' }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { typesPrefix: 'i', namingConvention: 'change-case-all#lowerCase' }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot( + ` + "export type inotificationsqueryvariables = Exact<{ [key: string]: never; }>; - expect(content).toBeSimilarStringTo( - `export type inotificationsqueryvariables = Exact<{ [key: string]: never; }>;` + + export type inotificationsquery = { notifications: Array< + | { text: string, id: string } + | { imageUrl: string, id: string, metadata: { createdBy: string } } + > }; + " + ` ); - expect(content).toBeSimilarStringTo(` - export type inotificationsquery = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - & { metadata: ( - { __typename?: 'ImageMetadata' } - & Pick - ) } - )> } - ); - `); - await validate(content, config); + + await validate(content); }); it('Test for dedupeOperationSuffix', async () => { @@ -629,33 +513,24 @@ describe('TypeScript Operations Plugin', () => { await plugin( schema, [{ location: 'test-file.ts', document: ast3 }], - { dedupeOperationSuffix: true, preResolveTypes: false }, + { dedupeOperationSuffix: true }, { outputFile: '' } ) ).content; - expect(withUsage).toBeSimilarStringTo(` - export type MyFragment = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - )> } - ); - `); - expect(withUsage).toBeSimilarStringTo(` - export type NotificationsQuery = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - )> } - ); + expect(withUsage).toMatchInlineSnapshot(` + "export type NotificationsQueryVariables = Exact<{ [key: string]: never; }>; + + + export type NotificationsQuery = { notifications: Array< + | { id: string } + | { id: string } + > }; + + export type MyFragment = { notifications: Array< + | { id: string } + | { id: string } + > }; + " `); }); }); @@ -700,31 +575,17 @@ describe('TypeScript Operations Plugin', () => { `); expect( - ( - await plugin( - schema, - [{ location: 'test-file.ts', document: ast }], - { preResolveTypes: false }, - { outputFile: '' } - ) - ).content + (await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' })).content ).toContain('export type NotificationsQueryQuery ='); expect( - ( - await plugin( - schema, - [{ location: 'test-file.ts', document: ast }], - { preResolveTypes: false }, - { outputFile: '' } - ) - ).content + (await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' })).content ).toContain('export type MyFragmentFragment ='); expect( ( await plugin( schema, [{ location: 'test-file.ts', document: ast }], - { omitOperationSuffix: true, preResolveTypes: false }, + { omitOperationSuffix: true }, { outputFile: '' } ) ).content @@ -734,7 +595,7 @@ describe('TypeScript Operations Plugin', () => { await plugin( schema, [{ location: 'test-file.ts', document: ast }], - { omitOperationSuffix: true, preResolveTypes: false }, + { omitOperationSuffix: true }, { outputFile: '' } ) ).content @@ -744,7 +605,7 @@ describe('TypeScript Operations Plugin', () => { await plugin( schema, [{ location: 'test-file.ts', document: ast2 }], - { omitOperationSuffix: true, preResolveTypes: false }, + { omitOperationSuffix: true }, { outputFile: '' } ) ).content @@ -754,7 +615,7 @@ describe('TypeScript Operations Plugin', () => { await plugin( schema, [{ location: 'test-file.ts', document: ast2 }], - { omitOperationSuffix: true, preResolveTypes: false }, + { omitOperationSuffix: true }, { outputFile: '' } ) ).content @@ -764,7 +625,7 @@ describe('TypeScript Operations Plugin', () => { await plugin( schema, [{ location: 'test-file.ts', document: ast2 }], - { omitOperationSuffix: false, preResolveTypes: false }, + { omitOperationSuffix: false }, { outputFile: '' } ) ).content @@ -774,7 +635,7 @@ describe('TypeScript Operations Plugin', () => { await plugin( schema, [{ location: 'test-file.ts', document: ast2 }], - { omitOperationSuffix: false, preResolveTypes: false }, + { omitOperationSuffix: false }, { outputFile: '' } ) ).content @@ -784,33 +645,24 @@ describe('TypeScript Operations Plugin', () => { await plugin( schema, [{ location: 'test-file.ts', document: ast3 }], - { omitOperationSuffix: true, preResolveTypes: false }, + { omitOperationSuffix: true }, { outputFile: '' } ) ).content; - expect(withUsage).toBeSimilarStringTo(` - export type My = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - )> } - ); - `); - expect(withUsage).toBeSimilarStringTo(` - export type Notifications = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - )> } - ); + expect(withUsage).toMatchInlineSnapshot(` + "export type NotificationsVariables = Exact<{ [key: string]: never; }>; + + + export type Notifications = { notifications: Array< + | { id: string } + | { id: string } + > }; + + export type My = { notifications: Array< + | { id: string } + | { id: string } + > }; + " `); }); @@ -832,21 +684,24 @@ describe('TypeScript Operations Plugin', () => { } } `); - const config = { - skipTypeNameForRoot: true, - preResolveTypes: false, - }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo( - `export type Q1Query = { test?: Maybe<( - { __typename?: 'Test' } - & Pick - )> };` + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + { skipTypeNameForRoot: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot( + ` + "export type Q1QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Q1Query = { test: { foo: string | null } | null }; + " + ` ); - await validate(content, config, testSchema); + await validate(content); }); it('Should ignore __typename for root types with skipTypeNameForRoot = true, and with nonOptionalTypename = true', async () => { @@ -866,22 +721,27 @@ describe('TypeScript Operations Plugin', () => { } } `); - const config = { - nonOptionalTypename: true, - skipTypeNameForRoot: true, - preResolveTypes: false, - }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo( - `export type Q1Query = { test?: Maybe<( - { __typename: 'Test' } - & Pick - )> };` + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + { + nonOptionalTypename: true, + skipTypeNameForRoot: true, + }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot( + ` + "export type Q1QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Q1Query = { test: { __typename: 'Test', foo: string | null } | null }; + " + ` ); - await validate(content, config, testSchema); + await validate(content); }); it('Should ignore skipTypeNameForRoot = true when __typename is specified manually', async () => { @@ -902,28 +762,30 @@ describe('TypeScript Operations Plugin', () => { } } `); - const config = { - nonOptionalTypename: true, - skipTypeNameForRoot: true, - preResolveTypes: false, - }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo( - `export type Q1Query = ( - { __typename: 'Query' } - & { test?: Maybe<( - { __typename: 'Test' } - & Pick - )> } - );` + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + { + nonOptionalTypename: true, + skipTypeNameForRoot: true, + }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot( + ` + "export type Q1QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Q1Query = { __typename: 'Query', test: { __typename: 'Test', foo: string | null } | null }; + " + ` ); - await validate(content, config, testSchema); + await validate(content); }); - it('Should add __typename correctly with nonOptionalTypename=false,skipTypename=true,preResolveTypes=true and explicit field', async () => { + it('Should add __typename correctly with nonOptionalTypename=false,skipTypename=true and explicit field', async () => { const testSchema = buildSchema(/* GraphQL */ ` type Search { search: [SearchResult!]! @@ -974,20 +836,23 @@ describe('TypeScript Operations Plugin', () => { } } `); - const config = { - nonOptionalTypename: false, - skipTypename: true, - }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toContain( - `\ -export type Q1Query = { search: Array< - | { __typename: 'Movie', id: string, title: string } - | { __typename: 'Person', id: string, name: string } - > };` + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + { + nonOptionalTypename: false, + skipTypename: true, + }, + { outputFile: '' } + ); + + expect(content).toContain( + `\ +export type Q1Query = { search: Array< + | { __typename: 'Movie', id: string, title: string } + | { __typename: 'Person', id: string, name: string } + > };` ); expect(content).toContain( `\ @@ -996,7 +861,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 () => { @@ -1005,13 +870,16 @@ export type Q2Query = { search: Array< dummy } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); + + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); expect(content).not.toContain(`__typename`); - await validate(content, config); + await validate(content); }); it('Should add __typename when dealing with fragments', async () => { @@ -1046,23 +914,33 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type TestQuery = ( - { __typename?: 'Query' } - & { some?: Maybe<( - { __typename: 'A' } - & Pick - ) | ( - { __typename: 'B' } - & Pick - )> } + + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } ); + expect(content).toMatchInlineSnapshot(` + "type Node_A_Fragment = { __typename: 'A', id: string }; + + type Node_B_Fragment = { __typename: 'B', id: string }; + + export type NodeFragment = + | Node_A_Fragment + | Node_B_Fragment + ; + + export type TestQueryVariables = Exact<{ [key: string]: never; }>; + + + export type TestQuery = { some: + | { __typename: 'A', id: string } + | { __typename: 'B', id: string } + | null }; + " `); - await validate(content, config, testSchema); + await validate(content); }); it('Should add aliased __typename correctly', async () => { @@ -1072,35 +950,16 @@ export type Q2Query = { search: Array< dummy } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = ( - { __typename?: 'Query' } - & Pick - & { type: 'Query' } - ); - `); - await validate(content, config); - }); - it('Should add aliased __typename correctly with preResovleTypes', async () => { - const ast = parse(/* GraphQL */ ` - query { - type: __typename - dummy - } - `); - const config = { preResolveTypes: true }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = { __typename?: 'Query', dummy?: string | null, type: 'Query' }; + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { dummy: string | null, type: 'Query' }; + " `); - await validate(content, config); + await validate(content); }); it('Should add __typename as non-optional when explicitly specified', async () => { @@ -1110,17 +969,16 @@ export type Q2Query = { search: Array< dummy } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = ( - { __typename: 'Query' } - & Pick - ); + + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { __typename: 'Query', dummy: string | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should add __typename as non-optional when forced', async () => { @@ -1129,36 +987,21 @@ export type Q2Query = { search: Array< dummy } `); - const config = { nonOptionalTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = ( - { __typename: 'Query' } - & Pick - ); - `); - await validate(content, config); - }); - it('Should add __typename as optional when its not specified', async () => { - const ast = parse(/* GraphQL */ ` - query { - dummy - } - `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = ( - { __typename?: 'Query' } - & Pick - ); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { nonOptionalTypename: true }, + { outputFile: '' } + ); + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { __typename: 'Query', dummy: string | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should add __typename as non-optional when its explictly specified, even if skipTypename is true', async () => { @@ -1168,21 +1011,25 @@ export type Q2Query = { search: Array< dummy } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = ( - { __typename: 'Query' } - & Pick - ); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { __typename: 'Query', dummy: string | null }; + " `); - await validate(content, config); + await validate(content); }); - it('Should add __typename correctly when unions are in use', async () => { + it('Should add __typename correctly when unions are in use and nonOptionalTypename=true', async () => { const ast = parse(/* GraphQL */ ` query unionTest { unionTest { @@ -1196,26 +1043,27 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type UnionTestQuery = ( - { __typename?: 'Query' } - & { unionTest?: Maybe<( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'Profile' } - & Pick - )> } - ); + + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { nonOptionalTypename: true }, + { outputFile: '' } + ); + expect(content).toMatchInlineSnapshot(` + "export type UnionTestQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UnionTestQuery = { __typename: 'Query', unionTest: + | { __typename: 'User', id: string } + | { __typename: 'Profile', age: number | null } + | null }; + " `); - await validate(content, config); + await validate(content); }); - it('Should add __typename correctly when interfaces are in use', async () => { + it('Should add __typename correctly when interfaces are in use and nonOptionalTypename=true', async () => { const ast = parse(/* GraphQL */ ` query notifications { notifications { @@ -1234,27 +1082,24 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type NotificationsQuery = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - & { metadata: ( - { __typename?: 'ImageMetadata' } - & Pick - ) } - )> } - ); + + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { nonOptionalTypename: true }, + { outputFile: '' } + ); + expect(content).toMatchInlineSnapshot(` + "export type NotificationsQueryVariables = Exact<{ [key: string]: never; }>; + + + export type NotificationsQuery = { __typename: 'Query', notifications: Array< + | { __typename: 'TextNotification', text: string, id: string } + | { __typename: 'ImageNotification', imageUrl: string, id: string, metadata: { __typename: 'ImageMetadata', createdBy: string } } + > }; + " `); - 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 */ ` @@ -1270,23 +1115,19 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type NotificationsQuery = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename: 'TextNotification' } - & Pick - ) | ( - { __typename: 'ImageNotification' } - & Pick - )> } - ); + + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + expect(content).toMatchInlineSnapshot(` + "export type NotificationsQueryVariables = Exact<{ [key: string]: never; }>; + + + export type NotificationsQuery = { notifications: Array< + | { __typename: 'TextNotification', text: string } + | { __typename: 'ImageNotification', imageUrl: string } + > }; + " `); - 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 */ ` @@ -1302,22 +1143,19 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - { __typename?: 'Query' } - & { unionTest?: Maybe<( - { __typename: 'User' } - & Pick - ) | ( - { __typename: 'Profile' } - & Pick - )> } - ); - `); - await validate(content, config); + + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + expect(content).toMatchInlineSnapshot(` + "export type UnionTestQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UnionTestQuery = { unionTest: + | { __typename: 'User', email: string } + | { __typename: 'Profile', firstName: string } + | null }; + " + `); + await validate(content); }); }); @@ -1328,17 +1166,28 @@ export type Q2Query = { search: Array< dummy } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = Pick; + + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { dummy: string | null }; + " `); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { dummy: string | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should handle unnamed documents correctly with multiple documents', async () => { @@ -1351,24 +1200,63 @@ export type Q2Query = { search: Array< dummy } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = Pick; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { dummy: string | null }; + + export type Unnamed_2_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_2_Query = { dummy: string | null }; + " `); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { dummy: string | null }; + + export type Unnamed_2_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_2_Query = { dummy: string | null }; + " `); - expect(content).toBeSimilarStringTo(` - export type Unnamed_2_Query = Pick; + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { dummy: string | null }; + + export type Unnamed_2_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_2_Query = { dummy: string | null }; + " `); - expect(content).toBeSimilarStringTo(` + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { dummy: string | null }; + export type Unnamed_2_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_2_Query = { dummy: string | null }; + " `); - await validate(content, config); + await validate(content); }); }); @@ -1379,7 +1267,6 @@ export type Q2Query = { search: Array< test } `); - const config = { preResolveTypes: false }; try { await plugin( @@ -1389,7 +1276,7 @@ export type Q2Query = { search: Array< } `), [{ location: 'test-file.ts', document: ast }], - config, + {}, { outputFile: '' } ); expect(true).toBeFalsy(); @@ -1438,10 +1325,13 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); + + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } + ); const usage = ` type Route = QqQuery['routes'][0]; @@ -1455,7 +1345,7 @@ export type Q2Query = { search: Array< } `; - await validate(content, config, testSchema, usage); + await validate(content, usage); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1480,11 +1370,14 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - await validate(content, config, testSchema); + + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } + ); + await validate(content); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1513,11 +1406,14 @@ export type Q2Query = { search: Array< name } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - await validate(content, config, testSchema); + + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } + ); + await validate(content); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1544,11 +1440,14 @@ export type Q2Query = { search: Array< name } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - await validate(content, config, testSchema); + + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } + ); + await validate(content); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1578,14 +1477,15 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); + + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } + ); 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); @@ -1636,15 +1536,16 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); + + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } + ); await validate( content, - config, - testSchema, ` function test(a: UserFragment) { if (a.__typename === 'Tom') { @@ -1699,10 +1600,13 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); + + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } + ); const usage = ` type Route = QqQuery['routes'][0]; @@ -1716,7 +1620,7 @@ export type Q2Query = { search: Array< } `; - await validate(content, config, testSchema, usage); + await validate(content, usage); expect(mergeOutputs([content])).toMatchSnapshot(); }); @@ -1737,17 +1641,27 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type MeQuery = { me?: Maybe<( - Pick - & { profile?: Maybe> } - )> }; + + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + expect(content).toMatchInlineSnapshot(` + "export type Role = + | 'USER' + | 'ADMIN'; + + export type UserFieldsFragment = { id: string, username: string, role: Role | null, profile: { age: number | null } | null }; + + export type MeQueryVariables = Exact<{ [key: string]: never; }>; + + + export type MeQuery = { me: { id: string, username: string, role: Role | null, profile: { age: number | null } | null } | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should support fragment spread correctly with simple type with other fields', async () => { @@ -1766,18 +1680,24 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type MeQuery = { me?: Maybe<( - Pick - & { profile?: Maybe> } - )> }; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type UserFieldsFragment = { id: string, profile: { age: number | null } | null }; + + export type MeQueryVariables = Exact<{ [key: string]: never; }>; + + + export type MeQuery = { me: { username: string, id: string, profile: { age: number | null } | null } | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should support fragment spread correctly with multiple fragment spread', async () => { @@ -1800,40 +1720,26 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: false, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type MeQuery = ( - { __typename?: 'Query' } - & { me?: Maybe<( - { __typename?: 'User' } - & Pick - & { profile?: Maybe<( - { __typename?: 'Profile' } - & Pick - )> } - )> } + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: false }, + { outputFile: '' } ); + + expect(content).toMatchInlineSnapshot(` + "export type UserFieldsFragment = { id: string }; + + export type UserProfileFragment = { profile: { age: number | null } | null }; + + export type MeQueryVariables = Exact<{ [key: string]: never; }>; + + + export type MeQuery = { me: { username: string, id: string, profile: { age: number | null } | null } | null }; + " `); - expect(content).toBeSimilarStringTo(` - export type UserProfileFragment = ( - { __typename?: 'User' } - & { profile?: Maybe<( - { __typename?: 'Profile' } - & Pick - )> } - ); - `); - expect(content).toBeSimilarStringTo(` - export type UserFieldsFragment = ( - { __typename?: 'User' } - & Pick - ); - `); - await validate(content, config); + await validate(content); }); it('Should generate the correct intersection for fragments when using with interfaces with different type', async () => { @@ -1875,34 +1781,24 @@ export type Q2Query = { search: Array< y } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = ( - { __typename?: 'Query' } - & { b?: Maybe<( - { __typename?: 'A' } - & Pick - ) | ( - { __typename?: 'B' } - & Pick - )> } - ); + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); - export type AFragment = ( - { __typename?: 'A' } - & Pick - ); + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type BFragment = ( - { __typename?: 'B' } - & Pick - ); + + export type Unnamed_1_Query = { b: + | { id: string, x: number } + | { id: string, y: number } + | null }; + + export type AFragment = { id: string, x: number }; + + export type BFragment = { id: string, y: number }; + " `); - await validate(content, config, schema); + await validate(content); }); it('Should generate the correct intersection for fragments when type implements 2 interfaces', async () => { @@ -1947,20 +1843,22 @@ export type Q2Query = { search: Array< bar } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = ( - { __typename?: 'Query' } - & { myType: ( - { __typename?: 'MyType' } - & Pick - ) } - ); + + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { myType: { foo: string, bar: string, test: string } }; + + export type CFragment = { test: string }; + + export type AFragment = { foo: string }; + + export type BFragment = { bar: string }; + " `); - await validate(content, config, schema); + await validate(content); }); it('Should generate the correct intersection for fragments when using with interfaces with same type', async () => { @@ -2000,32 +1898,24 @@ export type Q2Query = { search: Array< x } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type Unnamed_1_Query = ( - { __typename?: 'Query' } - & { b?: Maybe<( - { __typename?: 'A' } - & Pick - ) | { __typename?: 'B' }> } - ); + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); - export type AFragment = ( - { __typename?: 'A' } - & Pick - ); + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type BFragment = ( - { __typename?: 'A' } - & Pick - ); + + export type Unnamed_1_Query = { b: + | { id: string, x: number } + | Record + | null }; + + export type AFragment = { id: string }; + + export type BFragment = { x: number }; + " `); - validateTs(mergeOutputs([content]), config); - expect(mergeOutputs([content])).toMatchSnapshot(); + validateTs(mergeOutputs([content]), {}); }); it('Should support interfaces correctly when used with inline fragments', async () => { @@ -2048,27 +1938,18 @@ export type Q2Query = { search: Array< } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type NotificationsQuery = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - & { metadata: ( - { __typename?: 'ImageMetadata' } - & Pick - ) } - )> } - ); + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + expect(content).toMatchInlineSnapshot(` + "export type NotificationsQueryVariables = Exact<{ [key: string]: never; }>; + + + export type NotificationsQuery = { notifications: Array< + | { text: string, id: string } + | { imageUrl: string, id: string, metadata: { createdBy: string } } + > }; + " `); - await validate(content, config); + await validate(content); }); it('Should support union correctly when used with inline fragments', async () => { @@ -2085,24 +1966,20 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type UnionTestQuery = ( - { __typename?: 'Query' } - & { unionTest?: Maybe<( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'Profile' } - & Pick - )> } - ); + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + + expect(content).toMatchInlineSnapshot(` + "export type UnionTestQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UnionTestQuery = { unionTest: + | { id: string } + | { age: number | null } + | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should support union correctly when used with inline fragments on types implementing common interface', async () => { @@ -2123,24 +2000,20 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type UnionTestQuery = ( - { __typename?: 'Query' } - & { mixedNotifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - )> } - ); + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + + expect(content).toMatchInlineSnapshot(` + "export type UnionTestQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UnionTestQuery = { mixedNotifications: Array< + | { id: string, text: string } + | { id: string, imageUrl: string } + > }; + " `); - 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 () => { @@ -2165,27 +2038,21 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type UnionTestQuery = ( - { __typename?: 'Query' } - & { search: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - ) | ( - { __typename?: 'User' } - & Pick - )> } - ); + const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + + expect(content).toMatchInlineSnapshot(` + "export type UnionTestQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UnionTestQuery = { search: Array< + | { id: string, text: string } + | { id: string, imageUrl: string } + | { id: string } + > }; + " `); - await validate(content, config); + await validate(content); }); it('Should support merging identical fragment union types', async () => { @@ -2200,28 +2067,24 @@ export type Q2Query = { search: Array< id } `); - const config = { preResolveTypes: true, mergeFragmentTypes: true, namingConvention: 'keep' }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type testQueryVariables = Exact<{ [key: string]: never; }>; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { mergeFragmentTypes: true, namingConvention: 'keep' }, + { outputFile: '' } + ); - export type testQuery = ( - { notifications: Array<( - { id: string } - & { __typename?: 'TextNotification' | 'ImageNotification' } - )> } - & { __typename?: 'Query' } - ); + expect(content).toMatchInlineSnapshot(` + "export type testQueryVariables = Exact<{ [key: string]: never; }>; - export type NFragment = ( - { id: string } - & { __typename?: 'TextNotification' | 'ImageNotification' } - ); - `); - await validate(content, config); + + export type testQuery = { notifications: Array<{ id: string }> }; + + export type NFragment = { id: string }; + " + `); + await validate(content); }); it('Should support computing correct names for merged fragment union types', async () => { @@ -2233,25 +2096,26 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: true, mergeFragmentTypes: true, namingConvention: 'keep' }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - type N_TextNotification_Fragment = ( - { text: string, id: string } - & { __typename?: 'TextNotification' } - ); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { mergeFragmentTypes: true, namingConvention: 'keep' }, + { outputFile: '' } + ); - type N_ImageNotification_Fragment = ( - { id: string } - & { __typename?: 'ImageNotification' } - ); + expect(content).toMatchInlineSnapshot(` + "type N_TextNotification_Fragment = { text: string, id: string }; - export type NFragment = N_TextNotification_Fragment | N_ImageNotification_Fragment; + type N_ImageNotification_Fragment = { id: string }; + + 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 () => { @@ -2294,25 +2158,26 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: true, mergeFragmentTypes: true, namingConvention: 'keep' }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - type N_A_Fragment = ( - { text: string, id: string } - & { __typename?: 'A' } - ); + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + { mergeFragmentTypes: true, namingConvention: 'keep' }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "type N_A_Fragment = { text: string, id: string }; - type N_zhJJUzpMTyh98zugnx0IKwiLetPNjV8KybSlmpAEUU_Fragment = ( - { id: string } - & { __typename?: 'B' | 'C' | 'D' | 'E' } - ); + type N_ZMkK3KeglIQrCEb6gIP8zgzig3OXIb4iuHrFFPW86a4_Fragment = { id: string }; - export type NFragment = N_A_Fragment | N_zhJJUzpMTyh98zugnx0IKwiLetPNjV8KybSlmpAEUU_Fragment; + export type NFragment = + | N_A_Fragment + | N_ZMkK3KeglIQrCEb6gIP8zgzig3OXIb4iuHrFFPW86a4_Fragment + ; + " `); - await validate(content, config); + await validate(content); }); it('Should not create empty types when merging fragment union types', async () => { @@ -2325,21 +2190,19 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: true, mergeFragmentTypes: true, namingConvention: 'keep' }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type NFragment = ( - { notifications: Array<( - { text: string } - & { __typename?: 'TextNotification' } - ) | { __typename?: 'ImageNotification' }> } - & { __typename?: 'Query' } - ); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { mergeFragmentTypes: true, namingConvention: 'keep' }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type NFragment = { notifications: Array<{ text: string }> }; + " `); - await validate(content, config); + await validate(content); }); it('Should support merging identical fragment union types with skipTypename', async () => { @@ -2354,17 +2217,24 @@ export type Q2Query = { search: Array< id } `); - const config = { preResolveTypes: true, skipTypename: true, mergeFragmentTypes: true, namingConvention: 'keep' }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type testQueryVariables = Exact<{ [key: string]: never; }>; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true, mergeFragmentTypes: true, namingConvention: 'keep' }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type testQueryVariables = Exact<{ [key: string]: never; }>; + export type testQuery = { notifications: Array<{ id: string }> }; + + export type NFragment = { id: string }; + " `); - await validate(content, config); + await validate(content); }); it('Should support computing correct names for merged fragment union types with skipTypename', async () => { @@ -2376,19 +2246,26 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: true, skipTypename: true, mergeFragmentTypes: true, namingConvention: 'keep' }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - type N_TextNotification_Fragment = { text: string, id: string }; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true, mergeFragmentTypes: true, namingConvention: 'keep' }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "type N_TextNotification_Fragment = { text: string, id: string }; - type N_ImageNotification_Fragment = { id: string }; + type N_ImageNotification_Fragment = { id: string }; - export type NFragment = N_TextNotification_Fragment | N_ImageNotification_Fragment; + 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 () => { @@ -2403,30 +2280,34 @@ export type Q2Query = { search: Array< id } `); - const config = { preResolveTypes: true, mergeFragmentTypes: true, inlineFragmentTypes: 'mask' } as const; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type TestQueryVariables = Exact<{ [key: string]: never; }>; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { mergeFragmentTypes: true, inlineFragmentTypes: 'mask' }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type TestQueryVariables = Exact<{ [key: string]: never; }>; - export type TestQuery = { __typename?: 'Query', notifications: Array<( - { __typename?: 'TextNotification' } - & { ' $fragmentRefs'?: { 'N_TextNotification_Fragment': N_TextNotification_Fragment } } - ) | ( - { __typename?: 'ImageNotification' } - & { ' $fragmentRefs'?: { 'N_ImageNotification_Fragment': N_ImageNotification_Fragment } } - )> }; + export type TestQuery = { notifications: Array< + | { ' $fragmentRefs'?: { 'N_TextNotification_Fragment': N_TextNotification_Fragment } } + | { ' $fragmentRefs'?: { 'N_ImageNotification_Fragment': N_ImageNotification_Fragment } } + > }; - type N_TextNotification_Fragment = { __typename?: 'TextNotification', id: string } & { ' $fragmentName'?: 'N_TextNotification_Fragment' }; + type N_TextNotification_Fragment = { id: string } & { ' $fragmentName'?: 'N_TextNotification_Fragment' }; - type N_ImageNotification_Fragment = { __typename?: 'ImageNotification', id: string } & { ' $fragmentName'?: 'N_ImageNotification_Fragment' }; + type N_ImageNotification_Fragment = { id: string } & { ' $fragmentName'?: 'N_ImageNotification_Fragment' }; - export type NFragment = N_TextNotification_Fragment | N_ImageNotification_Fragment; - `); - await validate(content, config); + export type NFragment = + | N_TextNotification_Fragment + | N_ImageNotification_Fragment + ; + " + `); + await validate(content); }); it('Should support inline fragments', async () => { @@ -2443,18 +2324,22 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type CurrentUserQuery = { me?: Maybe<( - Pick - & { profile?: Maybe> } - )> }; + + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + expect(content).toMatchInlineSnapshot(` + "export type CurrentUserQueryVariables = Exact<{ [key: string]: never; }>; + + + export type CurrentUserQuery = { me: { username: string, id: string, profile: { age: number | null } | null } | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should build a basic selection set based on basic query on GitHub schema', async () => { @@ -2474,28 +2359,40 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(gitHuntSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo( - `export type MeQueryVariables = Exact<{ - repoFullName: Scalars['String']['input']; - }>;` + const { content } = await plugin( + gitHuntSchema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } ); - expect(content).toBeSimilarStringTo(` - export type MeQuery = { currentUser?: Maybe>, entry?: Maybe<( - Pick - & { postedBy: Pick } - )> }; - `); - await validate(content, config, gitHuntSchema); - }); - it('Should build a basic selection set based on basic query on GitHub schema with preResolveTypes=true', async () => { - const ast = parse(/* GraphQL */ ` - query me($repoFullName: String!) { + expect(content).toMatchInlineSnapshot( + ` + "export type MeQueryVariables = Exact<{ + repoFullName: string; + }>; + + + export type MeQuery = { currentUser: { login: string, html_url: string } | null, entry: { id: number, createdAt: number, postedBy: { login: string, html_url: string } } | null }; + " + ` + ); + expect(content).toMatchInlineSnapshot(` + "export type MeQueryVariables = Exact<{ + repoFullName: string; + }>; + + + export type MeQuery = { currentUser: { login: string, html_url: string } | null, entry: { id: number, createdAt: number, postedBy: { login: string, html_url: string } } | null }; + " + `); + await validate(content); + }); + + it('Should build a basic selection set based on basic query on GitHub schema', async () => { + const ast = parse(/* GraphQL */ ` + query me($repoFullName: String!) { currentUser { login html_url @@ -2510,18 +2407,27 @@ export type Q2Query = { search: Array< } } `); - const config = { preResolveTypes: true }; - const { content } = await plugin(gitHuntSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - 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 }; + const { content } = await plugin( + gitHuntSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type MeQueryVariables = Exact<{ + repoFullName: string; + }>; + + + export type MeQuery = { currentUser: { login: string, html_url: string } | null, entry: { id: number, createdAt: number, postedBy: { 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 () => { + it('Should produce valid output with enums', async () => { const ast = parse(/* GraphQL */ ` query test { info { @@ -2555,17 +2461,31 @@ export type Q2Query = { search: Array< info: Information } `); - const config = { preResolveTypes: true }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - const o = await validate(content, config, testSchema); - expect(o).toContain(`export enum Information_EntryType {`); - expect(o).toContain(`__typename?: 'Information_Entry', id: Information_EntryType,`); + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + {}, + { outputFile: '' } + ); + + const o = await validate(content); + expect(o).toMatchInlineSnapshot(` + "export type Information_EntryType = + | 'NAME' + | 'ADDRESS'; + + export type TestQueryVariables = Exact<{ [key: string]: never; }>; + + + export type TestQuery = { info: { entries: Array<{ id: Information_EntryType, value: string | null }> } | null }; + + export type InformationFragment = { entries: Array<{ id: Information_EntryType, value: string | null }> }; + " + `); }); - it('Should produce valid output with preResolveTypes=true and enums with prefixes set', async () => { + it('Should produce valid output with enums with prefixes set', async () => { const ast = parse(/* GraphQL */ ` query test($e: Information_EntryType!) { info { @@ -2603,21 +2523,33 @@ export type Q2Query = { search: Array< info: Information } `); - const config = { preResolveTypes: true, typesPrefix: 'I', enumPrefix: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - const o = await validate(content, config, testSchema); - 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(`__typename?: 'Information_Entry', id: Information_EntryType,`); + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + { typesPrefix: 'I', enumPrefix: false }, + { outputFile: '' } + ); + + const o = await validate(content); + expect(o).toMatchInlineSnapshot(` + "export type Information_EntryType = + | 'NAME' + | 'ADDRESS'; + + export type ITestQueryVariables = Exact<{ + e: Information_EntryType; + }>; + + + export type ITestQuery = { info: { entries: Array<{ id: Information_EntryType, value: string | null }> } | null, infoArgTest: { entries: Array<{ id: Information_EntryType, value: string | null }> } | null }; + + export type IInformationFragment = { entries: Array<{ id: Information_EntryType, value: string | null }> }; + " + `); }); - it('Should produce valid output with preResolveTypes=true and enums with no suffixes', async () => { + it('Should produce valid output with enums with no suffixes', async () => { const ast = parse(/* GraphQL */ ` query test($e: Information_EntryType!) { info { @@ -2655,18 +2587,30 @@ export type Q2Query = { search: Array< info: Information } `); - const config = { preResolveTypes: true, typesSuffix: 'I', enumSuffix: false }; - const { content } = await plugin(testSchema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - const o = await validate(content, config, testSchema); - 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(`__typename?: 'Information_Entry', id: Information_EntryType,`); + const { content } = await plugin( + testSchema, + [{ location: 'test-file.ts', document: ast }], + { typesSuffix: 'I', enumSuffix: false }, + { outputFile: '' } + ); + + const o = await validate(content); + expect(o).toMatchInlineSnapshot(` + "export type Information_EntryType = + | 'NAME' + | 'ADDRESS'; + + export type TestQueryVariablesI = Exact<{ + e: Information_EntryType; + }>; + + + export type TestQueryI = { info: { entries: Array<{ id: Information_EntryType, value: string | null }> } | null, infoArgTest: { entries: Array<{ id: Information_EntryType, value: string | null }> } | null }; + + export type InformationFragmentI = { entries: Array<{ id: Information_EntryType, value: string | null }> }; + " + `); }); it('Should build a basic selection set based on basic query', async () => { @@ -2675,15 +2619,22 @@ export type Q2Query = { search: Array< dummy } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type DummyQuery = Pick; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type DummyQueryVariables = Exact<{ [key: string]: never; }>; + + + export type DummyQuery = { dummy: string | null }; + " `); - 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 () => { @@ -2695,18 +2646,22 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type DummyQuery = ( - { customName: Query['dummy'] } - & { customName2?: Maybe> } - ); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type DummyQueryVariables = Exact<{ [key: string]: never; }>; + + + export type DummyQuery = { customName: string | null, customName2: { age: number | null } | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should build a basic selection set based on a query with inner fields', async () => { @@ -2722,18 +2677,26 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type CurrentUserQuery = { me?: Maybe<( - Pick - & { profile?: Maybe> } - )> }; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type Role = + | 'USER' + | 'ADMIN'; + + export type CurrentUserQueryVariables = Exact<{ [key: string]: never; }>; + + + export type CurrentUserQuery = { me: { id: string, username: string, role: Role | null, profile: { age: number | null } | null } | null }; + " `); - await validate(content, config); + await validate(content); }); }); @@ -2748,18 +2711,19 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type UserFieldsFragment = ( - Pick - & { profile?: Maybe> } - ); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type UserFieldsFragment = { id: string, username: string, profile: { age: number | null } | null }; + " `); - await validate(content, config); + await validate(content); }); }); @@ -2776,18 +2740,22 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type LoginMutation = { login?: Maybe<( - Pick - & { profile?: Maybe> } - )> }; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type LoginMutationVariables = Exact<{ [key: string]: never; }>; + + + export type LoginMutation = { login: { id: string, username: string, profile: { age: number | null } | null } | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should detect Query correctly', async () => { @@ -2796,15 +2764,22 @@ export type Q2Query = { search: Array< dummy } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type TestQuery = Pick; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: false }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type TestQueryVariables = Exact<{ [key: string]: never; }>; + + + export type TestQuery = { dummy: string | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should detect Subscription correctly', async () => { @@ -2815,15 +2790,22 @@ export type Q2Query = { search: Array< } } `); - const config = { skipTypename: true, preResolveTypes: false }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(` - export type TestSubscription = { userCreated?: Maybe> }; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type TestSubscriptionVariables = Exact<{ [key: string]: never; }>; + + + export type TestSubscription = { userCreated: { id: string } | null }; + " `); - await validate(content, config); + await validate(content); }); it('Should handle operation variables correctly', async () => { @@ -2841,24 +2823,37 @@ export type Q2Query = { search: Array< dummy } `); - const config = { skipTypename: true }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo( - `export type TestQueryQueryVariables = Exact<{ - username?: InputMaybe; - email?: InputMaybe; - password: Scalars['String']['input']; - input?: InputMaybe; + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot( + ` + "type InputType = { + t?: string | null | undefined; + }; + + export type TestQueryQueryVariables = Exact<{ + username?: string | null; + email?: string | null; + password: string; + input?: InputType | null; mandatoryInput: InputType; - testArray?: InputMaybe> | InputMaybe>; - requireString: Array> | InputMaybe; - innerRequired: Array | Scalars['String']['input']; - }>;` + testArray?: Array | string | null; + requireString: Array | string; + innerRequired: Array | string; + }>; + + + export type TestQueryQuery = { dummy: string | null }; + " + ` ); - await validate(content, config, schema); + await validate(content); }); it('Should handle operation variables correctly when they use custom scalars', async () => { @@ -2867,17 +2862,26 @@ export type Q2Query = { search: Array< dummy } `); - const config = { skipTypename: true }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo( - `export type TestQueryQueryVariables = Exact<{ - test?: InputMaybe; - }>;` + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot( + ` + "export type TestQueryQueryVariables = Exact<{ + test?: any | null; + }>; + + + export type TestQueryQuery = { dummy: string | null }; + " + ` ); - await validate(content, config); + await validate(content); }); it('Should create empty variables when there are no operation variables', async () => { @@ -2886,13 +2890,22 @@ export type Q2Query = { search: Array< dummy } `); - const config = { skipTypename: true }; - const { content } = await plugin(schema, [{ location: 'test-file.ts', document: ast }], config, { - outputFile: '', - }); - expect(content).toBeSimilarStringTo(`export type TestQueryQueryVariables = Exact<{ [key: string]: never; }>;`); - await validate(content, config); + const { content } = await plugin( + schema, + [{ location: 'test-file.ts', document: ast }], + { skipTypename: true }, + { outputFile: '' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type TestQueryQueryVariables = Exact<{ [key: string]: never; }>; + + + export type TestQueryQuery = { dummy: string | null }; + " + `); + await validate(content); }); it('avoid duplicates - each type name should be unique', async () => { @@ -2927,23 +2940,21 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type SubmitMessageMutation = ( - { __typename?: 'Mutation' } - & { mutation: ( - { __typename?: 'DeleteMutation' } - & Pick - ) | ( - { __typename?: 'UpdateMutation' } - & Pick - ) } - ); + expect(content).toMatchInlineSnapshot(` + "export type SubmitMessageMutationVariables = Exact<{ + message: string; + }>; + + + export type SubmitMessageMutation = { mutation: + | { deleted: boolean } + | { updated: boolean } + }; + " `); }); @@ -2969,17 +2980,16 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type PostQuery = ( - { __typename?: 'Query' } - & { post: { __typename: 'Post' } } - ); + expect(content).toMatchInlineSnapshot(` + "export type PostQueryVariables = Exact<{ [key: string]: never; }>; + + + export type PostQuery = { post: { __typename: 'Post' } }; + " `); }); @@ -3007,26 +3017,17 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type InfoQuery = ( - { __typename?: 'Query' } - & { __schema: ( - { __typename?: '__Schema' } - & { queryType: ( - { __typename?: '__Type' } - & { fields?: Maybe - )>> } - ) } - ) } - );`); + expect(content).toMatchInlineSnapshot(` + "export type InfoQueryVariables = Exact<{ [key: string]: never; }>; + + + export type InfoQuery = { __schema: { queryType: { fields: Array<{ name: string }> | null } } }; + " + `); }); it('should handle introspection types (__type)', async () => { @@ -3056,100 +3057,19 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type InfoQuery = ( - { __typename?: 'Query' } - & { __type?: Maybe<( - { __typename?: '__Type' } - & Pick<__Type, 'name'> - & { fields?: Maybe - & { type: ( - { __typename?: '__Type' } - & Pick<__Type, 'name' | 'kind'> - ) } - )>> } - )> } - ); + expect(content).toMatchInlineSnapshot(` + "export type InfoQueryVariables = Exact<{ [key: string]: never; }>; + + + export type InfoQuery = { __type: { name: string | null, fields: Array<{ name: string, type: { name: string | null, kind: __TypeKind } }> | null } | null }; + " `); }); - it('should handle introspection types (like __TypeKind)', async () => { - const testSchema = buildSchema(/* GraphQL */ ` - type Post { - title: String - } - type Query { - post: Post! - } - `); - const query = parse(/* GraphQL */ ` - query Info { - __type(name: "Post") { - name - fields { - name - type { - name - kind - } - } - } - } - `); - - const coreContent = await tsPlugin( - testSchema, - [{ location: '', document: query }], - {}, - { - outputFile: 'graphql.ts', - } - ); - - const pluginContent = await plugin( - testSchema, - [{ location: '', document: query }], - {}, - { - outputFile: 'graphql.ts', - } - ); - - const content = mergeOutputs([coreContent, pluginContent]); - - expect(content).toBeSimilarStringTo(` - /** An enum describing what kind of type a given \`__Type\` is. */ - export enum __TypeKind { - /** Indicates this type is a scalar. */ - Scalar = 'SCALAR', - /** Indicates this type is an object. \`fields\` and \`interfaces\` are valid fields. */ - Object = 'OBJECT', - /** Indicates this type is an interface. \`fields\`, \`interfaces\`, and \`possibleTypes\` are valid fields. */ - Interface = 'INTERFACE', - /** Indicates this type is a union. \`possibleTypes\` is a valid field. */ - Union = 'UNION', - /** Indicates this type is an enum. \`enumValues\` is a valid field. */ - Enum = 'ENUM', - /** Indicates this type is an input object. \`inputFields\` is a valid field. */ - InputObject = 'INPUT_OBJECT', - /** Indicates this type is a list. \`ofType\` is a valid field. */ - List = 'LIST', - /** Indicates this type is a non-null. \`ofType\` is a valid field. */ - NonNull = 'NON_NULL' - } - `); - - validateTs(content); - }); - it('Should generate correctly when using enums and typesPrefix', async () => { const testSchema = buildSchema(/* GraphQL */ ` enum Access { @@ -3178,25 +3098,27 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { typesPrefix: 'PREFIX_', preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + { typesPrefix: 'PREFIX_' }, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` + expect(content).toMatchInlineSnapshot(` + "export type PREFIX_Access = + | 'Read' + | 'Write' + | 'All'; + + type PREFIX_Filter = { + match: string; + }; + export type PREFIX_UsersQueryVariables = Exact<{ filter: PREFIX_Filter; }>; - `); - expect(content).toBeSimilarStringTo(` - export type PREFIX_UsersQuery = ( - { __typename?: 'Query' } - & { users?: Maybe - )>>> } - ); + + + export type PREFIX_UsersQuery = { users: Array<{ access: PREFIX_Access | null } | null> | null }; + " `); }); @@ -3221,15 +3143,17 @@ export type Q2Query = { search: Array< testSchema, [{ location: '', document: query }], {}, - { - outputFile: 'graphql.ts', - } + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UsersQueryVariables = Exact<{ - reverse?: InputMaybe; + expect(content).toMatchInlineSnapshot(` + "export type UsersQueryVariables = Exact<{ + reverse?: boolean | null; }>; + + + export type UsersQuery = { users: Array<{ name: string }> }; + " `); }); }); @@ -3282,31 +3206,18 @@ export type Q2Query = { search: Array< } `); - const { content } = await plugin( - schema, - [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } - ); - expect(content).toBeSimilarStringTo(` - export type FieldQuery = ( - { __typename?: 'Query' } - & { field: ( - { __typename: 'Error1' } - & Pick - ) | ( - { __typename: 'Error2' } - & Pick - ) | ( - { __typename: 'ComplexError' } - & Pick - ) | ( - { __typename: 'FieldResultSuccess' } - & Pick - ) } - ); + const { content } = await plugin(schema, [{ location: '', document: query }], {}, { outputFile: 'graphql.ts' }); + expect(content).toMatchInlineSnapshot(` + "export type FieldQueryVariables = Exact<{ [key: string]: never; }>; + + + export type FieldQuery = { field: + | { __typename: 'Error1', message: string } + | { __typename: 'Error2', message: string } + | { __typename: 'ComplexError', message: string, additionalInfo: string } + | { __typename: 'FieldResultSuccess', someValue: boolean } + }; + " `); }); @@ -3357,31 +3268,18 @@ export type Q2Query = { search: Array< } `); - const { content } = await plugin( - schema, - [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } - ); - expect(content).toBeSimilarStringTo(` - export type FieldQuery = ( - { __typename?: 'Query' } - & { field: ( - { __typename: 'Error1' } - & Pick - ) | ( - { __typename: 'Error2' } - & Pick - ) | ( - { __typename: 'ComplexError' } - & Pick - ) | ( - { __typename?: 'FieldResultSuccess' } - & Pick - ) } - ); + const { content } = await plugin(schema, [{ location: '', document: query }], {}, { outputFile: 'graphql.ts' }); + expect(content).toMatchInlineSnapshot(` + "export type FieldQueryVariables = Exact<{ [key: string]: never; }>; + + + export type FieldQuery = { field: + | { __typename: 'Error1', message: string } + | { __typename: 'Error2', message: string } + | { __typename: 'ComplexError', message: string, additionalInfo: string } + | { someValue: boolean } + }; + " `); }); it('interface with same field names', async () => { @@ -3422,23 +3320,19 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type SomethingQuery = ( - { __typename?: 'Query' } - & { node?: Maybe<( - { __typename?: 'A' } - & Pick - ) | ( - { __typename?: 'B' } - & Pick - )> } - ); + expect(content).toMatchInlineSnapshot(` + "export type SomethingQueryVariables = Exact<{ [key: string]: never; }>; + + + export type SomethingQuery = { node: + | { a: string | null } + | { a: boolean | null } + | null }; + " `); }); it('union returning single interface types', async () => { @@ -3492,30 +3386,20 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQuery = ( - { __typename?: 'Query' } - & { user?: Maybe<( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'Error2' } - & Pick - ) | ( - { __typename?: 'Error3' } - & Pick - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } - )> } - ); + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UserQuery = { user: + | { id: string, login: string } + | { message: string } + | { message: string, info: { message: string } | null } + | null }; + " `); }); @@ -3585,30 +3469,20 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQuery = ( - { __typename?: 'Query' } - & { user?: Maybe<( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'Error2' } - & Pick - ) | ( - { __typename?: 'Error3' } - & Pick - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } - )> } - ); + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UserQuery = { user: + | { id: string, login: string } + | { message: string } + | { message: string, info: { message: string, message2: string } | null } + | null }; + " `); }); @@ -3641,22 +3515,18 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - const o = await validate(content, {}, testSchema); + const o = await validate(content); - expect(o).toBeSimilarStringTo(` - export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - ) } - ); + expect(o).toMatchInlineSnapshot(` + "export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UserQueryQuery = { user: { id: string, login: string } }; + " `); }); @@ -3691,27 +3561,21 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - const o = await validate(content, {}, testSchema); - - expect(o).toBeSimilarStringTo(` - export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - ) } - );`); - - expect(o).toBeSimilarStringTo(`export type TestFragment = ( - { __typename?: 'User' } - & Pick - );`); + const o = await validate(content); + + expect(o).toMatchInlineSnapshot(` + "export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UserQueryQuery = { user: { id: string, login: string } }; + + export type TestFragment = { login: string }; + " + `); }); it('Should handle union selection sets with both FragmentSpreads and InlineFragments', async () => { @@ -3790,16 +3654,12 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); const output = await validate( content, - {}, - testSchema, ` function t(q: UserQueryQuery) { if (q.user) { @@ -3819,63 +3679,55 @@ export type Q2Query = { search: Array< } }` ); - expect(mergeOutputs([content])).toMatchSnapshot(); - expect(output).toBeSimilarStringTo(` - export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'Error2' } - & Pick - ) | ( - { __typename?: 'Error3' } - & Pick - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } - ) } - );`); - - expect(output).toBeSimilarStringTo(` - export type AdditionalInfoFragment = ( - { __typename?: 'AdditionalInfo' } - & Pick - ); + expect(output).toMatchInlineSnapshot(` + "export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; - type UserResult1_User_Fragment = ( - { __typename?: 'User' } - & Pick - ); - type UserResult1_Error2_Fragment = { __typename?: 'Error2' }; + export type UserQueryQuery = { user: + | { login: string, id: string } + | { message: string } + | { message: string, info: { message2: string, message: string } | null } + }; + + export type AdditionalInfoFragment = { message: string }; - type UserResult1_Error3_Fragment = ( - { __typename?: 'Error3' } - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } - ); + type UserResult1_User_Fragment = { id: string }; - export type UserResult1Fragment = UserResult1_User_Fragment | UserResult1_Error2_Fragment | UserResult1_Error3_Fragment; + type UserResult1_Error3_Fragment = { info: { message2: string } | null }; - type UserResult_User_Fragment = ( - { __typename?: 'User' } - & Pick - ); + export type UserResult1Fragment = + | UserResult1_User_Fragment + | UserResult1_Error3_Fragment + ; - type UserResult_Error2_Fragment = ( - { __typename?: 'Error2' } - & Pick - ); + type UserResult_User_Fragment = { id: string }; + + type UserResult_Error2_Fragment = { message: string }; - type UserResult_Error3_Fragment = { __typename?: 'Error3' }; + export type UserResultFragment = + | UserResult_User_Fragment + | UserResult_Error2_Fragment + ; - export type UserResultFragment = UserResult_User_Fragment | UserResult_Error2_Fragment | UserResult_Error3_Fragment;`); + function t(q: UserQueryQuery) { + if (q.user) { + if (q.user.__typename === 'User') { + if (q.user.id) { + const u = q.user.login; + } + } + if (q.user.__typename === 'Error2') { + console.log(q.user.message); + } + if (q.user.__typename === 'Error3') { + if (q.user.info) { + console.log(q.user.info.__typename) + } + } + } + }" + `); }); it('Should handle union selection sets with both FragmentSpreads and InlineFragments with flattenGeneratedTypes', async () => { @@ -3951,19 +3803,15 @@ export type Q2Query = { search: Array< } `); - const config = { - flattenGeneratedTypes: true, - preResolveTypes: false, - }; - - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + { flattenGeneratedTypes: true }, + { outputFile: 'graphql.ts' } + ); const output = await validate( content, - config, - testSchema, ` function t(q: UserQueryQuery) { if (q.user) { @@ -3983,26 +3831,34 @@ export type Q2Query = { search: Array< } }` ); - expect(mergeOutputs([output])).toMatchSnapshot(); - - expect(output).toBeSimilarStringTo(` - export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'Error2' } - & Pick - ) | ( - { __typename?: 'Error3' } - & Pick - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } - ) } - ); + + expect(output).toMatchInlineSnapshot(` + "export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UserQueryQuery = { user: + | { id: string, login: string } + | { message: string } + | { message: string, info: { message2: string, message: string } | null } + }; + + function t(q: UserQueryQuery) { + if (q.user) { + if (q.user.__typename === 'User') { + if (q.user.id) { + const u = q.user.login; + } + } + if (q.user.__typename === 'Error2') { + console.log(q.user.message); + } + if (q.user.__typename === 'Error3') { + if (q.user.info) { + console.log(q.user.info.__typename) + } + } + } + }" `); }); @@ -4056,72 +3912,25 @@ export type Q2Query = { search: Array< } `); - const config = { - flattenGeneratedTypes: true, - preResolveTypes: false, - }; - - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); - - const output = await validate(content, config, testSchema); - expect(mergeOutputs([output])).toMatchSnapshot(); - - expect(output).toBeSimilarStringTo(` - export type Maybe = T | null; - export type InputMaybe = Maybe; - export type Exact = { [K in keyof T]: T[K] }; - 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; - }; + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + { flattenGeneratedTypes: true }, + { outputFile: 'graphql.ts' } + ); - export type Dimension = Concept & { - __typename?: 'Dimension'; - id?: Maybe; - }; + const output = await validate(content); - export type DimValue = { - __typename?: 'DimValue'; - dimension?: Maybe; - value: Scalars['String']['output']; - }; + expect(output).toMatchInlineSnapshot(` + "export type SearchPopularQueryVariables = Exact<{ [key: string]: never; }>; - export type Searchable = Dimension | DimValue; - export type SearchPopularQueryVariables = Exact<{ [key: string]: never; }>; - export type SearchPopularQuery = ( - { __typename?: 'Query' } - & { search?: Maybe - ) | ( - { __typename?: 'DimValue' } - & Pick - & { dimension?: Maybe<( - { __typename?: 'Dimension' } - & Pick - )> } - )>> } - );`); + export type SearchPopularQuery = { search: Array< + | { id: string | null } + | { value: string, dimension: { id: string | null } | null } + > | null }; + " + `); }); it('Handles fragments across files with flattenGeneratedTypes', async () => { @@ -4158,57 +3967,30 @@ export type Q2Query = { search: Array< } `); - const config = { - flattenGeneratedTypes: true, - flattenGeneratedTypesIncludeFragments: true, - preResolveTypes: true, - }; - const { content } = await plugin( testSchema, [ { location: '', document: query }, { location: '', document: fragment }, ], - config, { - outputFile: 'graphql.ts', - } + flattenGeneratedTypes: true, + flattenGeneratedTypesIncludeFragments: true, + }, + { outputFile: 'graphql.ts' } ); - const output = await validate(content, config, testSchema); - - expect(output).toBeSimilarStringTo(` - export type Maybe = T | null; - export type InputMaybe = Maybe; - export type Exact = { [K in keyof T]: T[K] }; - 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>; - }; + const output = await validate(content); - export type Dimension = { - __typename?: 'Dimension'; - id?: Maybe; - }; - export type SearchableFragmentFragment = { __typename?: 'Dimension', id?: string | null }; + expect(output).toMatchInlineSnapshot(` + "export type SearchableFragmentFragment = { 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 = { search: Array<{ id: string | null }> | null }; + " + `); }); it('Drops fragments with flattenGeneratedTypes', async () => { @@ -4246,56 +4028,28 @@ export type Q2Query = { search: Array< } `); - const config = { - flattenGeneratedTypes: true, - flattenGeneratedTypesIncludeFragments: false, - preResolveTypes: true, - }; - const { content } = await plugin( testSchema, [ { location: '', document: query }, { location: '', document: fragment }, ], - config, { - outputFile: 'graphql.ts', - } + flattenGeneratedTypes: true, + flattenGeneratedTypesIncludeFragments: false, + }, + { outputFile: 'graphql.ts' } ); - const output = await validate(content, config, testSchema); - - expect(output).toBeSimilarStringTo(` - export type Maybe = T | null; - export type InputMaybe = Maybe; - export type Exact = { [K in keyof T]: T[K] }; - 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>; - }; + const output = await validate(content); - export type Dimension = { - __typename?: 'Dimension'; - id?: Maybe; - }; + expect(output).toMatchInlineSnapshot(` + "export type SearchPopularQueryVariables = Exact<{ [key: string]: never; }>; - export type SearchPopularQueryVariables = Exact<{ [key: string]: never; }>; - export type SearchPopularQuery = { __typename?: 'Query', search?: Array<{ __typename?: 'Dimension', id?: string | null }> | null };`); + export type SearchPopularQuery = { search: Array<{ id: string | null }> | null }; + " + `); }); it('Should add operation name when addOperationExport is true', async () => { @@ -4323,38 +4077,26 @@ export type Q2Query = { search: Array< } `); - const config = { - addOperationExport: true, - preResolveTypes: false, - }; + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + { addOperationExport: true }, + { outputFile: 'graphql.ts' } + ); - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); + expect(content).toMatchInlineSnapshot(` + "export type UserIdQueryQueryVariables = Exact<{ [key: string]: never; }>; - expect(content).toBeSimilarStringTo(` - export type UserIdQueryQueryVariables = Exact<{ [key: string]: never; }>; - export type UserIdQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - ) } - ); + export type UserIdQueryQuery = { user: { id: string } }; - export type UserLoginQueryQueryVariables = Exact<{ [key: string]: never; }>; + export type UserLoginQueryQueryVariables = Exact<{ [key: string]: never; }>; - export type UserLoginQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - ) } - ); - export declare const UserIdQuery: import("graphql").DocumentNode; - export declare const UserLoginQuery: import("graphql").DocumentNode; + export type UserLoginQueryQuery = { user: { login: string } }; + + export declare const UserIdQuery: import("graphql").DocumentNode; + export declare const UserLoginQuery: import("graphql").DocumentNode;" `); }); @@ -4438,19 +4180,15 @@ export type Q2Query = { search: Array< } `); - const config = { - flattenGeneratedTypes: true, - preResolveTypes: false, - }; - - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + { flattenGeneratedTypes: true }, + { outputFile: 'graphql.ts' } + ); const output = await validate( content, - config, - testSchema, ` function t(q: UserQueryQuery) { if (q.user) { @@ -4470,26 +4208,34 @@ export type Q2Query = { search: Array< } }` ); - expect(mergeOutputs([output])).toMatchSnapshot(); - - expect(output).toBeSimilarStringTo(` - export type UserQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'Error2' } - & Pick - ) | ( - { __typename?: 'Error3' } - & Pick - & { info?: Maybe<( - { __typename?: 'AdditionalInfo' } - & Pick - )> } - ) } - ); + + expect(output).toMatchInlineSnapshot(` + "export type UserQueryQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UserQueryQuery = { user: + | { id: string, test2: string | null, login: string, test: string | null } + | { message: string } + | { message: string, info: { message2: string, message: string } | null } + }; + + function t(q: UserQueryQuery) { + if (q.user) { + if (q.user.__typename === 'User') { + if (q.user.id) { + const u = q.user.login; + } + } + if (q.user.__typename === 'Error2') { + console.log(q.user.message); + } + if (q.user.__typename === 'Error3') { + if (q.user.info) { + console.log(q.user.info.__typename) + } + } + } + }" `); }); }); @@ -4540,15 +4286,11 @@ export type Q2Query = { search: Array< testSchema, [{ location: '', document: query }], {}, - { - outputFile: 'graphql.ts', - } + { outputFile: 'graphql.ts' } ); await validate( content, - {}, - testSchema, ` function test (t: TestQuery) { for (const item of t.obj!.items) { @@ -4581,14 +4323,17 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).not.toContain(`Maybe<>`); - expect(content).toContain(`Maybe`); + expect(content).toMatchInlineSnapshot(` + "export type TestQueryVariables = Exact<{ [key: string]: never; }>; + + + export type TestQuery = { test: never | null }; + " + `); }); it('#4389 - validate issues with interfaces', async () => { @@ -4626,12 +4371,16 @@ export type Q2Query = { search: Array< const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toContain(`{ foo?: Maybe<{ __typename?: 'C' }> }`); + expect(content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { foo: Record | null }; + " + `); }); it('#5001 - incorrect output with typeSuffix', async () => { @@ -4657,13 +4406,12 @@ export type Q2Query = { search: Array< } `); - const config = { - typesSuffix: 'Type', - }; - - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + { typesSuffix: 'Type' }, + { outputFile: 'graphql.ts' } + ); expect(content).not.toContain('UserTypeQueryVariablesType'); expect(content).not.toContain('UserTypeQueryType'); @@ -4726,18 +4474,15 @@ export type Q2Query = { search: Array< } `); - const config = {}; - - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); - - expect(content).toMatchSnapshot(); + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + {}, + { outputFile: 'graphql.ts' } + ); const result = await validate( content, - {}, - testSchema, `function test(q: QQuery) { if (q.hotel) { const t1 = q.hotel.gpsPosition.lat @@ -4751,7 +4496,7 @@ export type Q2Query = { search: Array< expect(mergeOutputs([result])).toMatchSnapshot(); }); - it('#2916 - Missing import prefix with preResolveTypes: true and near-operation-file preset', async () => { + it('#2916 - Missing import prefix with near-operation-file preset', async () => { const testSchema = buildSchema(/* GraphQL */ ` type Query { user(id: ID!): User! @@ -4781,15 +4526,15 @@ export type Q2Query = { search: Array< } `); - const config = { - skipTypename: true, - preResolveTypes: true, - namespacedImportName: 'Types', - }; - - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + { + skipTypename: true, + namespacedImportName: 'Types', + }, + { outputFile: 'graphql.ts' } + ); expect(content).toContain(`dep: Types.Department`); expect(content).toMatchSnapshot(); @@ -4917,17 +4662,13 @@ export type Q2Query = { search: Array< testSchema, [{ location: '', document: query }], {}, - { - outputFile: 'graphql.ts', - } + { outputFile: 'graphql.ts' } ); expect(mergeOutputs([content])).toMatchSnapshot(); 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 @@ -4984,35 +4725,28 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( testSchema, [{ location: '', document: query }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type TestQueryQuery = ( - { __typename?: 'Query' } - & { fooBar: Array<( - { __typename?: 'Foo' } - & Pick - ) | ( - { __typename?: 'Bar' } - & Pick - )> } - ); + expect(content).toMatchInlineSnapshot(` + "export type TestQueryQueryVariables = Exact<{ [key: string]: never; }>; - type FooBarFragment_Foo_Fragment = ( - { __typename?: 'Foo' } - & Pick - ); - type FooBarFragment_Bar_Fragment = ( - { __typename?: 'Bar' } - & Pick - ); + export type TestQueryQuery = { fooBar: Array< + | { id: string } + | { id: string } + > }; + + type FooBarFragment_Foo_Fragment = { id: string }; + + type FooBarFragment_Bar_Fragment = { id: string }; - export type FooBarFragmentFragment = FooBarFragment_Foo_Fragment | FooBarFragment_Bar_Fragment; + export type FooBarFragmentFragment = + | FooBarFragment_Foo_Fragment + | FooBarFragment_Bar_Fragment + ; + " `); }); @@ -5059,26 +4793,15 @@ function test(q: GetEntityBrandDataQuery): void { { location: '', document: productFragmentDocument }, { location: '', document: priceFragmentDocument }, ], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type ProductFragmentFragment = ( - { __typename?: 'Product' } - & Pick - ); + expect(content).toMatchInlineSnapshot(` + "export type ProductFragmentFragment = { id: string, title: string }; - export type PriceFragmentFragment = ( - { __typename?: 'Price' } - & Pick - & { item: Array - )>> } - ); + export type PriceFragmentFragment = { id: string, item: Array<{ id: string, title: string } | null> }; + " `); }); @@ -5106,20 +4829,19 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQuery = ( - { __typename?: 'Query' } - & { user?: Maybe<( - { __typename?: 'User' } - & Pick - )> } - );`); + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ + withUser?: boolean; + }>; + + + export type UserQuery = { user?: { name: string | null } | null }; + " + `); }); it('#2436 - interface with field of same name but different type is correctly handled', async () => { @@ -5173,31 +4895,16 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type DashboardVersionFragmentFragment = ( - { __typename?: 'DashboardVersion' } - & { tiles: ( - { __typename?: 'DashboardTileFilterDetails' } - & Pick - & { md: ( - { __typename?: 'TileFilterMetadata' } - & Pick - ) } - ) | ( - { __typename?: 'DashboardTileParameterDetails' } - & Pick - & { md: ( - { __typename?: 'TileParameterMetadata' } - & Pick - ) } - ) } - ); + expect(content).toMatchInlineSnapshot(` + "export type DashboardVersionFragmentFragment = { tiles: + | { tileId: string, md: { viz: string, columnInfo: string } } + | { tileId: string, md: { viz: string, columnInfo: string } } + }; + " `); }); @@ -5251,31 +4958,16 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type DashboardVersionFragmentFragment = ( - { __typename?: 'DashboardVersion' } - & { tiles: ( - { __typename?: 'DashboardTileFilterDetails' } - & Pick - & { md: ( - { __typename?: 'TileFilterMetadata' } - & Pick - ) } - ) | ( - { __typename?: 'DashboardTileParameterDetails' } - & Pick - & { md: ( - { __typename?: 'TileParameterMetadata' } - & Pick - ) } - ) } - ); + expect(content).toMatchInlineSnapshot(` + "export type DashboardVersionFragmentFragment = { tiles: + | { tileId: string, md: { viz: string, columnInfo: string } } + | { tileId: string, md: { viz: string, columnInfo: string } } + }; + " `); }); @@ -5322,28 +5014,18 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: query }], - { - skipTypename: true, - }, - { - outputFile: 'graphql.ts', - } + { skipTypename: true }, + { outputFile: 'graphql.ts' } ); expect(content).toMatchInlineSnapshot(` - "type CatFragment_Duck_Fragment = Record; - - type CatFragment_Lion_Fragment = { id: string }; + "type CatFragment_Lion_Fragment = { id: string }; type CatFragment_Puma_Fragment = { id: string }; - type CatFragment_Wolf_Fragment = Record; - export type CatFragmentFragment = - | CatFragment_Duck_Fragment | CatFragment_Lion_Fragment | CatFragment_Puma_Fragment - | CatFragment_Wolf_Fragment ; export type KittyQueryVariables = Exact<{ [key: string]: never; }>; @@ -5401,38 +5083,27 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: query }], - { - skipTypename: false, - }, - { - outputFile: 'graphql.ts', - } + { skipTypename: false }, + { outputFile: 'graphql.ts' } ); expect(content).toMatchInlineSnapshot(` - "type CatFragment_Duck_Fragment = { __typename?: 'Duck' }; - - type CatFragment_Lion_Fragment = { __typename?: 'Lion', id: string }; + "type CatFragment_Lion_Fragment = { id: string }; - type CatFragment_Puma_Fragment = { __typename?: 'Puma', id: string }; - - type CatFragment_Wolf_Fragment = { __typename?: 'Wolf' }; + type CatFragment_Puma_Fragment = { id: string }; export type CatFragmentFragment = - | CatFragment_Duck_Fragment | CatFragment_Lion_Fragment | CatFragment_Puma_Fragment - | CatFragment_Wolf_Fragment ; export type KittyQueryVariables = Exact<{ [key: string]: never; }>; - export type KittyQuery = { __typename?: 'Query', animals: Array< - | { __typename?: 'Duck' } - | { __typename?: 'Lion', id: string } - | { __typename?: 'Puma', id: string } - | { __typename?: 'Wolf' } + export type KittyQuery = { animals: Array< + | { id: string } + | { id: string } + | Record > }; " `); @@ -5470,17 +5141,19 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: query }], - { - skipTypename: true, - preResolveTypes: false, - }, - { - outputFile: 'graphql.ts', - } + { skipTypename: true }, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQuery = { user: Pick | Record }; + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ [key: string]: never; }>; + + + export type UserQuery = { user: + | { id: string, login: string | null } + | Record + }; + " `); }); @@ -5502,18 +5175,21 @@ function test(q: GetEntityBrandDataQuery): void { } } `); - const config = { preResolveTypes: true }; - const { content } = await plugin(schema, [{ location: '', document: ast }], config, { - outputFile: 'graphql.ts', - }); - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ - testArray?: InputMaybe> | InputMaybe>; - requireString: Array> | InputMaybe; - innerRequired: Array | Scalars['String']['input']; - }>;`); - await validate(content, config); + const { content } = await plugin(schema, [{ location: '', document: ast }], {}, { outputFile: 'graphql.ts' }); + + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ + testArray?: Array | string | null; + requireString: Array | string; + innerRequired: Array | string; + }>; + + + export type UserQuery = { search: Array<{ id: string }> | null }; + " + `); + await validate(content); }); it('#5352 - Prevent array input coercion if arrayInputCoercion = false', async () => { @@ -5534,18 +5210,26 @@ function test(q: GetEntityBrandDataQuery): void { } } `); - const config = { preResolveTypes: true, arrayInputCoercion: false }; - const { content } = await plugin(schema, [{ location: '', document: ast }], config, { - outputFile: 'graphql.ts', - }); - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ - testArray?: InputMaybe>>; - requireString: Array>; - innerRequired: Array; - }>;`); - await validate(content, config); + const { content } = await plugin( + schema, + [{ location: '', document: ast }], + { arrayInputCoercion: false }, + { outputFile: 'graphql.ts' } + ); + + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ + testArray?: Array | null; + requireString: Array; + innerRequired: Array; + }>; + + + export type UserQuery = { search: Array<{ id: string }> | null }; + " + `); + await validate(content); }); it('#5263 - inline fragment spread on interface field results in incorrect types', async () => { @@ -5585,26 +5269,17 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const { content } = await plugin( - schema, - [{ location: '', document }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } - ); + const { content } = await plugin(schema, [{ location: '', document }], {}, { outputFile: 'graphql.ts' }); - expect(content).toBeSimilarStringTo(` - export type EntityQuery = ( - { __typename?: 'Query' } - & { entity: ( - { __typename?: 'Session' } - & Pick - ) | ( - { __typename?: 'User' } - & Pick - ) } - ); + expect(content).toMatchInlineSnapshot(` + "export type EntityQueryVariables = Exact<{ [key: string]: never; }>; + + + export type EntityQuery = { entity: + | { id: string } + | { name: string, id: string } + }; + " `); }); @@ -5639,28 +5314,14 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const { content } = await plugin( - schema, - [{ location: '', document }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } - ); + const { content } = await plugin(schema, [{ location: '', document }], {}, { outputFile: 'graphql.ts' }); + + expect(content).toMatchInlineSnapshot(` + "export type InlineFragmentQueryQueryVariables = Exact<{ [key: string]: never; }>; - expect(content).toBeSimilarStringTo(` - export type InlineFragmentQueryQueryVariables = Exact<{ [key: string]: never; }>; - - export type InlineFragmentQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & { friends: Array<( - { __typename?: 'User' } - & Pick - )> } - ) } - ); + + export type InlineFragmentQueryQuery = { user: { friends: Array<{ id: string, name: string }> } }; + " `); }); it('SpreadFragmentQuery', async () => { @@ -5687,51 +5348,18 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const { content } = await plugin( - schema, - [{ location: '', document }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } - ); + const { content } = await plugin(schema, [{ location: '', document }], {}, { outputFile: 'graphql.ts' }); - expect(content).toBeSimilarStringTo(` - export type UserFriendsIdFragmentFragment = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & { friends: Array<( - { __typename?: 'User' } - & Pick - )> } - ) } - ); - - export type UserFriendsNameFragmentFragment = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & { friends: Array<( - { __typename?: 'User' } - & Pick - )> } - ) } - ); + expect(content).toMatchInlineSnapshot(` + "export type UserFriendsIdFragmentFragment = { user: { friends: Array<{ id: string }> } }; + + export type UserFriendsNameFragmentFragment = { user: { friends: Array<{ name: string }> } }; export type SpreadFragmentQueryQueryVariables = Exact<{ [key: string]: never; }>; - export type SpreadFragmentQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & { friends: Array<( - { __typename?: 'User' } - & Pick - )> } - ) } - ); + export type SpreadFragmentQueryQuery = { user: { friends: Array<{ id: string, name: string }> } }; + " `); }); it('SpreadFragmentWithSelectionQuery', async () => { @@ -5755,40 +5383,16 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const { content } = await plugin( - schema, - [{ location: '', document }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } - ); + const { content } = await plugin(schema, [{ location: '', document }], {}, { outputFile: 'graphql.ts' }); - expect(content).toBeSimilarStringTo(` - export type UserFriendsNameFragmentFragment = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & { friends: Array<( - { __typename?: 'User' } - & Pick - )> } - ) } - ); + expect(content).toMatchInlineSnapshot(` + "export type UserFriendsNameFragmentFragment = { user: { friends: Array<{ name: string }> } }; export type SpreadFragmentWithSelectionQueryQueryVariables = Exact<{ [key: string]: never; }>; - export type SpreadFragmentWithSelectionQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - & { friends: Array<( - { __typename?: 'User' } - & Pick - )> } - ) } - ); + + export type SpreadFragmentWithSelectionQueryQuery = { user: { id: string, friends: Array<{ id: string, name: string }> } }; + " `); }); it('SpreadFragmentWithSelectionQuery - flatten', async () => { @@ -5812,40 +5416,16 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const { content } = await plugin( - schema, - [{ location: '', document }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } - ); + const { content } = await plugin(schema, [{ location: '', document }], {}, { outputFile: 'graphql.ts' }); - expect(content).toBeSimilarStringTo(` - export type UserFriendsNameFragmentFragment = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & { friends: Array<( - { __typename?: 'User' } - & Pick - )> } - ) } - ); + expect(content).toMatchInlineSnapshot(` + "export type UserFriendsNameFragmentFragment = { user: { friends: Array<{ name: string }> } }; export type SpreadFragmentWithSelectionQueryQueryVariables = Exact<{ [key: string]: never; }>; - export type SpreadFragmentWithSelectionQueryQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - & { friends: Array<( - { __typename?: 'User' } - & Pick - )> } - ) } - ); + + export type SpreadFragmentWithSelectionQueryQuery = { user: { id: string, friends: Array<{ id: string, name: string }> } }; + " `); }); }); @@ -5910,26 +5490,17 @@ function test(q: GetEntityBrandDataQuery): void { "export type GetPeopleQueryVariables = Exact<{ [key: string]: never; }>; - export type GetPeopleQuery = { __typename?: 'Query', people: - | ( - { __typename?: 'Character' } - & { ' $fragmentRefs'?: { 'PeopleInfo_Character_Fragment': PeopleInfo_Character_Fragment } } - ) - | ( - { __typename?: 'Jedi' } - & { ' $fragmentRefs'?: { 'PeopleInfo_Jedi_Fragment': PeopleInfo_Jedi_Fragment } } - ) - | ( - { __typename?: 'Droid' } - & { ' $fragmentRefs'?: { 'PeopleInfo_Droid_Fragment': PeopleInfo_Droid_Fragment } } - ) + export type GetPeopleQuery = { people: + | { ' $fragmentRefs'?: { 'PeopleInfo_Character_Fragment': PeopleInfo_Character_Fragment } } + | { ' $fragmentRefs'?: { 'PeopleInfo_Jedi_Fragment': PeopleInfo_Jedi_Fragment } } + | { ' $fragmentRefs'?: { 'PeopleInfo_Droid_Fragment': PeopleInfo_Droid_Fragment } } }; - type PeopleInfo_Character_Fragment = { __typename?: 'Character', name?: string | null } & { ' $fragmentName'?: 'PeopleInfo_Character_Fragment' }; + type PeopleInfo_Character_Fragment = { name: string | null } & { ' $fragmentName'?: 'PeopleInfo_Character_Fragment' }; - type PeopleInfo_Jedi_Fragment = { __typename?: 'Jedi', side?: string | null } & { ' $fragmentName'?: 'PeopleInfo_Jedi_Fragment' }; + type PeopleInfo_Jedi_Fragment = { side: string | null } & { ' $fragmentName'?: 'PeopleInfo_Jedi_Fragment' }; - type PeopleInfo_Droid_Fragment = { __typename?: 'Droid', model?: string | null } & { ' $fragmentName'?: 'PeopleInfo_Droid_Fragment' }; + type PeopleInfo_Droid_Fragment = { model: string | null } & { ' $fragmentName'?: 'PeopleInfo_Droid_Fragment' }; export type PeopleInfoFragment = | PeopleInfo_Character_Fragment @@ -5940,7 +5511,7 @@ function test(q: GetEntityBrandDataQuery): void { `); }); - it('#6874 - generates types when parent type differs from spread fragment member types and preResolveTypes=true', async () => { + it('#6874 - generates types when parent type differs from spread fragment member types', async () => { const testSchema = buildSchema(/* GraphQL */ ` interface Animal { name: String! @@ -5995,11 +5566,12 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const config = { preResolveTypes: true }; - - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + {}, + { outputFile: 'graphql.ts' } + ); expect(content).toMatchSnapshot(); }); @@ -6043,13 +5615,23 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const config = { preResolveTypes: true }; + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + {}, + { outputFile: 'graphql.ts' } + ); - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); + expect(content).toMatchInlineSnapshot(` + "export type SnakeQueryQueryVariables = Exact<{ [key: string]: never; }>; - expect(content).toMatchSnapshot(); + + export type SnakeQueryQuery = { __typename: 'Query', snake: + | { __typename: 'Snake' } + | { __typename: 'Error' } + }; + " + `); }); it('#8461 - conditional directives are ignored on fields with alias', async () => { @@ -6081,30 +5663,22 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const config = { preResolveTypes: true }; - - const { content } = await plugin(testSchema, [{ location: '', document: query }], config, { - outputFile: 'graphql.ts', - }); + const { content } = await plugin( + testSchema, + [{ location: '', document: query }], + {}, + { outputFile: 'graphql.ts' } + ); - expect(content).toBeSimilarStringTo(` - export type UserQueryQueryVariables = Exact<{ - skipFirstName: Scalars['Boolean']['input']; - skipAddress: Scalars['Boolean']['input']; + expect(content).toMatchInlineSnapshot(` + "export type UserQueryQueryVariables = Exact<{ + skipFirstName: boolean; + skipAddress: boolean; }>; - export type UserQueryQuery = { - __typename?: 'Query', - viewer: { - __typename?: 'User', - lastName: number, - givenName?: string, - mailingAddress?: { - __typename?: 'Address', - postalCode: string - } - } - }; + + export type UserQueryQuery = { viewer: { lastName: number, givenName?: string, mailingAddress?: { postalCode: string } } }; + " `); }); }); @@ -6138,20 +5712,19 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { - preResolveTypes: true, - }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ - showAddress: Scalars['Boolean']['input']; - }>; + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ + showAddress: boolean; + }>; + - export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', name: string, address?: string, nicknames?: Array | null, parents?: Array } };`); + export type UserQuery = { user: { name: string, address?: string, nicknames?: Array | null, parents?: Array } }; + " + `); }); it('objects with @skip, @include should pre resolve into optional', async () => { @@ -6191,169 +5764,28 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { - preResolveTypes: true, - }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ - showAddress: Scalars['Boolean']['input']; - showName: Scalars['Boolean']['input']; - }>; - export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', id: string, name?: string, address?: { __typename?: 'Address', city: string }, friends?: Array<{ __typename?: 'User', id: string }> } };`); + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ + showAddress: boolean; + showName: boolean; + }>; + + + export type UserQuery = { user: { id: string, name?: string, address?: { city: string }, friends?: Array<{ id: string }> } }; + " + `); }); - it('fields with @skip, @include should make container resolve into MakeOptional type', async () => { + it('optionals (?) on types should be avoided by default', async () => { const schema = buildSchema(/* GraphQL */ ` type Query { - user: User! + me: User! } - type User { - id: String! - name: String! - address: Address! - friends: [User!]! - } - type Address { - city: String! - } - `); - - const fragment = parse(/* GraphQL */ ` - query user($showAddress: Boolean!, $showName: Boolean!) { - user { - id - name @include(if: $showName) - address @include(if: $showAddress) { - city - } - friends @include(if: $isFriendly) { - id - } - } - } - `); - - const { content } = await plugin( - schema, - [{ location: '', document: fragment }], - { preResolveTypes: false }, - { - outputFile: 'graphql.ts', - } - ); - - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ - showAddress: Scalars['Boolean']['input']; - showName: Scalars['Boolean']['input']; - }>; - - export type UserQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & MakeOptional, 'name'> - & { address?: ( - { __typename?: 'Address' } - & Pick - ), friends?: Array<( - { __typename?: 'User' } - & Pick - )> } - ) } - );`); - }); - - 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 () => { - const schema = buildSchema(/* GraphQL */ ` - type Query { - user(id: ID!): User! - } - - type User { - id: ID! - username: String! - email: String - } - `); - const operations = parse(/* GraphQL */ ` - query user { - user(id: 1) { - id - username - email - } - } - `); - const config = { avoidOptionals: true, preResolveTypes: true }; - const { content } = await plugin(schema, [{ location: '', document: operations }], config, { - outputFile: 'graphql.ts', - }); - - expect(content).toBeSimilarStringTo( - `export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', id: string, username: string, email: string | null } }` - ); - }); - - it('On avoidOptionals:true, optionals (?) on types should be avoided', async () => { - const schema = buildSchema(/* GraphQL */ ` - type Query { - me: User! - } - + type User { messages: [Message!]! } @@ -6376,31 +5808,22 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { - avoidOptionals: true, - nonOptionalTypename: true, - preResolveTypes: false, - }, - { - outputFile: 'graphql.ts', - } + { nonOptionalTypename: true }, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type MyQueryQuery = ( - { __typename: 'Query' } - & { me: ( - { __typename: 'User' } - & { messages?: Array<( - { __typename: 'Message' } - & Pick - )> } - ) } - ); + expect(content).toMatchInlineSnapshot(` + "export type MyQueryQueryVariables = Exact<{ + include: boolean; + }>; + + + export type MyQueryQuery = { __typename: 'Query', me: { __typename: 'User', messages?: Array<{ __typename: 'Message', content: string }> } }; + " `); }); - it('inline fragment with conditional directives and avoidOptionals', async () => { + it('inline fragment with conditional directives', async () => { const schema = buildSchema(/* GraphQL */ ` type Query { user: User @@ -6432,27 +5855,22 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { preResolveTypes: true, avoidOptionals: true }, - { - outputFile: 'graphql.ts', - } + {}, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQuery = { - __typename?: 'Query', - user?: { - __typename?: 'User', - name: string | null - } | null, - group?: { - __typename?: 'Group', - id: number - } - };`); + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ + withUser?: boolean; + }>; + + + export type UserQuery = { user?: { name: string | null } | null, group?: { id: number } }; + " + `); }); - 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! @@ -6482,75 +5900,24 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { - preResolveTypes: true, - maybeValue: "T | 'specialType'", - avoidOptionals: true, - }, - { - outputFile: 'graphql.ts', - } + { maybeValue: "T | 'specialType'" }, + { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQuery = { __typename?: 'Query', user: { __typename?: 'User', name: string, age: number | 'specialType', address?: string, nicknames?: Array | 'specialType', parents?: Array } }; - `); - }); - - it('inline fragment with conditional directives and avoidOptionals, without preResolveTypes', async () => { - const schema = buildSchema(/* GraphQL */ ` - type Query { - user: User - group: Group! - } + expect(content).toMatchInlineSnapshot(` + "export type UserQueryVariables = Exact<{ + showProperty: boolean; + }>; - type User { - name: String - } - type Group { - id: Int! - } - `); - - const fragment = parse(/* GraphQL */ ` - query user($withUser: Boolean! = false) { - ... @include(if: $withUser) { - user { - name - } - group { - id - } - } - } + export type UserQuery = { user: { name: string, age: number | 'specialType', address?: string, nicknames?: Array | 'specialType', parents?: Array } }; + " `); - - const { content } = await plugin( - schema, - [{ location: '', document: fragment }], - { preResolveTypes: false, avoidOptionals: true }, - { - outputFile: 'graphql.ts', - } - ); - - expect(content).toBeSimilarStringTo(` - export type UserQuery = ( - { __typename?: 'Query' } - & { user?: Maybe<( - { __typename?: 'User' } - & Pick - )>, group?: ( - { __typename?: 'Group' } - & Pick - ) } - );`); }); }); describe('incremental delivery directive handling', () => { - it('should generate an union of initial and deferred fields for fragments (preResolveTypes: true)', async () => { - const schema = buildSchema(` + it('should generate an union of initial and deferred fields for fragments', async () => { + const schema = buildSchema(/* GraphQL */ ` type Address { street1: String! } @@ -6581,7 +5948,7 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const fragment = parse(` + const fragment = parse(/* GraphQL */ ` fragment WidgetFragment on User { widgetCount widgetPreference @@ -6634,175 +6001,29 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { preResolveTypes: true }, + {}, { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ [key: string]: never; }>; - export type UserQuery = { - __typename?: 'Query', - user: { - __typename?: 'User', - clearanceLevel: string, - name: string, - phone: { - __typename?: 'Phone', - home: string - }, - employment: { - __typename?: 'Employment', - title: string - } - } & ({ __typename?: 'User', email: string } - | { __typename?: 'User', email?: never }) - & ({ __typename?: 'User', address: { __typename?: 'Address', street1: string } } - | { __typename?: 'User', address?: never }) - & ({ __typename?: 'User', widgetCount: number, widgetPreference: string } - | { __typename?: 'User', widgetCount?: never, widgetPreference?: never }) - & ({ __typename?: 'User', favoriteFood: string, leastFavoriteFood: string } - | { __typename?: 'User', favoriteFood?: never, leastFavoriteFood?: never }) }; - `); - }); - - it('should generate an union of initial and deferred fields for fragments using MakeEmpty (preResolveTypes: false)', async () => { - const schema = buildSchema(` - type Address { - street1: String! - } - - type Phone { - home: String! - } - - type Employment { - title: String! - } - - type User { - name: String! - email: String! - address: Address! - phone: Phone! - employment: Employment! - widgetCount: Int! - clearanceLevel: String! - } - - type Query { - user: User! - } - `); - - const fragment = parse(` - fragment WidgetFragment on User { - widgetCount - } - - fragment EmploymentFragment on User { - employment { - title - } - } - - query user { - user { - # Test inline fragment defer - ... @defer { - email - } - - # Test inline fragment defer with nested selection set - ... @defer { - address { - street1 - } - } - - # Test named fragment defer - ...WidgetFragment @defer - - # Not deferred fields, fragments, selection sets, etc are left alone - name - phone { - home - } - ...EmploymentFragment - ... { - clearanceLevel - } - } - } - `); - - const { content } = await plugin( - schema, - [{ location: '', document: fragment }], - { preResolveTypes: false }, - { outputFile: 'graphql.ts' } - ); + expect(content).toMatchInlineSnapshot(` + "export type WidgetFragmentFragment = { widgetCount: number, widgetPreference: string }; - expect(content).toBeSimilarStringTo(` - export type WidgetFragmentFragment = ( - { __typename?: 'User' } - & Pick - ); + export type FoodFragmentFragment = { favoriteFood: string, leastFavoriteFood: string }; - export type EmploymentFragmentFragment = ( - { __typename?: 'User' } - & { employment: ( - { __typename?: 'Employment' } - & Pick - ) } - ); + export type EmploymentFragmentFragment = { employment: { title: string } }; export type UserQueryVariables = Exact<{ [key: string]: never; }>; - export type UserQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - & { phone: ( - { __typename?: 'Phone' } - & Pick - ), employment: ( - { __typename?: 'Employment' } - & Pick - ) } - ) & (( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'User' } - & MakeEmpty - )) & (( - { __typename?: 'User' } - & { address: ( - { __typename?: 'Address' } - & Pick - ) } - ) | ( - { __typename?: 'User' } - & { address?: ( - { __typename?: 'Address' } - & Pick - ) } - )) & (( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'User' } - & MakeEmpty - )) } - ); + + export type UserQuery = { user: { clearanceLevel: string, name: string, phone: { home: string }, employment: { title: string } } & ({ email: string } | { email?: never }) & ({ address: { street1: string } } | { address?: never }) & ({ widgetCount: number, widgetPreference: string } | { widgetCount?: never, widgetPreference?: never }) & ({ favoriteFood: string, leastFavoriteFood: string } | { favoriteFood?: never, leastFavoriteFood?: never }) }; + " `); }); - it('should generate an union of initial and deferred fields for fragments MakeEmpty (avoidOptionals: true)', async () => { - const schema = buildSchema(` + it('should resolve optionals according to maybeValue together with deferred fragments', async () => { + const schema = buildSchema(/* GraphQL */ ` type Address { - street1: String! + street1: String } type Phone { @@ -6829,7 +6050,7 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const fragment = parse(` + const fragment = parse(/* GraphQL */ ` fragment WidgetFragment on User { widgetName widgetCount @@ -6874,72 +6095,25 @@ function test(q: GetEntityBrandDataQuery): void { const { content } = await plugin( schema, [{ location: '', document: fragment }], - { - avoidOptionals: true, - preResolveTypes: false, - }, + { maybeValue: "T | 'specialType'" }, { outputFile: 'graphql.ts' } ); - expect(content).toBeSimilarStringTo(` - export type WidgetFragmentFragment = ( - { __typename?: 'User' } - & Pick - ); + expect(content).toMatchInlineSnapshot(` + "export type WidgetFragmentFragment = { widgetName: string, widgetCount: number }; - export type EmploymentFragmentFragment = ( - { __typename?: 'User' } - & { employment: ( - { __typename?: 'Employment' } - & Pick - ) } - ); + export type EmploymentFragmentFragment = { employment: { title: string } }; export type UserQueryVariables = Exact<{ [key: string]: never; }>; - export type UserQuery = ( - { __typename?: 'Query' } - & { user: ( - { __typename?: 'User' } - & Pick - & { phone: ( - { __typename?: 'Phone' } - & Pick - ), employment: ( - { __typename?: 'Employment' } - & Pick - ) } - ) & (( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'User' } - & MakeEmpty - )) & (( - { __typename?: 'User' } - & { address: ( - { __typename?: 'Address' } - & Pick - ) } - ) | ( - { __typename?: 'User' } - & { address?: ( - { __typename?: 'Address' } - & Pick - ) } - )) & (( - { __typename?: 'User' } - & Pick - ) | ( - { __typename?: 'User' } - & MakeEmpty - )) } - ); + + export type UserQuery = { user: { clearanceLevel: string, name: string, phone: { home: string }, employment: { title: string } } & ({ email: string } | { email?: never }) & ({ address: { street1: string | 'specialType' } } | { address?: never }) & ({ widgetName: string, widgetCount: number } | { widgetName?: never, widgetCount?: never }) }; + " `); }); - it('should support "preResolveTypes: true" and "avoidOptionals: true" together', async () => { - const schema = buildSchema(` + it('should generate correct types with inlineFragmentTypes: "mask""', async () => { + const schema = buildSchema(/* GraphQL */ ` type Address { street1: String! } @@ -6959,7 +6133,10 @@ function test(q: GetEntityBrandDataQuery): void { phone: Phone! employment: Employment! widgetCount: Int! + widgetPreference: String! clearanceLevel: String! + favoriteFood: String! + leastFavoriteFood: String! } type Query { @@ -6967,111 +6144,15 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const fragment = parse(` + const fragment = parse(/* GraphQL */ ` fragment WidgetFragment on User { widgetCount + widgetPreference } - fragment EmploymentFragment on User { - employment { - title - } - } - - query user { - user { - # Test inline fragment defer - ... @defer { - email - } - - # Test inline fragment defer with nested selection set - ... @defer { - address { - street1 - } - } - - # Test named fragment defer - ...WidgetFragment @defer - - # Not deferred fields, fragments, selection sets, etc are left alone - name - phone { - home - } - ...EmploymentFragment - ... { - clearanceLevel - } - } - } - `); - - const { content } = await plugin( - schema, - [{ location: '', document: fragment }], - { - avoidOptionals: true, - preResolveTypes: true, - }, - { outputFile: 'graphql.ts' } - ); - - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ [key: string]: never; }>; - export type UserQuery = { - __typename?: 'Query', - user: { - __typename?: 'User', - clearanceLevel: string, - name: string, - phone: { __typename?: 'Phone', home: string }, - employment: { __typename?: 'Employment', title: string } - } & ({ __typename?: 'User', email: string } - | { __typename?: 'User', email?: never }) - & ({ __typename?: 'User', address: { __typename?: 'Address', street1: string } } - | { __typename?: 'User', address?: never }) - & ({ __typename?: 'User', widgetCount: number } - | { __typename?: 'User', widgetCount?: never }) - }; - `); - }); - - it('should resolve optionals according to maybeValue together with avoidOptionals and deferred fragments', async () => { - const schema = buildSchema(` - type Address { - street1: String - } - - type Phone { - home: String! - } - - type Employment { - title: String! - } - - type User { - name: String! - email: String! - address: Address! - phone: Phone! - employment: Employment! - widgetName: String! - widgetCount: Int! - clearanceLevel: String! - } - - type Query { - user: User! - } - `); - - const fragment = parse(` - fragment WidgetFragment on User { - widgetName - widgetCount + fragment FoodFragment on User { + favoriteFood + leastFavoriteFood } fragment EmploymentFragment on User { @@ -7097,6 +6178,9 @@ function test(q: GetEntityBrandDataQuery): void { # Test named fragment defer ...WidgetFragment @defer + # Test a secondary named fragment defer + ...FoodFragment @defer + # Not deferred fields, fragments, selection sets, etc are left alone name phone { @@ -7110,152 +6194,33 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const { content } = await plugin( - schema, - [{ location: '', document: fragment }], - { - preResolveTypes: true, - maybeValue: "T | 'specialType'", - avoidOptionals: true, - }, - { outputFile: 'graphql.ts' } - ); - - expect(content).toBeSimilarStringTo(` - export type UserQueryVariables = Exact<{ [key: string]: never; }>; - export type UserQuery = { - __typename?: 'Query', - user: { - __typename?: 'User', - clearanceLevel: string, - name: string, - phone: { __typename?: 'Phone', home: string }, - employment: { __typename?: 'Employment', title: string } - } & ({ __typename?: 'User', email: string } - | { __typename?: 'User', email?: never }) - & ({ __typename?: 'User', address: { __typename?: 'Address', street1: string | 'specialType' } } - | { __typename?: 'User', address?: never }) - & ({ __typename?: 'User', widgetName: string, widgetCount: number } - | { __typename?: 'User', widgetName?: never, widgetCount?: never }) - }; - `); - }); - - it('should generate correct types with inlineFragmentTypes: "mask""', async () => { - const schema = buildSchema(` - type Address { - street1: String! - } - - type Phone { - home: String! - } - - type Employment { - title: String! - } - - type User { - name: String! - email: String! - address: Address! - phone: Phone! - employment: Employment! - widgetCount: Int! - widgetPreference: String! - clearanceLevel: String! - favoriteFood: String! - leastFavoriteFood: String! - } - - type Query { - user: User! - } - `); - - const fragment = parse(` - fragment WidgetFragment on User { - widgetCount - widgetPreference - } - - fragment FoodFragment on User { - favoriteFood - leastFavoriteFood - } - - fragment EmploymentFragment on User { - employment { - title - } - } - - query user { - user { - # Test inline fragment defer - ... @defer { - email - } - - # Test inline fragment defer with nested selection set - ... @defer { - address { - street1 - } - } - - # Test named fragment defer - ...WidgetFragment @defer - - # Test a secondary named fragment defer - ...FoodFragment @defer - - # Not deferred fields, fragments, selection sets, etc are left alone - name - phone { - home - } - ...EmploymentFragment - ... { - clearanceLevel - } - } - } - `); + const content = mergeOutputs([ + await plugin( + schema, + [{ location: '', document: fragment }], + { inlineFragmentTypes: 'mask' }, + { outputFile: 'graphql.ts' } + ), + ]); - const { content } = await plugin( - schema, - [{ location: '', document: fragment }], - { preResolveTypes: true, inlineFragmentTypes: 'mask' }, - { outputFile: 'graphql.ts' } - ); + expect(content).toMatchInlineSnapshot(` + "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 WidgetFragmentFragment = { widgetCount: number, widgetPreference: string } & { ' $fragmentName'?: 'WidgetFragmentFragment' }; - expect(content).toBeSimilarStringTo(` - export type WidgetFragmentFragment = { __typename?: 'User', widgetCount: number, widgetPreference: string } & { ' $fragmentName'?: 'WidgetFragmentFragment' }; + export type FoodFragmentFragment = { favoriteFood: string, leastFavoriteFood: string } & { ' $fragmentName'?: 'FoodFragmentFragment' }; - export type FoodFragmentFragment = { __typename?: 'User', favoriteFood: string, leastFavoriteFood: string } & { ' $fragmentName'?: 'FoodFragmentFragment' }; + export type EmploymentFragmentFragment = { employment: { title: string } } & { ' $fragmentName'?: 'EmploymentFragmentFragment' }; - export type EmploymentFragmentFragment = { __typename?: 'User', employment: { __typename?: 'Employment', title: string } } & { ' $fragmentName'?: 'EmploymentFragmentFragment' }; + export type UserQueryVariables = Exact<{ [key: string]: never; }>; - export type UserQueryVariables = Exact<{ [key: string]: never; }>; - export type UserQuery = { - __typename?: 'Query', - user: ( - { - __typename?: 'User', - clearanceLevel: string, - name: string, - phone: { __typename?: 'Phone', home: string } - } & { ' $fragmentRefs'?: { 'EmploymentFragmentFragment': EmploymentFragmentFragment } } - ) & ({ __typename?: 'User', email: string } | { __typename?: 'User', email?: never }) & ({ __typename?: 'User', address: { __typename?: 'Address', street1: string } } | { __typename?: 'User', address?: never }) & ( - { __typename?: 'User' } - & { ' $fragmentRefs'?: { 'WidgetFragmentFragment': Incremental } } - ) & ( - { __typename?: 'User' } - & { ' $fragmentRefs'?: { 'FoodFragmentFragment': Incremental } } - ) }; - `); + export type UserQuery = { user: ( + { clearanceLevel: string, name: string, phone: { home: string } } + & { ' $fragmentRefs'?: { 'EmploymentFragmentFragment': EmploymentFragmentFragment } } + ) & ({ email: string } | { email?: never }) & ({ address: { street1: string } } | { address?: never }) & { ' $fragmentRefs'?: { 'WidgetFragmentFragment': Incremental } } & { ' $fragmentRefs'?: { 'FoodFragmentFragment': Incremental } } }; + " + `); }); }); @@ -7268,25 +6233,16 @@ function test(q: GetEntityBrandDataQuery): void { } `); - const result = await plugin( - schema, - [{ location: 'test-file.ts', document: ast }], - { preResolveTypes: false }, - { outputFile: '' } - ); - expect(result.content).toBeSimilarStringTo(` - export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - - export type Unnamed_1_Query = ( - { __typename?: 'Query' } - & { notifications: Array<( - { __typename?: 'TextNotification' } - & Pick - ) | ( - { __typename?: 'ImageNotification' } - & Pick - )> } - ); + const result = await plugin(schema, [{ location: 'test-file.ts', document: ast }], {}, { outputFile: '' }); + expect(result.content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { notifications: Array< + | { id: string } + | { id: string } + > }; + " `); }); @@ -7308,16 +6264,14 @@ function test(q: GetEntityBrandDataQuery): void { { inlineFragmentTypes: 'combine' }, { outputFile: '' } ); - expect(result.content).toBeSimilarStringTo(` - export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + expect(result.content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( - { __typename?: 'User' } - & UserFragmentFragment - ) | null }; + export type Unnamed_1_Query = { me: UserFragmentFragment | null }; - export type UserFragmentFragment = { __typename?: 'User', id: string }; + export type UserFragmentFragment = { id: string }; + " `); }); @@ -7338,13 +6292,14 @@ function test(q: GetEntityBrandDataQuery): void { { inlineFragmentTypes: 'inline' }, { outputFile: '' } ); - expect(result.content).toBeSimilarStringTo(` - export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + expect(result.content).toMatchInlineSnapshot(` + "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 = { me: { id: string } | null }; - export type UserFragmentFragment = { __typename?: 'User', id: string }; + export type UserFragmentFragment = { id: string }; + " `); }); @@ -7365,16 +6320,14 @@ function test(q: GetEntityBrandDataQuery): void { { inlineFragmentTypes: 'mask' }, { outputFile: '' } ); - expect(result.content).toBeSimilarStringTo(` - export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + expect(result.content).toMatchInlineSnapshot(` + "export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; - export type Unnamed_1_Query = { __typename?: 'Query', me?: ( - { __typename?: 'User' } - & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } } - ) | null }; + export type Unnamed_1_Query = { me: { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } } | null }; - export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; + export type UserFragmentFragment = { id: string } & { ' $fragmentName'?: 'UserFragmentFragment' }; + " `); }); }); 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 new file mode 100644 index 00000000000..cc0bcb97a89 --- /dev/null +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.enum.spec.ts @@ -0,0 +1,1502 @@ +import { mergeOutputs } from '@graphql-codegen/plugin-helpers'; +import { validateTs } from '@graphql-codegen/testing'; +import { buildSchema, parse } from 'graphql'; +import { plugin } from '../src/index.js'; + +describe('TypeScript Operations Plugin - Enum', () => { + it('does not generate enums if not used in variables and result', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query Me { + me { + id + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "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 MeQueryVariables = Exact<{ [key: string]: never; }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `native-numeric` enum', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document }], { enumType: 'native-numeric' }, { outputFile: '' }), + ]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export enum UserRole { + Admin = 0, + Customer = 1 + } + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `const` enum', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + A_B_C + X_Y_Z + _TEST + My_Value + _123 + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'const' }, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export const UserRole = { + ABC: 'A_B_C', + XYZ: 'X_Y_Z', + Test: '_TEST', + MyValue: 'My_Value', + '123': '_123' + } as const; + + export type UserRole = typeof UserRole[keyof typeof UserRole]; + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `native-const` enum', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + """ + Multiline comment test + """ + enum UserRole { + ADMIN + CUSTOMER @deprecated(reason: "Enum value CUSTOMER has been deprecated.") + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document }], { enumType: 'native-const' }, { outputFile: '' }), + ]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + /** Multiline comment test */ + export const enum UserRole { + Admin = 'ADMIN', + /** @deprecated Enum value CUSTOMER has been deprecated. */ + Customer = 'CUSTOMER' + }; + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `native` enum', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'native' }, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export enum UserRole { + Admin = 'ADMIN', + Customer = 'CUSTOMER' + } + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `enumValues` with `string-literal` enum', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + A_B_C + X_Y_Z + _TEST + My_Value + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumType: 'string-literal', + enumValues: { + UserRole: { + A_B_C: 0, + X_Y_Z: 'Foo', + _TEST: 'Bar', + My_Value: 1, + }, + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "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 UserRole = + | 0 + | 'Foo' + | 'Bar' + | 1; + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `enumValues` with `const` enum', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + A_B_C + X_Y_Z + _TEST + My_Value + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumType: 'const', + enumValues: { + UserRole: { + A_B_C: 0, + X_Y_Z: 'Foo', + _TEST: 'Bar', + My_Value: 1, + }, + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export const UserRole = { + ABC: 0, + XYZ: 'Foo', + Test: 'Bar', + MyValue: 1 + } as const; + + export type UserRole = typeof UserRole[keyof typeof UserRole]; + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `enumValues` with `native` enum', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumType: 'native', + enumValues: { + UserRole: { + ADMIN: 0, + CUSTOMER: 'test', + }, + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export enum UserRole { + Admin = 0, + Customer = 'test' + } + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `enumValues` as file import', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumValues: { + UserRole: './my-file#MyEnum', + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "import { MyEnum as UserRole } from './my-file'; + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export { UserRole }; + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('does not import or export `enumValues` (as file import) if enum is not used', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumValues: { + UserRole: './my-file#MyEnum', + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "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 Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; + + + export type Unnamed_1_Query = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `enumValues` with custom imported enum from namespace with different name', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumValues: { + UserRole: './my-file#NS.ETest', + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "import { NS } from './my-file'; + import UserRole = NS.ETest; + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export { UserRole }; + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `enumValues` with custom imported enum from namespace with the same name', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumValues: { + UserRole: './my-file#NS.UserRole', + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "import { NS } from './my-file'; + import UserRole = NS.UserRole; + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export { UserRole }; + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `enumValues` from a single file', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + enum UserStatus { + ACTIVE + PENDING + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!, $status: UserStatus!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumType: 'native', + enumValues: './my-file', + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "import { UserRole } from './my-file'; + import { UserStatus } from './my-file'; + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export { UserRole }; + + export { UserStatus }; + + export type MeQueryVariables = Exact<{ + role: UserRole; + status: UserStatus; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles `enumValues` from a single file when specified as string', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + enum UserStatus { + ACTIVE + PENDING + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!, $status: UserStatus!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumType: 'native', + enumValues: { UserRole: './my-file#UserRole', UserStatus: './my-file#UserStatus2X' }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "import { UserRole } from './my-file'; + import { UserStatus2X as UserStatus } from './my-file'; + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export { UserRole }; + + export { UserStatus }; + + export type MeQueryVariables = Exact<{ + role: UserRole; + status: UserStatus; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('removes underscore from enum values', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + A_B_C + X_Y_Z + _TEST + My_Value + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'native' }, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export enum UserRole { + ABC = 'A_B_C', + XYZ = 'X_Y_Z', + Test = '_TEST', + MyValue = 'My_Value' + } + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('keeps underscores in enum values when the value is only underscores', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + _ + __ + _TEST + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'native' }, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export enum UserRole { + _ = '_', + __ = '__', + Test = '_TEST' + } + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('adds typesPrefix to enum when enumPrefix is true', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document }], { typesPrefix: 'I', enumPrefix: true }, { outputFile: '' }), + ]); + expect(result).toMatchInlineSnapshot(` + "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 IUserRole = + | 'ADMIN' + | 'CUSTOMER'; + + export type IMeQueryVariables = Exact<{ + role: IUserRole; + }>; + + + export type IMeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('does not add typesPrefix to enum when enumPrefix is false', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document }], { typesPrefix: 'I', enumPrefix: false }, { outputFile: '' }), + ]); + expect(result).toMatchInlineSnapshot(` + "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 UserRole = + | 'ADMIN' + | 'CUSTOMER'; + + export type IMeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type IMeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('adds typesSuffix to enum when enumSuffix is true', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document }], { typesSuffix: 'Z', enumSuffix: true }, { outputFile: '' }), + ]); + expect(result).toMatchInlineSnapshot(` + "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 UserRoleZ = + | 'ADMIN' + | 'CUSTOMER'; + + export type MeQueryVariablesZ = Exact<{ + role: UserRoleZ; + }>; + + + export type MeQueryZ = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('does not add typesSuffix to enum when enumSuffix is false', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document }], { typesSuffix: 'Z', enumSuffix: false }, { outputFile: '' }), + ]); + expect(result).toMatchInlineSnapshot(` + "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 UserRole = + | 'ADMIN' + | 'CUSTOMER'; + + export type MeQueryVariablesZ = Exact<{ + role: UserRole; + }>; + + + export type MeQueryZ = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('keeps enum value naming convention when namingConvention.enumValues is `keep`', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + namingConvention: { + typeNames: 'change-case-all#lowerCase', + enumValues: 'keep', + }, + }, + { outputFile: '' } + ), + ]); + expect(result).toMatchInlineSnapshot(` + "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 userrole = + | 'ADMIN' + | 'CUSTOMER'; + + export type mequeryvariables = Exact<{ + role: userrole; + }>; + + + export type mequery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('uses custom enum naming convention when namingConvention.enumValues is provided and enumType is native', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + enumType: 'native', + namingConvention: { + typeNames: 'keep', + enumValues: 'change-case-all#lowerCase', + }, + }, + { outputFile: '' } + ), + ]); + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export enum UserRole { + admin = 'ADMIN', + customer = 'CUSTOMER' + } + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('does not contain "export" when noExport is set to true', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + noExport: true, + }, + { outputFile: '' } + ), + ]); + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + type UserRole = + | 'ADMIN' + | 'CUSTOMER'; + + type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('handles enumValues and named default import', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + typesPrefix: 'I', + namingConvention: { enumValues: 'change-case-all#constantCase' }, + enumValues: { + UserRole: './files#default as UserRole', + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "import UserRole from './files'; + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export { UserRole }; + + export type IMeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type IMeQuery = { me: { id: string } | null }; + " + `); + }); + + it('enum members should be quoted if numeric when enumType is native', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + AXB + _1X2 + _3X4 + } + + scalar DateTime + `); + + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], { enumType: 'native' }, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export enum UserRole { + Axb = 'AXB', + '1X2' = '_1X2', + '3X4' = '_3X4' + } + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + }); +}); + +describe('TypeScript Operations Plugin - Enum `%future added value`', () => { + it('adds `%future added value` to the type when enumType is `string-literal` and futureProofEnums is true', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + me: User + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query Me($role: UserRole!) { + me { + id + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], { futureProofEnums: true }, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "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 UserRole = + | 'ADMIN' + | 'CUSTOMER' + | '%future added value'; + + export type MeQueryVariables = Exact<{ + role: UserRole; + }>; + + + export type MeQuery = { me: { id: string } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); +}); 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 new file mode 100644 index 00000000000..782fc23d9ec --- /dev/null +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.import-types.spec.ts @@ -0,0 +1,392 @@ +import { buildSchema, parse } from 'graphql'; +import { validateTs } from '@graphql-codegen/testing'; +import { mergeOutputs } from '@graphql-codegen/plugin-helpers'; +import { plugin } from '../src/index.js'; + +describe('TypeScript Operations Plugin - Import Types', () => { + it('imports user-defined types externally with relative importSchemaTypesFrom correctly', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user(id: ID!): User + users(input: UsersInput!): UsersResponse! + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + "UserRole Description" + enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER + } + + "UsersInput Description" + input UsersInput { + "UsersInput from" + from: DateTime + "UsersInput to" + to: DateTime + role: UserRole + } + + type UsersResponseOk { + result: [User!]! + } + union UsersResponse = UsersResponseOk | ResponseError + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query User($id: ID!) { + user(id: $id) { + id + name + role + createdAt + } + } + + query Users($input: UsersInput!) { + users(input: $input) { + ... on UsersResponseOk { + result { + id + } + } + ... on ResponseError { + error + } + } + } + + query UsersWithScalarInput($from: DateTime!, $to: DateTime, $role: UserRole) { + users(input: { from: $from, to: $to, role: $role }) { + ... on UsersResponseOk { + result { + __typename + } + } + ... on ResponseError { + __typename + } + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + importSchemaTypesFrom: './base-dir/path-to-other-file.generated.ts', + namespacedImportName: 'TypeImport', + }, + { outputFile: './base-dir/this-file.ts' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "import type * as TypeImport from './path-to-other-file.generated'; + + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + /** UsersInput Description */ + type UsersInput = { + /** UsersInput from */ + from?: any; + /** UsersInput to */ + to?: any; + role?: UserRole | null | undefined; + }; + + export type UserQueryVariables = Exact<{ + id: string; + }>; + + + export type UserQuery = { user: { id: string, name: string, role: TypeImport.UserRole, createdAt: any } | null }; + + export type UsersQueryVariables = Exact<{ + input: TypeImport.UsersInput; + }>; + + + export type UsersQuery = { users: + | { result: Array<{ id: string }> } + | { error: TypeImport.ResponseErrorType } + }; + + export type UsersWithScalarInputQueryVariables = Exact<{ + from: any; + to?: any | null; + role?: TypeImport.UserRole | null; + }>; + + + export type UsersWithScalarInputQuery = { users: + | { result: Array<{ __typename: 'User' }> } + | { __typename: 'ResponseError' } + }; + " + `); + }); + + it('imports user-defined types externally with absolute importSchemaTypesFrom correctly', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user(id: ID!): User + users(input: UsersInput!): UsersResponse! + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + "UserRole Description" + enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER + } + + "UsersInput Description" + input UsersInput { + "UsersInput from" + from: DateTime + "UsersInput to" + to: DateTime + role: UserRole + } + + type UsersResponseOk { + result: [User!]! + } + union UsersResponse = UsersResponseOk | ResponseError + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query User($id: ID!) { + user(id: $id) { + id + name + role + createdAt + } + } + + query Users($input: UsersInput!) { + users(input: $input) { + ... on UsersResponseOk { + result { + id + } + } + ... on ResponseError { + error + } + } + } + + query UsersWithScalarInput($from: DateTime!, $to: DateTime, $role: UserRole) { + users(input: { from: $from, to: $to, role: $role }) { + ... on UsersResponseOk { + result { + __typename + } + } + ... on ResponseError { + __typename + } + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + importSchemaTypesFrom: '~@my-company/package/types', + namespacedImportName: 'TypeImport', + }, + { outputFile: './base-dir/this-file.ts' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "import type * as TypeImport from '@my-company/package/types'; + + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + /** UsersInput Description */ + type UsersInput = { + /** UsersInput from */ + from?: any; + /** UsersInput to */ + to?: any; + role?: UserRole | null | undefined; + }; + + export type UserQueryVariables = Exact<{ + id: string; + }>; + + + export type UserQuery = { user: { id: string, name: string, role: TypeImport.UserRole, createdAt: any } | null }; + + export type UsersQueryVariables = Exact<{ + input: TypeImport.UsersInput; + }>; + + + export type UsersQuery = { users: + | { result: Array<{ id: string }> } + | { error: TypeImport.ResponseErrorType } + }; + + export type UsersWithScalarInputQueryVariables = Exact<{ + from: any; + to?: any | null; + role?: TypeImport.UserRole | null; + }>; + + + export type UsersWithScalarInputQuery = { users: + | { result: Array<{ __typename: 'User' }> } + | { __typename: 'ResponseError' } + }; + " + `); + }); + + it('does not import external types if only native GraphQL types are used in Variables and Result', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user(id: ID!): User + users(input: UsersInput!): UsersResponse! + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + # Native GraphQL types + id: ID! + name: String! + isOld: Boolean! + ageInt: Int! + ageFloat: Float! + + # User-defined types + role: UserRole! + createdAt: DateTime! + } + + "UserRole Description" + enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER + } + + "UsersInput Description" + input UsersInput { + "UsersInput from" + from: DateTime + "UsersInput to" + to: DateTime + role: UserRole + } + + type UsersResponseOk { + result: [User!]! + } + union UsersResponse = UsersResponseOk | ResponseError + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query User($id: ID, $name: String, $bool: Boolean, $int: Int, $float: Float) { + user(id: $id) { + id + name + isOld + ageInt + ageFloat + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + importSchemaTypesFrom: './path-to-other-file', + namespacedImportName: 'TypeImport', + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "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 UserQueryVariables = Exact<{ + id?: string | null; + name?: string | null; + bool?: boolean | null; + int?: number | null; + float?: number | null; + }>; + + + export type UserQuery = { user: { id: string, name: string, isOld: boolean, ageInt: number, ageFloat: number } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); +}); 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 new file mode 100644 index 00000000000..03d33e1d2ec --- /dev/null +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts @@ -0,0 +1,370 @@ +import { mergeOutputs } from '@graphql-codegen/plugin-helpers'; +import { validateTs } from '@graphql-codegen/testing'; +import { buildSchema, parse } from 'graphql'; +import { plugin } from '../src/index.js'; + +describe('TypeScript Operations Plugin - Input', () => { + it('generates nested input correctly', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + users(input: UsersInput!): [User!]! + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + id: ID! + ageRange1: [Int] + ageRange2: [Int]! + ageRange3: [Int!] + ageRange4: [Int!]! + } + + "UserRole Description" + enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER + } + + "UsersInput Description" + input UsersInput { + "UsersInput from" + from: DateTime + "UsersInput to" + to: DateTime + timezone: TimeZone + role: UserRole + ageRange1: [Int] + ageRange2: [Int]! + ageRange3: [Int!] + ageRange4: [Int!]! + bestFriend: UsersBestFriendInput + nestedInput: UsersInput + } + + input UsersBestFriendInput { + name: String + } + + scalar DateTime + scalar TimeZone + `); + const document = parse(/* GraphQL */ ` + query UsersWithScalarInput($inputNonNullable: UsersInput!, $inputNullable: UsersInput) { + users(input: $inputNonNullable) { + ageRange1 + ageRange2 + ageRange3 + ageRange4 + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + scalars: { + DateTime: 'Date', + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + /** UserRole Description */ + export type UserRole = + /** UserRole ADMIN */ + | 'ADMIN' + /** UserRole CUSTOMER */ + | 'CUSTOMER'; + + /** UsersInput Description */ + type UsersInput = { + /** UsersInput from */ + from?: Date | null | undefined; + /** UsersInput to */ + to?: Date | null | undefined; + timezone?: any; + role?: UserRole | null | undefined; + ageRange1?: Array | null | undefined; + ageRange2: Array; + ageRange3?: Array | null | undefined; + ageRange4: Array; + bestFriend?: UsersBestFriendInput | null | undefined; + nestedInput?: UsersInput | null | undefined; + }; + + type UsersBestFriendInput = { + name?: string | null | undefined; + }; + + export type UsersWithScalarInputQueryVariables = Exact<{ + inputNonNullable: UsersInput; + inputNullable?: UsersInput | null; + }>; + + + export type UsersWithScalarInputQuery = { users: Array<{ ageRange1: Array | null, ageRange2: Array, ageRange3: Array | null, ageRange4: Array }> }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('generates readonly input when immutableTypes:true', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + users(input: UsersInput!): [User!]! + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + id: ID! + ageRange1: [Int] + ageRange2: [Int]! + ageRange3: [Int!] + ageRange4: [Int!]! + } + + "UserRole Description" + enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER + } + + "UsersInput Description" + input UsersInput { + "UsersInput from" + from: DateTime + "UsersInput to" + to: DateTime + timezone: TimeZone + role: UserRole + ageRange1: [Int] + ageRange2: [Int]! + ageRange3: [Int!] + ageRange4: [Int!]! + bestFriend: UsersBestFriendInput + nestedInput: UsersInput + } + + input UsersBestFriendInput { + name: String + } + + scalar DateTime + scalar TimeZone + `); + const document = parse(/* GraphQL */ ` + query UsersWithScalarInput($inputNonNullable: UsersInput!, $inputNullable: UsersInput) { + users(input: $inputNonNullable) { + ageRange1 + ageRange2 + ageRange3 + ageRange4 + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + scalars: { + DateTime: 'Date', + }, + immutableTypes: true, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + /** UserRole Description */ + export type UserRole = + /** UserRole ADMIN */ + | 'ADMIN' + /** UserRole CUSTOMER */ + | 'CUSTOMER'; + + /** UsersInput Description */ + type UsersInput = { + /** UsersInput from */ + readonly from?: Date | null | undefined; + /** UsersInput to */ + readonly to?: Date | null | undefined; + readonly timezone?: any; + readonly role?: UserRole | null | undefined; + readonly ageRange1?: Array | null | undefined; + readonly ageRange2: Array; + readonly ageRange3?: Array | null | undefined; + readonly ageRange4: Array; + readonly bestFriend?: UsersBestFriendInput | null | undefined; + readonly nestedInput?: UsersInput | null | undefined; + }; + + type UsersBestFriendInput = { + readonly name?: string | null | undefined; + }; + + export type UsersWithScalarInputQueryVariables = Exact<{ + inputNonNullable: UsersInput; + inputNullable?: UsersInput | null; + }>; + + + export type UsersWithScalarInputQuery = { readonly users: ReadonlyArray<{ readonly ageRange1: ReadonlyArray | null, readonly ageRange2: ReadonlyArray, readonly ageRange3: ReadonlyArray | null, readonly ageRange4: ReadonlyArray }> }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('generates @oneOf input correctly', async () => { + const schema = buildSchema(/* GraphQL */ ` + directive @oneOf on INPUT_OBJECT + + type Query { + users(input: UsersInput!): [User!]! + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + id: ID! + ageRange1: [Int] + ageRange2: [Int]! + ageRange3: [Int!] + ageRange4: [Int!]! + } + + "UserRole Description" + enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER + } + + "UsersInput Description" + input UsersInput @oneOf { + "UsersInput from" + from: DateTime + "UsersInput to" + to: DateTime + timezone: TimeZone + role: UserRole + ageRange1: [Int] + ageRange3: [Int!] + bestFriend: UsersBestFriendInput + nestedInput: UsersInput + } + + input UsersBestFriendInput { + name: String + } + + scalar DateTime + scalar TimeZone + `); + const document = parse(/* GraphQL */ ` + query Users($inputNonNullable: UsersInput!, $inputNullable: UsersInput) { + users(input: $inputNonNullable) { + __typename + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + scalars: { + DateTime: 'Date', + }, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + /** UserRole Description */ + export type UserRole = + /** UserRole ADMIN */ + | 'ADMIN' + /** UserRole CUSTOMER */ + | 'CUSTOMER'; + + /** UsersInput Description */ + type UsersInput = + { /** UsersInput from */ + from: Date; to?: never; timezone?: never; role?: never; ageRange1?: never; ageRange3?: never; bestFriend?: never; nestedInput?: never; } + | { from?: never; /** UsersInput to */ + to: Date; timezone?: never; role?: never; ageRange1?: never; ageRange3?: never; bestFriend?: never; nestedInput?: never; } + | { from?: never; to?: never; timezone: any; role?: never; ageRange1?: never; ageRange3?: never; bestFriend?: never; nestedInput?: never; } + | { from?: never; to?: never; timezone?: never; role: UserRole; ageRange1?: never; ageRange3?: never; bestFriend?: never; nestedInput?: never; } + | { from?: never; to?: never; timezone?: never; role?: never; ageRange1: Array; ageRange3?: never; bestFriend?: never; nestedInput?: never; } + | { from?: never; to?: never; timezone?: never; role?: never; ageRange1?: never; ageRange3: Array; bestFriend?: never; nestedInput?: never; } + | { from?: never; to?: never; timezone?: never; role?: never; ageRange1?: never; ageRange3?: never; bestFriend: UsersBestFriendInput; nestedInput?: never; } + | { from?: never; to?: never; timezone?: never; role?: never; ageRange1?: never; ageRange3?: never; bestFriend?: never; nestedInput: UsersInput; }; + + type UsersBestFriendInput = { + name?: string | null | undefined; + }; + + export type UsersQueryVariables = Exact<{ + inputNonNullable: UsersInput; + inputNullable?: UsersInput | null; + }>; + + + export type UsersQuery = { users: Array<{ __typename: 'User' }> }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); +}); diff --git a/packages/plugins/typescript/operations/tests/ts-documents.standalone.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.standalone.spec.ts new file mode 100644 index 00000000000..466b11ce8fd --- /dev/null +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.spec.ts @@ -0,0 +1,785 @@ +import { mergeOutputs } from '@graphql-codegen/plugin-helpers'; +import { validateTs } from '@graphql-codegen/testing'; +import { buildSchema, parse } from 'graphql'; +import { plugin } from '../src/index.js'; + +describe('TypeScript Operations Plugin - Standalone', () => { + it('generates using default config', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user(id: ID!): User + users(input: UsersInput!): UsersResponse! + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + nickname: String + } + + "UserRole Description" + enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER + } + + "UsersInput Description" + input UsersInput { + "UsersInput from" + from: DateTime + "UsersInput to" + to: DateTime + role: UserRole + } + + type UsersResponseOk { + result: [User!]! + } + union UsersResponse = UsersResponseOk | ResponseError + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query User($id: ID!) { + user(id: $id) { + id + name + role + createdAt + nickname + } + } + + query Users($input: UsersInput!) { + users(input: $input) { + ... on UsersResponseOk { + result { + id + } + } + ... on ResponseError { + error + } + } + } + + query UsersWithScalarInput($from: DateTime!, $to: DateTime, $role: UserRole) { + users(input: { from: $from, to: $to, role: $role }) { + ... on UsersResponseOk { + result { + __typename + } + } + ... on ResponseError { + __typename + } + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "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 ResponseErrorType = + | 'NOT_FOUND' + | 'INPUT_VALIDATION_ERROR' + | 'FORBIDDEN_ERROR' + | 'UNEXPECTED_ERROR'; + + /** UserRole Description */ + export type UserRole = + /** UserRole ADMIN */ + | 'ADMIN' + /** UserRole CUSTOMER */ + | 'CUSTOMER'; + + /** UsersInput Description */ + type UsersInput = { + /** UsersInput from */ + from?: any; + /** UsersInput to */ + to?: any; + role?: UserRole | null | undefined; + }; + + export type UserQueryVariables = Exact<{ + id: string; + }>; + + + export type UserQuery = { user: { id: string, name: string, role: UserRole, createdAt: any, nickname: string | null } | null }; + + export type UsersQueryVariables = Exact<{ + input: UsersInput; + }>; + + + export type UsersQuery = { users: + | { result: Array<{ id: string }> } + | { error: ResponseErrorType } + }; + + export type UsersWithScalarInputQueryVariables = Exact<{ + from: any; + to?: any | null; + role?: UserRole | null; + }>; + + + export type UsersWithScalarInputQuery = { users: + | { result: Array<{ __typename: 'User' }> } + | { __typename: 'ResponseError' } + }; + " + `); + + // FIXME: enable this to ensure type correctness + // validateTs(content, undefined, undefined, undefined, undefined, true); + }); + + it('test generating input types enums in lists and inner field', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + users(input: UsersInput!): [User!]! + } + + type User { + id: ID! + } + + enum EnumRoot { + ENUM_A + ENUM_B + } + + enum EnumRootArray { + ENUM_C + ENUM_D + } + + enum EnumInnerArray { + ENUM_E + ENUM_F + } + + input EnumsInner { + enumsDeep: [EnumInnerArray!]! + } + + input UsersInput { + enum: EnumRoot! + enums: [EnumRootArray!]! + innerEnums: EnumsInner! + } + `); + const document = parse(/* GraphQL */ ` + query Users($input: UsersInput!) { + users(input: $input) { + id + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "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 EnumRoot = + | 'ENUM_A' + | 'ENUM_B'; + + export type EnumRootArray = + | 'ENUM_C' + | 'ENUM_D'; + + export type EnumInnerArray = + | 'ENUM_E' + | 'ENUM_F'; + + type EnumsInner = { + enumsDeep: Array; + }; + + type UsersInput = { + enum: EnumRoot; + enums: Array; + innerEnums: EnumsInner; + }; + + export type UsersQueryVariables = Exact<{ + input: UsersInput; + }>; + + + export type UsersQuery = { users: Array<{ id: string }> }; + " + `); + }); + + it('test generating output enums in lists and inner field', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user(id: ID!): User! + } + + enum EnumRoot { + ENUM_A + ENUM_B + } + + enum EnumRootArray { + ENUM_C + ENUM_D + } + + enum EnumInnerArray { + ENUM_E + ENUM_F + } + + type EnumsInner { + enumsDeep: [EnumInnerArray!]! + } + + type User { + enum: EnumRoot! + enums: [EnumRootArray!]! + innerEnums: EnumsInner! + } + `); + const document = parse(/* GraphQL */ ` + query User($id: ID!) { + user(id: $id) { + enum + enums + innerEnums { + enumsDeep + } + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + extractAllFieldsToTypes: true, // Extracts all fields to separate types (similar to apollo-codegen behavior) + printFieldsOnNewLines: true, // Prints each field on a new line (similar to apollo-codegen behavior) + }, + { + outputFile: '', + } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "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 EnumRoot = + | 'ENUM_A' + | 'ENUM_B'; + + export type EnumRootArray = + | 'ENUM_C' + | 'ENUM_D'; + + export type EnumInnerArray = + | 'ENUM_E' + | 'ENUM_F'; + + export type UserQuery_user_User_innerEnums_EnumsInner = { + enumsDeep: Array + }; + + export type UserQuery_user_User = { + enum: EnumRoot, + enums: Array, + innerEnums: UserQuery_user_User_innerEnums_EnumsInner + }; + + export type UserQuery_Query = { + user: UserQuery_user_User + }; + + + export type UserQueryVariables = Exact<{ + id: string; + }>; + + + export type UserQuery = UserQuery_Query; + " + `); + }); + + it('test overrdiding config.scalars', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user(id: ID!): User + } + + type User { + id: ID! + name: String! + } + `); + const document = parse(/* GraphQL */ ` + query User($id: ID!) { + user(id: $id) { + id + name + } + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document }], { scalars: { ID: 'string | number | boolean' } }, { outputFile: '' }), + ]); + + expect(result).toMatchInlineSnapshot(` + "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 UserQueryVariables = Exact<{ + id: string | number | boolean; + }>; + + + export type UserQuery = { user: { id: string | number | boolean, name: string } | null }; + " + `); + }); + + it('test render output enum from fragment in the same document', async () => { + const schema = buildSchema(/* GraphQL */ ` + enum RoleType { + ROLE_A + ROLE_B + } + + type User { + id: ID! + name: String! + role: RoleType + pictureUrl: String + } + + type Query { + users: [User!]! + viewer: User! + } + `); + const document = parse(/* GraphQL */ ` + fragment UserBasic on User { + id + name + role + } + + query GetUsersAndViewer { + users { + ...UserBasic + } + viewer { + ...UserBasic + } + } + `); + + const result = mergeOutputs([await plugin(schema, [{ document }], {}, { outputFile: '' })]); + + expect(result).toMatchInlineSnapshot(` + "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 RoleType = + | 'ROLE_A' + | 'ROLE_B'; + + export type UserBasicFragment = { id: string, name: string, role: RoleType | null }; + + export type GetUsersAndViewerQueryVariables = Exact<{ [key: string]: never; }>; + + + export type GetUsersAndViewerQuery = { users: Array<{ id: string, name: string, role: RoleType | null }>, viewer: { id: string, name: string, role: RoleType | null } }; + " + `); + }); + + it('test render output enum from fragment in a separate document', async () => { + const schema = buildSchema(/* GraphQL */ ` + enum RoleType { + ROLE_A + ROLE_B + } + + type User { + id: ID! + name: String! + role: RoleType + pictureUrl: String + } + + type Query { + users: [User!]! + viewer: User! + } + `); + + const documentWithFragment = parse(/* GraphQL */ ` + fragment UserBasic on User { + id + name + role + } + `); + + const documentMain = parse(/* GraphQL */ ` + query GetUsersAndViewer { + users { + ...UserBasic + } + viewer { + ...UserBasic + } + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document: documentMain }, { document: documentWithFragment }], {}, { outputFile: '' }), + ]); + + expect(result).toMatchInlineSnapshot(` + "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 RoleType = + | 'ROLE_A' + | 'ROLE_B'; + + export type GetUsersAndViewerQueryVariables = Exact<{ [key: string]: never; }>; + + + export type GetUsersAndViewerQuery = { users: Array<{ id: string, name: string, role: RoleType | null }>, viewer: { id: string, name: string, role: RoleType | null } }; + + export type UserBasicFragment = { id: string, name: string, role: RoleType | null }; + " + `); + }); + + it('does not generate Variables, Result or Fragments when generatesOperationTypes is false', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user(id: ID!): User + users(input: UsersInput!): UsersResponse! + } + + type Mutation { + makeUserAdmin(id: ID!): User! + } + + type Subscription { + userChanges(id: ID!): User! + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + "UserRole Description" + enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER + } + + "UsersInput Description" + input UsersInput { + "UsersInput from" + from: DateTime + "UsersInput to" + to: DateTime + role: UserRole + } + + type UsersResponseOk { + result: [User!]! + } + union UsersResponse = UsersResponseOk | ResponseError + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query User($id: ID!) { + user(id: $id) { + id + name + role + createdAt + } + } + + query Users($input: UsersInput!) { + users(input: $input) { + ... on UsersResponseOk { + result { + ...UserFragment + } + } + ... on ResponseError { + error + } + } + } + + query UsersWithScalarInput($from: DateTime!, $to: DateTime, $role: UserRole) { + users(input: { from: $from, to: $to, role: $role }) { + ... on UsersResponseOk { + result { + __typename + } + } + ... on ResponseError { + __typename + } + } + } + + mutation MakeAdmin { + makeUserAdmin(id: "100") { + ...UserFragment + } + } + + subscription UserChanges { + makeUserAdmin(id: "100") { + ...UserFragment + } + } + + fragment UserFragment on User { + id + role + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document }], { generatesOperationTypes: false }, { outputFile: '' }), + ]); + + expect(result).toMatchInlineSnapshot(` + " + + export type ResponseErrorType = + | 'NOT_FOUND' + | 'INPUT_VALIDATION_ERROR' + | 'FORBIDDEN_ERROR' + | 'UNEXPECTED_ERROR'; + + /** UserRole Description */ + export type UserRole = + /** UserRole ADMIN */ + | 'ADMIN' + /** UserRole CUSTOMER */ + | 'CUSTOMER'; + + /** UsersInput Description */ + type UsersInput = { + /** UsersInput from */ + from?: any; + /** UsersInput to */ + to?: any; + role?: UserRole | null | undefined; + }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('does not generate unused schema enum and input types', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user(id: ID!): User + users(input: UsersInput!): UsersResponse! + } + + type Mutation { + makeUserAdmin(id: ID!): User! + } + + type Subscription { + userChanges(id: ID!): User! + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + } + + "UserRole Description" + enum UserRole { + "UserRole ADMIN" + ADMIN + "UserRole CUSTOMER" + CUSTOMER + } + + "UsersInput Description" + input UsersInput { + "UsersInput from" + from: DateTime + "UsersInput to" + to: DateTime + role: UserRole + } + + type UsersResponseOk { + result: [User!]! + } + union UsersResponse = UsersResponseOk | ResponseError + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query User { + user(id: "100") { + id + } + } + `); + + const result = mergeOutputs([ + await plugin(schema, [{ document }], { generatesOperationTypes: false }, { outputFile: '' }), + ]); + + expect(result).toMatchInlineSnapshot(` + " + + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); + + it('adds __typename correctly for Apollo Client when skipTypeNameForRoot:true, nonOptionalTypename:true are used', async () => { + const schema = buildSchema(/* GraphQL */ ` + type Query { + user(id: ID!): User + } + + type ResponseError { + error: ResponseErrorType! + } + + enum ResponseErrorType { + NOT_FOUND + INPUT_VALIDATION_ERROR + FORBIDDEN_ERROR + UNEXPECTED_ERROR + } + + type User { + id: ID! + name: String! + role: UserRole! + createdAt: DateTime! + bestFriend: User + goodFriends: [User!]! + } + + enum UserRole { + ADMIN + CUSTOMER + } + + scalar DateTime + `); + const document = parse(/* GraphQL */ ` + query User($id: ID!) { + user(id: $id) { + id + name + createdAt + bestFriend { + name + } + goodFriends { + id + __typename + } + } + } + `); + + const result = mergeOutputs([ + await plugin( + schema, + [{ document }], + { + skipTypeNameForRoot: true, + nonOptionalTypename: true, + }, + { outputFile: '' } + ), + ]); + + expect(result).toMatchInlineSnapshot(` + "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 UserQueryVariables = Exact<{ + id: string; + }>; + + + export type UserQuery = { user: { __typename: 'User', id: string, name: string, createdAt: any, bestFriend: { __typename: 'User', name: string } | null, goodFriends: Array<{ __typename: 'User', id: string }> } | null }; + " + `); + + validateTs(result, undefined, undefined, undefined, undefined, true); + }); +}); diff --git a/packages/plugins/typescript/resolvers/tests/__snapshots__/ts-resolvers.spec.ts.snap b/packages/plugins/typescript/resolvers/tests/__snapshots__/ts-resolvers.spec.ts.snap index 3838c3a15da..b63bc6c726b 100644 --- a/packages/plugins/typescript/resolvers/tests/__snapshots__/ts-resolvers.spec.ts.snap +++ b/packages/plugins/typescript/resolvers/tests/__snapshots__/ts-resolvers.spec.ts.snap @@ -3,7 +3,6 @@ exports[`TypeScript Resolvers Plugin > Config > allowParentTypeOverride - should allow to have less strict resolvers by overrding parent type 1`] = ` "export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; @@ -623,7 +622,6 @@ export type DirectiveResolvers = ResolversObject<{ exports[`TypeScript Resolvers Plugin > Config > optionalInfoArgument - should allow to have optional info argument 1`] = ` "export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type MakeEmpty = { [_ in K]?: never }; diff --git a/packages/plugins/typescript/typescript/src/typescript-variables-to-object.ts b/packages/plugins/typescript/typescript/src/typescript-variables-to-object.ts index 8cb07a79bfc..06d45e1f934 100644 --- a/packages/plugins/typescript/typescript/src/typescript-variables-to-object.ts +++ b/packages/plugins/typescript/typescript/src/typescript-variables-to-object.ts @@ -36,7 +36,7 @@ export class TypeScriptOperationVariablesToObject extends OperationVariablesToOb ); } - private clearOptional(str: string): string { + protected clearOptional(str: string): string { const prefix = this._namespacedImportName ? `${this._namespacedImportName}.` : ''; const rgx = new RegExp(`^${this.wrapMaybe(`(.*?)`)}$`, 'i'); diff --git a/packages/plugins/typescript/typescript/src/visitor.ts b/packages/plugins/typescript/typescript/src/visitor.ts index d306c7156c0..f9812ebac16 100644 --- a/packages/plugins/typescript/typescript/src/visitor.ts +++ b/packages/plugins/typescript/typescript/src/visitor.ts @@ -1,15 +1,15 @@ import { BaseTypesVisitor, + convertSchemaEnumToDeclarationBlockString, DeclarationBlock, DeclarationKind, getConfigValue, + getNodeComment, indent, isOneOfInputObjectType, normalizeAvoidOptionals, NormalizedAvoidOptionalsConfig, ParsedTypesConfig, - transformComment, - wrapWithSingleQuotes, } from '@graphql-codegen/visitor-plugin-common'; import autoBind from 'auto-bind'; import { @@ -46,7 +46,6 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig { useImplementingTypes: boolean; } -export const EXACT_SIGNATURE = `type Exact = { [K in keyof T]: T[K] };`; export const MAKE_OPTIONAL_SIGNATURE = `type MakeOptional = Omit & { [SubKey in K]?: Maybe };`; export const MAKE_MAYBE_SIGNATURE = `type MakeMaybe = Omit & { [SubKey in K]: Maybe };`; export const MAKE_EMPTY_SIGNATURE = `type MakeEmpty = { [_ in K]?: never };`; @@ -159,7 +158,6 @@ export class TsVisitor< const definitions: string[] = [ this.getMaybeValue(), this.getInputMaybeValue(), - this.getExactDefinition(), this.getMakeOptionalDefinition(), this.getMakeMaybeDefinition(), this.getMakeEmptyDefinition(), @@ -176,12 +174,6 @@ export class TsVisitor< return definitions; } - public getExactDefinition(): string { - if (this.config.onlyEnums) return ''; - - return `${this.getExportPrefix()}${EXACT_SIGNATURE}`; - } - public getMakeOptionalDefinition(): string { return `${this.getExportPrefix()}${MAKE_OPTIONAL_SIGNATURE}`; } @@ -282,7 +274,7 @@ export class TsVisitor< : (node.type as any as string); const originalFieldNode = parent[key] as FieldDefinitionNode; const addOptionalSign = !this.config.avoidOptionals.field && originalFieldNode.type.kind !== Kind.NON_NULL_TYPE; - const comment = this.getNodeComment(node); + const comment = getNodeComment(node); const { type } = this.config.declarationKind; return ( @@ -308,7 +300,7 @@ export class TsVisitor< !this.config.avoidOptionals.inputValue && (originalFieldNode.type.kind !== Kind.NON_NULL_TYPE || (!this.config.avoidOptionals.defaultValue && node.defaultValue !== undefined)); - const comment = this.getNodeComment(node); + const comment = getNodeComment(node); const declarationKind = this.config.declarationKind.type; let type: string = node.type as any as string; @@ -352,114 +344,39 @@ export class TsVisitor< EnumTypeDefinition(node: EnumTypeDefinitionNode): string { const enumName = node.name.value; - // In case of mapped external enum string - if (this.config.enumValues[enumName]?.sourceFile) { - return `export { ${this.config.enumValues[enumName].typeIdentifier} };\n`; - } + const outputType = ((): Parameters[0]['outputType'] => { + if (this.config.enumsAsTypes) { + return 'string-literal'; + } - const getValueFromConfig = (enumValue: string | number) => { - if (typeof this.config.enumValues[enumName]?.mappedValues?.[enumValue] !== 'undefined') { - return this.config.enumValues[enumName].mappedValues[enumValue]; + if (this.config.numericEnums) { + return 'native-numeric'; } - return null; - }; - const withFutureAddedValue = [ - this.config.futureProofEnums ? [indent('| ' + wrapWithSingleQuotes('%future added value'))] : [], - ]; + if (this.config.enumsAsConst) { + return 'const'; + } - const enumTypeName = this.convertName(node, { - useTypesPrefix: this.config.enumPrefix, - useTypesSuffix: this.config.enumSuffix, + return this.config.constEnums ? 'native-const' : 'native'; + })(); + + return convertSchemaEnumToDeclarationBlockString({ + schema: this._schema, + node, + declarationBlockConfig: this._declarationBlockConfig, + enumName, + enumValues: this.config.enumValues, + futureProofEnums: this.config.futureProofEnums, + ignoreEnumValuesFromSchema: this.config.ignoreEnumValuesFromSchema, + outputType, + naming: { + convert: this.config.convert, + typesPrefix: this.config.typesPrefix, + typesSuffix: this.config.typesSuffix, + useTypesPrefix: this.config.enumPrefix, + useTypesSuffix: this.config.enumSuffix, + }, }); - - if (this.config.enumsAsTypes) { - return new DeclarationBlock(this._declarationBlockConfig) - .export() - .asKind('type') - .withComment(node.description?.value) - .withName(enumTypeName) - .withContent( - '\n' + - node.values - .map(enumOption => { - const name = enumOption.name.value; - const enumValue: string | number = getValueFromConfig(name) ?? name; - const comment = transformComment(enumOption.description?.value, 1); - - return comment + indent('| ' + wrapWithSingleQuotes(enumValue)); - }) - .concat(...withFutureAddedValue) - .join('\n') - ).string; - } - - if (this.config.numericEnums) { - const block = new DeclarationBlock(this._declarationBlockConfig) - .export() - .withComment(node.description?.value) - .withName(enumTypeName) - .asKind('enum') - .withBlock( - node.values - .map((enumOption, i) => { - const valueFromConfig = getValueFromConfig(enumOption.name.value); - const enumValue: string | number = valueFromConfig ?? i; - const comment = transformComment(enumOption.description?.value, 1); - const optionName = this.makeValidEnumIdentifier( - this.convertName(enumOption, { - useTypesPrefix: false, - transformUnderscore: true, - }) - ); - return comment + indent(optionName) + ` = ${enumValue}`; - }) - .concat(...withFutureAddedValue) - .join(',\n') - ).string; - - return block; - } - - if (this.config.enumsAsConst) { - const typeName = `export type ${enumTypeName} = typeof ${enumTypeName}[keyof typeof ${enumTypeName}];`; - const enumAsConst = new DeclarationBlock({ - ...this._declarationBlockConfig, - blockTransformer: block => { - return block + ' as const'; - }, - }) - .export() - .asKind('const') - .withName(enumTypeName) - .withComment(node.description?.value) - .withBlock( - node.values - .map(enumOption => { - const optionName = this.makeValidEnumIdentifier( - this.convertName(enumOption, { - useTypesPrefix: false, - transformUnderscore: true, - }) - ); - const comment = transformComment(enumOption.description?.value, 1); - const name = enumOption.name.value; - const enumValue: string | number = getValueFromConfig(name) ?? name; - - return comment + indent(`${optionName}: ${wrapWithSingleQuotes(enumValue)}`); - }) - .join(',\n') - ).string; - - return [enumAsConst, typeName].join('\n'); - } - - return new DeclarationBlock(this._declarationBlockConfig) - .export() - .asKind(this.config.constEnums ? 'const enum' : 'enum') - .withName(enumTypeName) - .withComment(node.description?.value) - .withBlock(this.buildEnumValuesBlock(enumName, node.values)).string; } protected getPunctuation(_declarationKind: DeclarationKind): string { diff --git a/packages/presets/client/src/index.ts b/packages/presets/client/src/index.ts index 73ee7dac239..e2bccb299df 100644 --- a/packages/presets/client/src/index.ts +++ b/packages/presets/client/src/index.ts @@ -2,7 +2,6 @@ import * as addPlugin from '@graphql-codegen/add'; import * as gqlTagPlugin from '@graphql-codegen/gql-tag-operations'; import type { PluginFunction, Types } from '@graphql-codegen/plugin-helpers'; import * as typedDocumentNodePlugin from '@graphql-codegen/typed-document-node'; -import * as typescriptPlugin from '@graphql-codegen/typescript'; import * as typescriptOperationPlugin from '@graphql-codegen/typescript-operations'; import { ClientSideBaseVisitor, DocumentMode } from '@graphql-codegen/visitor-plugin-common'; import { parse, printSchema, type DocumentNode, type GraphQLSchema } from 'graphql'; @@ -128,18 +127,14 @@ export const preset: Types.OutputPreset = { strictScalars: options.config.strictScalars, namingConvention: options.config.namingConvention, useTypeImports: options.config.useTypeImports, - skipTypename: options.config.skipTypename, arrayInputCoercion: options.config.arrayInputCoercion, - enumsAsTypes: options.config.enumsAsTypes, - enumsAsConst: options.config.enumsAsConst, + enumType: options.config.enumType, enumValues: options.config.enumValues, futureProofEnums: options.config.futureProofEnums, nonOptionalTypename: options.config.nonOptionalTypename, avoidOptionals: options.config.avoidOptionals, documentMode: options.config.documentMode, skipTypeNameForRoot: options.config.skipTypeNameForRoot, - onlyOperationTypes: options.config.onlyOperationTypes, - onlyEnums: options.config.onlyEnums, customDirectives: options.config.customDirectives, immutableTypes: options.config.immutableTypes, }; @@ -187,7 +182,6 @@ export const preset: Types.OutputPreset = { const pluginMap = { ...options.pluginMap, [`add`]: addPlugin, - [`typescript`]: typescriptPlugin, [`typescript-operations`]: typescriptOperationPlugin, [`typed-document-node`]: { ...typedDocumentNodePlugin, @@ -221,11 +215,6 @@ export const preset: Types.OutputPreset = { const plugins: Array = [ { [`add`]: { content: `/* eslint-disable */` } }, - { - [`typescript`]: { - inputMaybeValue: 'T | null | undefined', - }, - }, { [`typescript-operations`]: {} }, { [`typed-document-node`]: { diff --git a/packages/presets/client/tests/client-preset.enum.spec.ts b/packages/presets/client/tests/client-preset.enum.spec.ts new file mode 100644 index 00000000000..c6dcc1897a0 --- /dev/null +++ b/packages/presets/client/tests/client-preset.enum.spec.ts @@ -0,0 +1,212 @@ +import { executeCodegen } from '@graphql-codegen/cli'; +import { preset } from '../src/index.js'; + +describe('client-preset - Enum', () => { + it('does not generate enum if not used in operations', async () => { + const { result } = await executeCodegen({ + schema: [ + /* GraphQL */ ` + enum Color { + RED + BLUE + } + `, + ], + + generates: { + 'out1/': { + preset, + }, + }, + }); + + const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); + expect(graphqlFile.content).toMatchInlineSnapshot(` + "/* eslint-disable */ + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };" + `); + }); + + it('generates enum if used in operation Variables', async () => { + const { result } = await executeCodegen({ + schema: [ + /* GraphQL */ ` + type Query { + shape(shape: Shape): ShapeObj! + } + + enum Color { + RED + BLUE + } + + enum Shape { + ROUND + SQUARE + } + + type ShapeObj { + id: ID! + shape: Shape! + } + `, + ], + documents: /* GraphQL */ ` + query Shape($shape: Shape) { + shape(shape: $shape) { + id + } + } + `, + + generates: { + 'out1/': { + preset, + }, + }, + }); + + 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'; + 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 Shape = + | 'ROUND' + | 'SQUARE'; + + export type ShapeQueryVariables = Exact<{ + shape?: Shape | null; + }>; + + + export type ShapeQuery = { shape: { id: string } }; + + + export const ShapeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Shape"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"shape"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Shape"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"shape"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"shape"},"value":{"kind":"Variable","name":{"kind":"Name","value":"shape"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode;" + `); + }); + + it('generates enum if used in operation Result', async () => { + const { result } = await executeCodegen({ + schema: [ + /* GraphQL */ ` + type Query { + shape(shape: Shape): ShapeObj! + } + + enum Color { + RED + BLUE + } + + enum Shape { + ROUND + SQUARE + } + + type ShapeObj { + id: ID! + shape: Shape! + } + `, + ], + documents: /* GraphQL */ ` + query Shape { + shape { + id + shape + } + } + `, + + generates: { + 'out1/': { + preset, + }, + }, + }); + + 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'; + 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 Shape = + | 'ROUND' + | 'SQUARE'; + + export type ShapeQueryVariables = Exact<{ [key: string]: never; }>; + + + export type ShapeQuery = { shape: { id: string, shape: Shape } }; + + + export const ShapeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Shape"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"shape"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"shape"}}]}}]}}]} as unknown as DocumentNode;" + `); + }); + + it('supports config.enumType=const', async () => { + const { result } = await executeCodegen({ + schema: [ + /* GraphQL */ ` + type Query { + shape(shape: Shape): ShapeObj! + } + + enum Shape { + ROUND + SQUARE + } + + type ShapeObj { + id: ID! + shape: Shape! + } + `, + ], + documents: /* GraphQL */ ` + query Shape($shape: Shape) { + shape(shape: $shape) { + id + } + } + `, + + generates: { + 'out1/': { + preset, + config: { + enumType: 'const', + }, + }, + }, + }); + + 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'; + type Exact = { [K in keyof T]: T[K] }; + export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; + export const Shape = { + Round: 'ROUND', + Square: 'SQUARE' + } as const; + + export type Shape = typeof Shape[keyof typeof Shape]; + export type ShapeQueryVariables = Exact<{ + shape?: Shape | null; + }>; + + + export type ShapeQuery = { shape: { id: string } }; + + + export const ShapeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Shape"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"shape"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Shape"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"shape"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"shape"},"value":{"kind":"Variable","name":{"kind":"Name","value":"shape"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode;" + `); + }); +}); diff --git a/packages/presets/client/tests/client-preset.nullability.spec.ts b/packages/presets/client/tests/client-preset.nullability.spec.ts index ad1f9834dce..b4e3a144d1e 100644 --- a/packages/presets/client/tests/client-preset.nullability.spec.ts +++ b/packages/presets/client/tests/client-preset.nullability.spec.ts @@ -83,16 +83,14 @@ describe('client-preset - nullability', () => { expect(formattedContent).toBeSimilarStringTo(` export type TestQuery = { - __typename?: "Query"; - me?: { - __typename?: "User"; + me: { 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 +98,7 @@ describe('client-preset - nullability', () => { nonNullableListBothLevels: Array; listWithNonNullableItem: Array; listWithNonNullableItemLevel0: Array; - listWithNonNullableItemLevel1?: Array | null; + listWithNonNullableItemLevel1: Array | null; listWithNonNullableItemBothLevels: Array; nonNullableListWithNonNullableItem: Array; nonNullableListWithNonNullableItemLevel0: Array; @@ -132,25 +130,23 @@ describe('client-preset - nullability', () => { expect(formattedContent).toBeSimilarStringTo(` export type TestQuery = { - __typename?: "Query"; - 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; + me: { + 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 fd330860548..51570c1b215 100644 --- a/packages/presets/client/tests/client-preset.spec.ts +++ b/packages/presets/client/tests/client-preset.spec.ts @@ -363,40 +363,19 @@ export * from "./gql";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { 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; @@ -499,47 +478,24 @@ export * from "./gql";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - 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; export const BDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"B"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"b"}}]}}]} as unknown as DocumentNode;" `); - - expect(graphqlFile.content).toContain("__typename: 'Query';"); }); it('supports Apollo fragment masking', async () => { @@ -588,43 +544,17 @@ export * from "./gql";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - me?: Maybe; - }; - - export type User = { - __typename?: 'User'; - age: Scalars['Int']['output']; - id: Scalars['ID']['output']; - name: Scalars['String']['output']; - }; - export type MeQueryVariables = Exact<{ [key: string]: never; }>; - export type MeQuery = { __typename?: 'Query', unmasked?: { __typename?: 'User', id: string, name: string, age: number } | null, masked?: ( - { __typename?: 'User', id: string } + export type MeQuery = { unmasked: { id: string, name: string, age: number } | null, masked: ( + { id: string } & { ' $fragmentRefs'?: { 'User_MeFragment': User_MeFragment } } ) | null }; - export type User_MeFragment = { __typename?: 'User', name: string, age: number } & { ' $fragmentName'?: 'User_MeFragment' }; + export type User_MeFragment = { name: string, age: number } & { ' $fragmentName'?: 'User_MeFragment' }; export const User_MeFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"User_Me"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"User"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"age"}}]}}]} as unknown as DocumentNode; export const MeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Me"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"unmasked"},"name":{"kind":"Name","value":"me"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"User_Me"},"directives":[{"kind":"Directive","name":{"kind":"Name","value":"unmask"}}]}]}},{"kind":"Field","alias":{"kind":"Name","value":"masked"},"name":{"kind":"Name","value":"me"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"User_Me"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"User_Me"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"User"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"age"}}]}}]} as unknown as DocumentNode;" @@ -705,31 +635,12 @@ export * from "./gql";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - }; - export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { 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;" @@ -1411,38 +1322,17 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type BbbQueryVariables = Exact<{ [key: string]: never; }>; - export type BbbQuery = { __typename?: 'Query', b?: string | null }; + export type BbbQuery = { b: string | null }; export type AaaQueryVariables = Exact<{ [key: string]: never; }>; - export type AaaQuery = { __typename?: 'Query', a?: string | null }; + export type AaaQuery = { 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; @@ -1489,40 +1379,19 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { 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; @@ -1570,40 +1439,19 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { 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; @@ -1651,40 +1499,19 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { 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; @@ -1734,38 +1561,17 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type AaaQueryVariables = Exact<{ [key: string]: never; }>; - export type AaaQuery = { __typename?: 'Query', a?: string | null }; + export type AaaQuery = { a: string | null }; export type BbbQueryVariables = Exact<{ [key: string]: never; }>; - export type BbbQuery = { __typename?: 'Query', b?: string | null }; + export type BbbQuery = { 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; @@ -1813,40 +1619,19 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { 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; @@ -1898,40 +1683,19 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { 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; @@ -1984,40 +1748,19 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { 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; @@ -2070,40 +1813,19 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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'; - a?: Maybe; - b?: Maybe; - c?: Maybe; - }; - export type AQueryVariables = Exact<{ [key: string]: never; }>; - export type AQuery = { __typename?: 'Query', a?: string | null }; + export type AQuery = { a: string | null }; export type BQueryVariables = Exact<{ [key: string]: never; }>; - export type BQuery = { __typename?: 'Query', b?: string | null }; + export type BQuery = { b: string | null }; - export type CFragment = { __typename?: 'Query', c?: string | null } & { ' $fragmentName'?: 'CFragment' }; + export type CFragment = { 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; @@ -2162,49 +1884,21 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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 A = { - __typename?: 'A'; - a: A; - b: Scalars['String']['output']; - }; - - export type Query = { - __typename?: 'Query'; - a: A; - }; - export type AbFragment = ( - { __typename?: 'A', b: string } + { b: string } & { ' $fragmentRefs'?: { 'AcFragment': AcFragment;'AaFragment': AaFragment } } ) & { ' $fragmentName'?: 'AbFragment' }; - export type AaFragment = { __typename?: 'A', b: string } & { ' $fragmentName'?: 'AaFragment' }; + export type AaFragment = { b: string } & { ' $fragmentName'?: 'AaFragment' }; export type OiQueryVariables = Exact<{ [key: string]: never; }>; - export type OiQuery = { __typename?: 'Query', a: ( - { __typename?: 'A' } - & { ' $fragmentRefs'?: { 'AbFragment': AbFragment;'AcFragment': AcFragment } } - ) }; + export type OiQuery = { a: { ' $fragmentRefs'?: { 'AbFragment': AbFragment;'AcFragment': AcFragment } } }; - export type AcFragment = { __typename?: 'A', b: string } & { ' $fragmentName'?: 'AcFragment' }; + export type AcFragment = { b: string } & { ' $fragmentName'?: 'AcFragment' }; export const AcFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AC"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"b"}}]}}]} as unknown as DocumentNode; export const AaFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AA"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"b"}}]}}]} as unknown as DocumentNode; @@ -2213,6 +1907,87 @@ export * from "./gql.js";`); `); }); + it('correctly handle fragment references with explicit __typename', async () => { + const { result } = await executeCodegen({ + schema: /* GraphQL */ ` + type Query { + a: A! + } + + type A { + b: String! + a: A! + } + `, + documents: [ + /* GraphQL */ ` + fragment AC on A { + __typename + b + } + `, + /* GraphQL */ ` + fragment AA on A { + __typename + b + } + `, + /* GraphQL */ ` + fragment AB on A { + __typename + b + ...AC + ...AA + } + `, + /* GraphQL */ ` + query OI { + __typename + a { + __typename + ...AB + ...AC + } + } + `, + ], + generates: { + 'out1/': { + preset, + plugins: [], + }, + }, + }); + 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'; + 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 AcFragment = { __typename: 'A', b: string } & { ' $fragmentName'?: 'AcFragment' }; + + export type AaFragment = { __typename: 'A', b: string } & { ' $fragmentName'?: 'AaFragment' }; + + export type AbFragment = ( + { __typename: 'A', b: string } + & { ' $fragmentRefs'?: { 'AcFragment': AcFragment;'AaFragment': AaFragment } } + ) & { ' $fragmentName'?: 'AbFragment' }; + + export type OiQueryVariables = Exact<{ [key: string]: never; }>; + + + export type OiQuery = { __typename: 'Query', a: ( + { __typename: 'A' } + & { ' $fragmentRefs'?: { 'AbFragment': AbFragment;'AcFragment': AcFragment } } + ) }; + + export const AcFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AC"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"b"}}]}}]} as unknown as DocumentNode; + export const AaFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AA"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"b"}}]}}]} as unknown as DocumentNode; + export const AbFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AB"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"b"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"AC"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"AA"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AC"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"b"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AA"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"b"}}]}}]} as unknown as DocumentNode; + export const OiDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"OI"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"a"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"AB"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"AC"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AC"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"b"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AA"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"b"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AB"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"A"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"b"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"AC"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"AA"}}]}}]} as unknown as DocumentNode;" + `); + }); + describe('handles @defer directive', () => { it('generates correct types and metadata', async () => { const { result } = await executeCodegen({ @@ -2241,58 +2016,29 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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 Foo = { - __typename?: 'Foo'; - id?: Maybe; - value?: Maybe; - }; - - export type Query = { - __typename?: 'Query'; - foo?: Maybe; - foos?: Maybe>>; - }; - export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: { __typename?: 'Foo' } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) | null }; + export type FooQuery = { foo: + | { ' $fragmentRefs'?: { 'FooFragment': Incremental } } + | Record + | null }; export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<{ __typename?: 'Foo' } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) | null> | null }; + export type FoosQuery = { foos: Array< + | { ' $fragmentRefs'?: { 'FooFragment': Incremental } } + | Record + | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { 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 = { id: string | null } & ({ value: string | null } | { value?: never }) & { ' $fragmentName'?: 'FooFragment' }; - export type FooNestedFragment = { __typename?: 'Foo', id?: string | null } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) & { ' $fragmentName'?: 'FooNestedFragment' }; + export type FooNestedFragment = { id: string | null } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } & { ' $fragmentName'?: 'FooNestedFragment' }; export const FooFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Foo"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Foo"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]} as unknown as DocumentNode; export const FooFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"foo"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Foo"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Foo"}},"directives":[{"kind":"Directive","name":{"kind":"Name","value":"defer"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]} as unknown as DocumentNode; @@ -2332,58 +2078,29 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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 Foo = { - __typename?: 'Foo'; - id?: Maybe; - value?: Maybe; - }; - - export type Query = { - __typename?: 'Query'; - foo?: Maybe; - foos?: Maybe>>; - }; - export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: { __typename?: 'Foo' } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) | null }; + export type FooQuery = { foo: + | { ' $fragmentRefs'?: { 'FooFragment': Incremental } } + | Record + | null }; export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<{ __typename?: 'Foo' } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) | null> | null }; + export type FoosQuery = { foos: Array< + | { ' $fragmentRefs'?: { 'FooFragment': Incremental } } + | Record + | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { 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 = { id: string | null } & ({ value: string | null } | { value?: never }) & { ' $fragmentName'?: 'FooFragment' }; - export type FooNestedFragment = { __typename?: 'Foo', id?: string | null } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) & { ' $fragmentName'?: 'FooNestedFragment' }; + export type FooNestedFragment = { id: string | null } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } & { ' $fragmentName'?: 'FooNestedFragment' }; export const FooFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Foo"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Foo"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]} as unknown as DocumentNode; export const FooFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"foo"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Foo"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Foo"}},"directives":[{"kind":"Directive","name":{"kind":"Name","value":"defer"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]} as unknown as DocumentNode; @@ -2423,58 +2140,29 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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 Foo = { - __typename?: 'Foo'; - id?: Maybe; - value?: Maybe; - }; - - export type Query = { - __typename?: 'Query'; - foo?: Maybe; - foos?: Maybe>>; - }; - export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: { __typename?: 'Foo' } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) | null }; + export type FooQuery = { foo: + | { ' $fragmentRefs'?: { 'FooFragment': Incremental } } + | Record + | null }; export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<{ __typename?: 'Foo' } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) | null> | null }; + export type FoosQuery = { foos: Array< + | { ' $fragmentRefs'?: { 'FooFragment': Incremental } } + | Record + | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { 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 = { id: string | null } & ({ value: string | null } | { value?: never }) & { ' $fragmentName'?: 'FooFragment' }; - export type FooNestedFragment = { __typename?: 'Foo', id?: string | null } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) & { ' $fragmentName'?: 'FooNestedFragment' }; + export type FooNestedFragment = { id: string | null } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } & { ' $fragmentName'?: 'FooNestedFragment' }; export class TypedDocumentString extends String @@ -2587,58 +2275,29 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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 Foo = { - __typename?: 'Foo'; - id?: Maybe; - value?: Maybe; - }; - - export type Query = { - __typename?: 'Query'; - foo?: Maybe; - foos?: Maybe>>; - }; - export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: { __typename?: 'Foo' } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) | null }; + export type FooQuery = { foo: + | { ' $fragmentRefs'?: { 'FooFragment': Incremental } } + | Record + | null }; export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<{ __typename?: 'Foo' } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) | null> | null }; + export type FoosQuery = { foos: Array< + | { ' $fragmentRefs'?: { 'FooFragment': Incremental } } + | Record + | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { 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 = { id: string | null } & ({ value: string | null } | { value?: never }) & { ' $fragmentName'?: 'FooFragment' }; - export type FooNestedFragment = { __typename?: 'Foo', id?: string | null } & ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } - ) & { ' $fragmentName'?: 'FooNestedFragment' }; + export type FooNestedFragment = { id: string | null } & { ' $fragmentRefs'?: { 'FooFragment': Incremental } } & { ' $fragmentName'?: 'FooNestedFragment' }; export class TypedDocumentString extends String @@ -2749,50 +2408,19 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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 Foo = { - __typename?: 'Foo'; - value?: Maybe; - }; - - export type Query = { - __typename?: 'Query'; - foo?: Maybe; - foos?: Maybe>>; - }; - export type FooQueryVariables = Exact<{ [key: string]: never; }>; - export type FooQuery = { __typename?: 'Query', foo?: ( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': FooFragment } } - ) | null }; + export type FooQuery = { foo: { ' $fragmentRefs'?: { 'FooFragment': FooFragment } } | null }; export type FoosQueryVariables = Exact<{ [key: string]: never; }>; - export type FoosQuery = { __typename?: 'Query', foos?: Array<( - { __typename?: 'Foo' } - & { ' $fragmentRefs'?: { 'FooFragment': FooFragment } } - ) | null> | null }; + export type FoosQuery = { foos: Array<{ ' $fragmentRefs'?: { 'FooFragment': FooFragment } } | null> | null }; - export type FooFragment = { __typename?: 'Foo', value?: string | null } & { ' $fragmentName'?: 'FooFragment' }; + export type FooFragment = { value: string | null } & { ' $fragmentName'?: 'FooFragment' }; export class TypedDocumentString extends String @@ -3043,55 +2671,15 @@ export * from "./gql.js";`); }); const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); - expect(graphqlFile.content).toBeSimilarStringTo(` - /* eslint-disable */ + expect(graphqlFile.content).toMatchInlineSnapshot(` + "/* eslint-disable */ import { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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 Mutation = { - __typename?: 'Mutation'; - createRegion?: Maybe; - }; - - - export type MutationCreateRegionArgs = { - regionDescription: Scalars['String']['input']; - }; - - export type Query = { - __typename?: 'Query'; - regions?: Maybe>>; - }; - - export type Region = { - __typename?: 'Region'; - regionDescription: Scalars['String']['output']; - regionId: Scalars['Int']['output']; - }; - - export type Subscription = { - __typename?: 'Subscription'; - onRegionCreated: Region; - }; - export type OnRegionCreatedSubscriptionVariables = Exact<{ [key: string]: never; }>; - export type OnRegionCreatedSubscription = { __typename?: 'Subscription', onRegionCreated: { __typename: 'Region', regionId: number, regionDescription: string } }; + export type OnRegionCreatedSubscription = { onRegionCreated: { __typename: 'Region', regionId: number, regionDescription: string } }; export class TypedDocumentString extends String @@ -3120,127 +2708,11 @@ export * from "./gql.js";`); regionDescription } } - \`) as unknown as TypedDocumentString; + \`) as unknown as TypedDocumentString;" `); }); }); - it('support enumsAsConst option', async () => { - const { result } = await executeCodegen({ - schema: [ - /* GraphQL */ ` - type Query { - thing: Thing - } - type Thing { - color: Color! - } - enum Color { - RED - BLUE - } - `, - ], - documents: path.join(__dirname, 'fixtures/enum.ts'), - generates: { - 'out1/': { - preset, - config: { - enumsAsConst: true, - }, - }, - }, - }); - const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); - expect(graphqlFile.content).toBeSimilarStringTo(` - /* eslint-disable */ - import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - 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 const Color = { - Blue: 'BLUE', - Red: 'RED' - } as const; - - export type Color = typeof Color[keyof typeof Color]; - export type Query = { - __typename?: 'Query'; - thing?: Maybe; - }; - - export type Thing = { - __typename?: 'Thing'; - color: Color; - }; - - export type FavoriteColorQueryVariables = Exact<{ [key: string]: never; }>; - - - export type FavoriteColorQuery = { __typename?: 'Query', thing?: { __typename?: 'Thing', color: Color } | null }; - - - export const FavoriteColorDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FavoriteColor"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"thing"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"color"}}]}}]}}]} as unknown as DocumentNode; - `); - }); - - it('support enumValues option', async () => { - const { result } = await executeCodegen({ - schema: [ - /* GraphQL */ ` - enum Color { - RED - BLUE - } - `, - ], - generates: { - 'out1/': { - preset, - config: { - enumValues: { - Color: './fixtures/with-enum-values#MyColor', - }, - }, - }, - }, - }); - - const graphqlFile = result.find(file => file.filename === 'out1/graphql.ts'); - expect(graphqlFile.content).toBeSimilarStringTo(`/* eslint-disable */ - import { MyColor as Color } from './fixtures/with-enum-values'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - 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 { Color };`); - }); - it('supports immutableTypes', async () => { const { result } = await executeCodegen({ schema: [ @@ -3279,43 +2751,12 @@ export * from "./gql.js";`); expect(graphqlFile.content).toMatchInlineSnapshot(` "/* eslint-disable */ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; - export type Maybe = T | null; - export type InputMaybe = T | null | undefined; - export type Exact = { [K in keyof T]: T[K] }; - export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; - export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; - export type MakeEmpty = { [_ in K]?: never }; + type Exact = { [K in keyof T]: T[K] }; 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 = { - readonly __typename?: 'Query'; - readonly user?: Maybe; - }; - - - export type QueryUserArgs = { - id: Scalars['ID']['input']; - }; - - export type User = { - readonly __typename?: 'User'; - readonly friends: ReadonlyArray; - readonly id: Scalars['ID']['output']; - readonly name: Scalars['String']['output']; - }; - 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 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;"