From 1d145940842b3727d5a0a415705ba0815e793652 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Wed, 16 Oct 2024 17:19:46 -0400 Subject: [PATCH 1/8] feat: introduce generator extensions --- graffle/_.ts | 9 + graffle/__.ts | 1 + graffle/modules/Client.ts | 5 + graffle/modules/Data.ts | 4 + graffle/modules/Global.ts | 24 + graffle/modules/MethodsDocument.ts | 18 + graffle/modules/MethodsRoot.ts | 585 +++++ graffle/modules/MethodsSelect.ts | 199 ++ graffle/modules/Scalar.ts | 1 + graffle/modules/SchemaBuildtime.ts | 359 +++ graffle/modules/SchemaDrivenDataMap.ts | 689 ++++++ graffle/modules/SchemaIndex.ts | 69 + graffle/modules/Select.ts | 149 ++ graffle/modules/SelectionSets.ts | 2102 ++++++++++++++++ package.json | 2 +- src/cli/generate.ts | 129 +- src/entrypoints/_Generator.ts | 2 + src/entrypoints/__Generator.ts | 1 + src/entrypoints/extensionkit.ts | 2 + src/entrypoints/extensions/schema-errors/_.ts | 0 .../extensions/schema-errors/generator/_.ts | 0 src/entrypoints/generator.ts | 2 +- src/entrypoints/utilities-for-generated.ts | 4 +- src/extensions/CustomScalars/decode.ts | 2 +- src/extensions/CustomScalars/encode.ts | 2 +- .../CustomScalars/schemaDrivenDataMap/__.ts | 5 + .../schemaDrivenDataMap/generator.ts | 85 +- .../schemaDrivenDataMap/types.ts | 287 +-- src/extensions/SchemaErrors/SchemaErrors.ts | 6 +- src/extensions/SchemaErrors/documentation.md | 42 +- src/extensions/SchemaErrors/generator.ts | 85 + .../injectTypenameOnRootResultFields.test.ts | 49 + .../injectTypenameOnRootResultFields.ts} | 2 +- .../{ => tests}/SchemaError.test-d.ts | 13 +- .../{ => tests}/SchemaErrors.test.ts | 52 +- .../tests/fixture/graffle.config.ts | 17 + .../SchemaErrors/tests/fixture/graffle/_.ts | 10 + .../SchemaErrors/tests/fixture/graffle/__.ts | 1 + .../tests/fixture/graffle/modules/Client.ts | 6 + .../tests/fixture/graffle/modules/Data.ts | 4 + .../tests/fixture/graffle/modules/Global.ts | 26 + .../graffle/modules/MethodsDocument.ts | 18 + .../fixture/graffle/modules/MethodsRoot.ts | 585 +++++ .../fixture/graffle/modules/MethodsSelect.ts | 199 ++ .../tests/fixture/graffle/modules/Scalar.ts | 2 + .../tests/fixture/graffle/modules/Schema.ts | 72 + .../graffle/modules/SchemaBuildtime.ts | 359 +++ .../graffle/modules/SchemaDrivenDataMap.ts | 735 ++++++ .../fixture/graffle/modules/SchemaIndex.ts | 69 + .../tests/fixture/graffle/modules/Select.ts | 149 ++ .../fixture/graffle/modules/SelectionSets.ts | 2103 +++++++++++++++++ .../1_Schema/Hybrid/types/Scalar/Scalar.ts | 1 + src/layers/1_Schema/Output/Output.ts | 2 +- src/layers/1_Schema/__.ts | 2 +- src/layers/2_Select/Directive/$types.ts | 4 +- src/layers/2_Select/Directive/include.ts | 4 +- src/layers/2_Select/Directive/skip.ts | 4 +- src/layers/3_InferResult/Alias.ts | 20 +- src/layers/3_InferResult/Field.ts | 28 +- src/layers/3_InferResult/InlineFragment.ts | 6 +- src/layers/3_InferResult/Interface.ts | 6 +- src/layers/3_InferResult/Object.ts | 16 +- src/layers/3_InferResult/ScalarsWildcard.ts | 12 +- src/layers/3_InferResult/Union.ts | 6 +- src/layers/3_InferResult/root.ts | 18 +- src/layers/3_SelectGraphQLMapper/context.ts | 2 +- .../inferVariableType.ts | 2 +- src/layers/3_SelectGraphQLMapper/mapper.ts | 2 +- .../nodes/2_OperationDefinition.ts | 2 +- .../nodes/3_GraffleSelectionSetRoot.ts | 2 +- .../nodes/4_GraffleSelectionObjectLevel.ts | 2 +- .../3_SelectGraphQLMapper/nodes/5_Field.ts | 2 +- .../3_SelectGraphQLMapper/nodes/Argument.ts | 2 +- .../3_SelectGraphQLMapper/nodes/Value.ts | 2 +- .../3_SelectGraphQLMapper/nodes/_collect.ts | 2 +- src/layers/4_generator/_.ts | 6 +- src/layers/4_generator/config.ts | 220 -- .../__snapshots__/config.test.ts.snap | 0 .../4_generator/{ => config}/config.test.ts | 8 +- src/layers/4_generator/config/config.ts | 234 ++ src/layers/4_generator/config/defaults.ts | 8 + src/layers/4_generator/config/input.ts | 113 + src/layers/4_generator/configFile/_.ts | 2 + src/layers/4_generator/configFile/builder.ts | 37 + src/layers/4_generator/configFile/loader.ts | 101 + src/layers/4_generator/extension/create.ts | 14 + src/layers/4_generator/extension/types.ts | 29 + src/layers/4_generator/generate.ts | 66 - .../__snapshots__/generate.test.ts.snap | 0 .../{ => generator}/generate.test.ts | 0 src/layers/4_generator/generator/generate.ts | 65 + src/layers/4_generator/generators/Client.ts | 3 +- .../4_generator/generators/MethodsDocument.ts | 4 +- .../4_generator/generators/MethodsRoot.ts | 8 +- .../4_generator/generators/MethodsSelect.ts | 8 +- src/layers/4_generator/generators/Scalar.ts | 67 +- src/layers/4_generator/generators/Schema.ts | 122 + .../4_generator/generators/SchemaBuildtime.ts | 6 +- .../4_generator/generators/SchemaIndex.ts | 154 -- src/layers/4_generator/generators/Select.ts | 12 +- .../4_generator/generators/SelectionSets.ts | 20 +- src/layers/4_generator/generators/_.ts | 2 + src/layers/4_generator/generators/__.ts | 3 +- src/layers/4_generator/generators/global.ts | 59 +- src/layers/4_generator/globalRegistry.ts | 22 +- src/layers/4_generator/helpers/fs.ts | 18 - .../helpers/moduleGeneratorRunner.ts | 2 +- src/layers/4_generator/helpers/render.ts | 4 +- src/layers/5_request/core.ts | 4 +- src/layers/6_client/Settings/Config.ts | 2 +- src/layers/6_client/Settings/Input.ts | 2 +- src/layers/6_client/prefilled.ts | 2 +- .../6_client/requestMethods/document.ts | 4 +- src/lib/Code.ts | 90 +- ...analyzeFunction.ts => analyze-function.ts} | 0 src/lib/anyware/getEntrypoint.ts | 2 +- src/lib/config-manager/ConfigManager.test.ts | 120 + src/lib/config-manager/ConfigManager.ts | 91 +- src/lib/fs.ts | 44 + src/lib/grafaid/schema/kindMap.ts | 22 +- src/lib/grafaid/schema/schema.ts | 13 +- src/lib/import-first.ts | 28 + src/lib/prelude.ts | 26 +- src/lib/{TSError.ts => ts-error.ts} | 0 .../typescript-formatter.ts} | 2 +- tests/_/schemas/generate.ts | 54 +- tests/_/schemas/kitchen-sink/graffle/_.ts | 1 + .../kitchen-sink/graffle/modules/Client.ts | 3 +- .../kitchen-sink/graffle/modules/Global.ts | 7 +- .../kitchen-sink/graffle/modules/Scalar.ts | 24 - .../graffle/modules/SchemaDrivenDataMap.ts | 98 +- .../graffle/modules/SchemaIndex.ts | 18 - .../graffle/modules/SelectionSets.ts | 17 +- .../kitchen-sink/{ => graffle}/schema.graphql | 0 tests/_/schemas/mutation-only/graffle/_.ts | 1 + .../mutation-only/graffle/modules/Client.ts | 3 +- .../mutation-only/graffle/modules/Global.ts | 2 +- .../mutation-only/graffle/modules/Scalar.ts | 2 - .../graffle/modules/SchemaDrivenDataMap.ts | 10 +- .../graffle/modules/SchemaIndex.ts | 10 - .../{ => graffle}/schema.graphql | 0 tests/_/schemas/pokemon/graffle/_.ts | 1 + .../schemas/pokemon/graffle/modules/Client.ts | 3 +- .../schemas/pokemon/graffle/modules/Global.ts | 2 +- .../schemas/pokemon/graffle/modules/Scalar.ts | 2 - .../graffle/modules/SchemaDrivenDataMap.ts | 10 +- .../pokemon/graffle/modules/SchemaIndex.ts | 9 - .../pokemon/{ => graffle}/schema.graphql | 0 tests/_/schemas/query-only/graffle/_.ts | 1 + .../query-only/graffle/modules/Client.ts | 3 +- .../query-only/graffle/modules/Global.ts | 2 +- .../query-only/graffle/modules/Scalar.ts | 2 - .../graffle/modules/SchemaDrivenDataMap.ts | 10 +- .../query-only/graffle/modules/SchemaIndex.ts | 9 - .../query-only/{ => graffle}/schema.graphql | 0 website/graffle/modules/Global.ts | 2 +- website/pokemon/modules/Global.ts | 2 +- 157 files changed, 10442 insertions(+), 1225 deletions(-) create mode 100644 graffle/_.ts create mode 100644 graffle/__.ts create mode 100644 graffle/modules/Client.ts create mode 100644 graffle/modules/Data.ts create mode 100644 graffle/modules/Global.ts create mode 100644 graffle/modules/MethodsDocument.ts create mode 100644 graffle/modules/MethodsRoot.ts create mode 100644 graffle/modules/MethodsSelect.ts create mode 100644 graffle/modules/Scalar.ts create mode 100644 graffle/modules/SchemaBuildtime.ts create mode 100644 graffle/modules/SchemaDrivenDataMap.ts create mode 100644 graffle/modules/SchemaIndex.ts create mode 100644 graffle/modules/Select.ts create mode 100644 graffle/modules/SelectionSets.ts create mode 100644 src/entrypoints/_Generator.ts create mode 100644 src/entrypoints/__Generator.ts create mode 100644 src/entrypoints/extensionkit.ts create mode 100644 src/entrypoints/extensions/schema-errors/_.ts create mode 100644 src/entrypoints/extensions/schema-errors/generator/_.ts create mode 100644 src/extensions/CustomScalars/schemaDrivenDataMap/__.ts create mode 100644 src/extensions/SchemaErrors/generator.ts create mode 100644 src/extensions/SchemaErrors/injectTypenameOnRootResultFields.test.ts rename src/{layers/5_request/schemaErrors.ts => extensions/SchemaErrors/injectTypenameOnRootResultFields.ts} (92%) rename src/extensions/SchemaErrors/{ => tests}/SchemaError.test-d.ts (80%) rename src/extensions/SchemaErrors/{ => tests}/SchemaErrors.test.ts (59%) create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle.config.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/_.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/__.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/Client.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/Data.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/Global.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsDocument.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsRoot.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsSelect.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaBuildtime.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaDrivenDataMap.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaIndex.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/Select.ts create mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/SelectionSets.ts delete mode 100644 src/layers/4_generator/config.ts rename src/layers/4_generator/{ => config}/__snapshots__/config.test.ts.snap (100%) rename src/layers/4_generator/{ => config}/config.test.ts (73%) create mode 100644 src/layers/4_generator/config/config.ts create mode 100644 src/layers/4_generator/config/defaults.ts create mode 100644 src/layers/4_generator/config/input.ts create mode 100644 src/layers/4_generator/configFile/_.ts create mode 100644 src/layers/4_generator/configFile/builder.ts create mode 100644 src/layers/4_generator/configFile/loader.ts create mode 100644 src/layers/4_generator/extension/create.ts create mode 100644 src/layers/4_generator/extension/types.ts delete mode 100644 src/layers/4_generator/generate.ts rename src/layers/4_generator/{ => generator}/__snapshots__/generate.test.ts.snap (100%) rename src/layers/4_generator/{ => generator}/generate.test.ts (100%) create mode 100644 src/layers/4_generator/generator/generate.ts create mode 100644 src/layers/4_generator/generators/Schema.ts delete mode 100644 src/layers/4_generator/generators/SchemaIndex.ts delete mode 100644 src/layers/4_generator/helpers/fs.ts rename src/lib/{analyzeFunction.ts => analyze-function.ts} (100%) create mode 100644 src/lib/config-manager/ConfigManager.test.ts create mode 100644 src/lib/fs.ts create mode 100644 src/lib/import-first.ts rename src/lib/{TSError.ts => ts-error.ts} (100%) rename src/{layers/4_generator/helpers/typeScriptFormatter.ts => lib/typescript-formatter.ts} (95%) rename tests/_/schemas/kitchen-sink/{ => graffle}/schema.graphql (100%) rename tests/_/schemas/mutation-only/{ => graffle}/schema.graphql (100%) rename tests/_/schemas/pokemon/{ => graffle}/schema.graphql (100%) rename tests/_/schemas/query-only/{ => graffle}/schema.graphql (100%) diff --git a/graffle/_.ts b/graffle/_.ts new file mode 100644 index 000000000..d5cdf0031 --- /dev/null +++ b/graffle/_.ts @@ -0,0 +1,9 @@ +// We import the global module for good measure although it is not clear it is always needed. +// It at least helps with Twoslash wherein without this import here Twoslash will not include the global module. +// In real TypeScript projects it seems the global module is included automatically. But there could be certain tsconfig +// setups where this still indeed does help. +import './modules/Global.js' + +export { create } from './modules/Client.js' +export { Select } from './modules/Select.js' +export * as SelectionSets from './modules/SelectionSets.js' diff --git a/graffle/__.ts b/graffle/__.ts new file mode 100644 index 000000000..4fba9ada3 --- /dev/null +++ b/graffle/__.ts @@ -0,0 +1 @@ +export * as Graffle from './_.js' diff --git a/graffle/modules/Client.ts b/graffle/modules/Client.ts new file mode 100644 index 000000000..f3787e620 --- /dev/null +++ b/graffle/modules/Client.ts @@ -0,0 +1,5 @@ +import { createPrefilled } from 'graffle/client' +import { defaultSchemaUrl } from './Data.js' +import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' + +export const create = createPrefilled(`default`, schemaDrivenDataMap, defaultSchemaUrl) diff --git a/graffle/modules/Data.ts b/graffle/modules/Data.ts new file mode 100644 index 000000000..ef2ad4cf6 --- /dev/null +++ b/graffle/modules/Data.ts @@ -0,0 +1,4 @@ +export const Name = `default` +export type Name = 'default' + +export const defaultSchemaUrl = undefined diff --git a/graffle/modules/Global.ts b/graffle/modules/Global.ts new file mode 100644 index 000000000..f7af69d03 --- /dev/null +++ b/graffle/modules/Global.ts @@ -0,0 +1,24 @@ +import type * as Data from './Data.js' +import type * as MethodsDocument from './MethodsDocument.js' +import type * as MethodsRoot from './MethodsRoot.js' +import type * as MethodsSelect from './MethodsSelect.js' +import type { Index } from './SchemaIndex.js' + +declare global { + export namespace GraffleGlobal { + export interface Schemas { + default: { + name: Data.Name + index: Index + interfaces: { + MethodsSelect: MethodsSelect.$MethodsSelect + Document: MethodsDocument.BuilderMethodsDocumentFn + Root: MethodsRoot.BuilderMethodsRootFn + } + customScalars: {} + + defaultSchemaUrl: null + } + } + } +} diff --git a/graffle/modules/MethodsDocument.ts b/graffle/modules/MethodsDocument.ts new file mode 100644 index 000000000..9b6e948e3 --- /dev/null +++ b/graffle/modules/MethodsDocument.ts @@ -0,0 +1,18 @@ +import type * as Utilities from 'graffle/utilities-for-generated' +import type { Index } from './SchemaIndex.js' +import type * as SelectionSets from './SelectionSets.js' + +export interface Document<$Config extends Utilities.Config> { + <$Document>(document: Utilities.ExactNonEmpty<$Document, SelectionSets.$Document>): Utilities.DocumentRunner< + $Config, + Index, + // @ts-expect-error We use Exact instead of constraint on this function. TypeScript does not see that as + // Satisfying the constraint on the DocumentRunner type. + $Document + > +} + +export interface BuilderMethodsDocumentFn extends Utilities.TypeFunction.Fn { + // @ts-expect-error parameter is Untyped. + return: Document +} diff --git a/graffle/modules/MethodsRoot.ts b/graffle/modules/MethodsRoot.ts new file mode 100644 index 000000000..161ed0d5f --- /dev/null +++ b/graffle/modules/MethodsRoot.ts @@ -0,0 +1,585 @@ +import type { InferResult } from 'graffle/schema' +import type * as Utils from 'graffle/utilities-for-generated' +import { type Simplify } from 'type-fest' +import type { Index } from './SchemaIndex.js' +import type * as SelectionSet from './SelectionSets.js' + +export interface MutationMethods<$Config extends Utils.Config> { + // todo Use a static type here? + $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Mutation>) => Promise< + Simplify< + Utils.HandleOutput< + $Config, + InferResult.Mutation<$SelectionSet, Index> + > + > + > + // todo Use a static type here? + __typename: () => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + { __typename: 'Mutation' }, + '__typename' + > + > + > + id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.id>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Mutation<{ id: $SelectionSet }, Index>, + 'id' + > + > + > + idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.idNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Mutation<{ idNonNull: $SelectionSet }, Index>, + 'idNonNull' + > + > + > +} + +export interface QueryMethods<$Config extends Utils.Config> { + // todo Use a static type here? + $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query>) => Promise< + Simplify< + Utils.HandleOutput< + $Config, + InferResult.Query<$SelectionSet, Index> + > + > + > + // todo Use a static type here? + __typename: () => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + { __typename: 'Query' }, + '__typename' + > + > + > + InputObjectNested: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNested>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ InputObjectNested: $SelectionSet }, Index>, + 'InputObjectNested' + > + > + > + InputObjectNestedNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNestedNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ InputObjectNestedNonNull: $SelectionSet }, Index>, + 'InputObjectNestedNonNull' + > + > + > + /** + * Query enum field documentation. + */ + abcEnum: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.abcEnum>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ abcEnum: $SelectionSet }, Index>, + 'abcEnum' + > + > + > + argInputObjectCircular: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.argInputObjectCircular>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ argInputObjectCircular: $SelectionSet }, Index>, + 'argInputObjectCircular' + > + > + > + date: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.date>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ date: $SelectionSet }, Index>, + 'date' + > + > + > + dateArg: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArg>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArg: $SelectionSet }, Index>, + 'dateArg' + > + > + > + dateArgInputObject: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgInputObject>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgInputObject: $SelectionSet }, Index>, + 'dateArgInputObject' + > + > + > + dateArgList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgList>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgList: $SelectionSet }, Index>, + 'dateArgList' + > + > + > + dateArgNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgNonNull: $SelectionSet }, Index>, + 'dateArgNonNull' + > + > + > + dateArgNonNullList: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullList>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgNonNullList: $SelectionSet }, Index>, + 'dateArgNonNullList' + > + > + > + dateArgNonNullListNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullListNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgNonNullListNonNull: $SelectionSet }, Index>, + 'dateArgNonNullListNonNull' + > + > + > + dateInterface1: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateInterface1>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateInterface1: $SelectionSet }, Index>, + 'dateInterface1' + > + > + > + dateList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateList>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateList: $SelectionSet }, Index>, + 'dateList' + > + > + > + dateListList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListList>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateListList: $SelectionSet }, Index>, + 'dateListList' + > + > + > + dateListNonNull: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateListNonNull: $SelectionSet }, Index>, + 'dateListNonNull' + > + > + > + dateNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateNonNull: $SelectionSet }, Index>, + 'dateNonNull' + > + > + > + dateObject1: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateObject1>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateObject1: $SelectionSet }, Index>, + 'dateObject1' + > + > + > + dateUnion: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateUnion>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateUnion: $SelectionSet }, Index>, + 'dateUnion' + > + > + > + error: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.error>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ error: $SelectionSet }, Index>, + 'error' + > + > + > + id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.id>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ id: $SelectionSet }, Index>, + 'id' + > + > + > + idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.idNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ idNonNull: $SelectionSet }, Index>, + 'idNonNull' + > + > + > + interface: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$interface>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ interface: $SelectionSet }, Index>, + 'interface' + > + > + > + interfaceNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ interfaceNonNull: $SelectionSet }, Index>, + 'interfaceNonNull' + > + > + > + interfaceWithArgs: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceWithArgs>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ interfaceWithArgs: $SelectionSet }, Index>, + 'interfaceWithArgs' + > + > + > + listInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listInt>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ listInt: $SelectionSet }, Index>, + 'listInt' + > + > + > + listIntNonNull: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listIntNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ listIntNonNull: $SelectionSet }, Index>, + 'listIntNonNull' + > + > + > + listListInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListInt>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ listListInt: $SelectionSet }, Index>, + 'listListInt' + > + > + > + listListIntNonNull: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListIntNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ listListIntNonNull: $SelectionSet }, Index>, + 'listListIntNonNull' + > + > + > + lowerCaseUnion: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.lowerCaseUnion>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ lowerCaseUnion: $SelectionSet }, Index>, + 'lowerCaseUnion' + > + > + > + object: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$object>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ object: $SelectionSet }, Index>, + 'object' + > + > + > + objectList: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectList>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectList: $SelectionSet }, Index>, + 'objectList' + > + > + > + objectListNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectListNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectListNonNull: $SelectionSet }, Index>, + 'objectListNonNull' + > + > + > + objectNested: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNested>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectNested: $SelectionSet }, Index>, + 'objectNested' + > + > + > + objectNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectNonNull: $SelectionSet }, Index>, + 'objectNonNull' + > + > + > + objectWithArgs: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectWithArgs>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectWithArgs: $SelectionSet }, Index>, + 'objectWithArgs' + > + > + > + result: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.result>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ result: $SelectionSet }, Index>, + 'result' + > + > + > + resultNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.resultNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ resultNonNull: $SelectionSet }, Index>, + 'resultNonNull' + > + > + > + string: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.$string>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ string: $SelectionSet }, Index>, + 'string' + > + > + > + stringWithArgEnum: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgEnum>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithArgEnum: $SelectionSet }, Index>, + 'stringWithArgEnum' + > + > + > + stringWithArgInputObject: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObject>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithArgInputObject: $SelectionSet }, Index>, + 'stringWithArgInputObject' + > + > + > + stringWithArgInputObjectRequired: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObjectRequired>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithArgInputObjectRequired: $SelectionSet }, Index>, + 'stringWithArgInputObjectRequired' + > + > + > + /** + * The given arguments are reflected back as a JSON string. + */ + stringWithArgs: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgs>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithArgs: $SelectionSet }, Index>, + 'stringWithArgs' + > + > + > + stringWithListArg: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArg>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithListArg: $SelectionSet }, Index>, + 'stringWithListArg' + > + > + > + stringWithListArgRequired: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArgRequired>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithListArgRequired: $SelectionSet }, Index>, + 'stringWithListArgRequired' + > + > + > + stringWithRequiredArg: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithRequiredArg>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithRequiredArg: $SelectionSet }, Index>, + 'stringWithRequiredArg' + > + > + > + unionFooBar: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBar>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionFooBar: $SelectionSet }, Index>, + 'unionFooBar' + > + > + > + unionFooBarNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionFooBarNonNull: $SelectionSet }, Index>, + 'unionFooBarNonNull' + > + > + > + unionFooBarWithArgs: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarWithArgs>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionFooBarWithArgs: $SelectionSet }, Index>, + 'unionFooBarWithArgs' + > + > + > + unionObject: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObject>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionObject: $SelectionSet }, Index>, + 'unionObject' + > + > + > + unionObjectNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObjectNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionObjectNonNull: $SelectionSet }, Index>, + 'unionObjectNonNull' + > + > + > +} + +export interface BuilderMethodsRoot<$Config extends Utils.Config> { + mutation: MutationMethods<$Config> + query: QueryMethods<$Config> +} + +export interface BuilderMethodsRootFn extends Utils.TypeFunction.Fn { + // @ts-expect-error parameter is Untyped. + return: BuilderMethodsRoot +} diff --git a/graffle/modules/MethodsSelect.ts b/graffle/modules/MethodsSelect.ts new file mode 100644 index 000000000..5dddcadb7 --- /dev/null +++ b/graffle/modules/MethodsSelect.ts @@ -0,0 +1,199 @@ +import type * as $Utilities from 'graffle/utilities-for-generated' +import type * as $SelectionSets from './SelectionSets.js' + +// +// +// +// +// +// +// ================================================================================================== +// Select Methods Interface +// ================================================================================================== +// +// +// +// +// +// + +export interface $MethodsSelect { + Mutation: Mutation + Query: Query + Bar: Bar + DateObject1: DateObject1 + DateObject2: DateObject2 + ErrorOne: ErrorOne + ErrorTwo: ErrorTwo + Foo: Foo + Object1: Object1 + Object1ImplementingInterface: Object1ImplementingInterface + Object2ImplementingInterface: Object2ImplementingInterface + ObjectNested: ObjectNested + ObjectUnion: ObjectUnion + lowerCaseObject: lowerCaseObject + lowerCaseObject2: lowerCaseObject2 + DateUnion: DateUnion + FooBarUnion: FooBarUnion + Result: Result + lowerCaseUnion: lowerCaseUnion + DateInterface1: DateInterface1 + Error: Error + Interface: Interface +} + +// +// +// +// +// +// +// ================================================================================================== +// Root +// ================================================================================================== +// +// +// +// +// +// + +export interface Mutation { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Mutation>): $SelectionSet +} + +export interface Query { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Query>): $SelectionSet +} + +// +// +// +// +// +// +// ================================================================================================== +// Object +// ================================================================================================== +// +// +// +// +// +// + +export interface Bar { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Bar>): $SelectionSet +} + +export interface DateObject1 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateObject1>): $SelectionSet +} + +export interface DateObject2 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateObject2>): $SelectionSet +} + +export interface ErrorOne { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ErrorOne>): $SelectionSet +} + +export interface ErrorTwo { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ErrorTwo>): $SelectionSet +} + +export interface Foo { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Foo>): $SelectionSet +} + +export interface Object1 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Object1>): $SelectionSet +} + +export interface Object1ImplementingInterface { + <$SelectionSet>( + selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Object1ImplementingInterface>, + ): $SelectionSet +} + +export interface Object2ImplementingInterface { + <$SelectionSet>( + selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Object2ImplementingInterface>, + ): $SelectionSet +} + +export interface ObjectNested { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ObjectNested>): $SelectionSet +} + +export interface ObjectUnion { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ObjectUnion>): $SelectionSet +} + +export interface lowerCaseObject { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.lowerCaseObject>): $SelectionSet +} + +export interface lowerCaseObject2 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.lowerCaseObject2>): $SelectionSet +} + +// +// +// +// +// +// +// ================================================================================================== +// Union +// ================================================================================================== +// +// +// +// +// +// + +export interface DateUnion { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateUnion>): $SelectionSet +} + +export interface FooBarUnion { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.FooBarUnion>): $SelectionSet +} + +export interface Result { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Result>): $SelectionSet +} + +export interface lowerCaseUnion { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.lowerCaseUnion>): $SelectionSet +} + +// +// +// +// +// +// +// ================================================================================================== +// Interface +// ================================================================================================== +// +// +// +// +// +// + +export interface DateInterface1 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateInterface1>): $SelectionSet +} + +export interface Error { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Error>): $SelectionSet +} + +export interface Interface { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Interface>): $SelectionSet +} diff --git a/graffle/modules/Scalar.ts b/graffle/modules/Scalar.ts new file mode 100644 index 000000000..5c8ae1f9f --- /dev/null +++ b/graffle/modules/Scalar.ts @@ -0,0 +1 @@ +export * from 'graffle/schema/scalars' diff --git a/graffle/modules/SchemaBuildtime.ts b/graffle/modules/SchemaBuildtime.ts new file mode 100644 index 000000000..3702db8f6 --- /dev/null +++ b/graffle/modules/SchemaBuildtime.ts @@ -0,0 +1,359 @@ +import type * as $ from 'graffle/schema' +import type * as $Scalar from './Scalar.js' + +// ------------------------------------------------------------ // +// Root // +// ------------------------------------------------------------ // +export namespace Root { + export type Mutation = $.Output.ObjectMutation<{ + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + idNonNull: $.Field<'idNonNull', $Scalar.ID, null> + }> + + export type Query = $.Output.ObjectQuery<{ + InputObjectNested: $.Field< + 'InputObjectNested', + $.Output.Nullable<$Scalar.ID>, + $.Args<{ + input: $.Input.Field<$.Input.Nullable> + }, true> + > + InputObjectNestedNonNull: $.Field< + 'InputObjectNestedNonNull', + $.Output.Nullable<$Scalar.ID>, + $.Args<{ + input: $.Input.Field + }, false> + > + /** + * Query enum field documentation. + */ + abcEnum: $.Field<'abcEnum', $.Output.Nullable, null> + argInputObjectCircular: $.Field< + 'argInputObjectCircular', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + input: $.Input.Field<$.Input.Nullable> + }, true> + > + date: $.Field<'date', $.Output.Nullable<$Scalar.Date>, null> + dateArg: $.Field< + 'dateArg', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$.Input.Nullable<$Scalar.Date>> + }, true> + > + dateArgInputObject: $.Field< + 'dateArgInputObject', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + input: $.Input.Field<$.Input.Nullable> + }, true> + > + dateArgList: $.Field< + 'dateArgList', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$.Input.Nullable<$.Input.List<$Scalar.Date>>> + }, true> + > + dateArgNonNull: $.Field< + 'dateArgNonNull', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$Scalar.Date> + }, false> + > + dateArgNonNullList: $.Field< + 'dateArgNonNullList', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$.Input.List<$.Input.Nullable<$Scalar.Date>>> + }, false> + > + dateArgNonNullListNonNull: $.Field< + 'dateArgNonNullListNonNull', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$.Input.List<$Scalar.Date>> + }, false> + > + dateInterface1: $.Field<'dateInterface1', $.Output.Nullable, null> + dateList: $.Field<'dateList', $.Output.Nullable<$.Output.List<$Scalar.Date>>, null> + dateListList: $.Field<'dateListList', $.Output.Nullable<$.Output.List<$.Output.List<$Scalar.Date>>>, null> + dateListNonNull: $.Field<'dateListNonNull', $.Output.List<$Scalar.Date>, null> + dateNonNull: $.Field<'dateNonNull', $Scalar.Date, null> + dateObject1: $.Field<'dateObject1', $.Output.Nullable, null> + dateUnion: $.Field<'dateUnion', $.Output.Nullable, null> + error: $.Field< + 'error', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + case: $.Input.Field<$.Input.Nullable<$Scalar.String>> + }, true> + > + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + idNonNull: $.Field<'idNonNull', $Scalar.ID, null> + interface: $.Field<'interface', $.Output.Nullable, null> + interfaceNonNull: $.Field<'interfaceNonNull', Interface.Interface, null> + interfaceWithArgs: $.Field< + 'interfaceWithArgs', + $.Output.Nullable, + $.Args<{ + id: $.Input.Field<$Scalar.ID> + }, false> + > + listInt: $.Field<'listInt', $.Output.Nullable<$.Output.List<$.Output.Nullable<$Scalar.Int>>>, null> + listIntNonNull: $.Field<'listIntNonNull', $.Output.List<$Scalar.Int>, null> + listListInt: $.Field< + 'listListInt', + $.Output.Nullable<$.Output.List<$.Output.Nullable<$.Output.List<$.Output.Nullable<$Scalar.Int>>>>>, + null + > + listListIntNonNull: $.Field<'listListIntNonNull', $.Output.List<$.Output.List<$Scalar.Int>>, null> + lowerCaseUnion: $.Field<'lowerCaseUnion', $.Output.Nullable, null> + object: $.Field<'object', $.Output.Nullable, null> + objectList: $.Field<'objectList', $.Output.Nullable<$.Output.List>, null> + objectListNonNull: $.Field<'objectListNonNull', $.Output.List, null> + objectNested: $.Field<'objectNested', $.Output.Nullable, null> + objectNonNull: $.Field<'objectNonNull', Object.Object1, null> + objectWithArgs: $.Field< + 'objectWithArgs', + $.Output.Nullable, + $.Args<{ + boolean: $.Input.Field<$.Input.Nullable<$Scalar.Boolean>> + float: $.Input.Field<$.Input.Nullable<$Scalar.Float>> + id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> + int: $.Input.Field<$.Input.Nullable<$Scalar.Int>> + string: $.Input.Field<$.Input.Nullable<$Scalar.String>> + }, true> + > + result: $.Field< + 'result', + $.Output.Nullable, + $.Args<{ + case: $.Input.Field + }, false> + > + resultNonNull: $.Field< + 'resultNonNull', + Union.Result, + $.Args<{ + case: $.Input.Field<$.Input.Nullable> + }, true> + > + string: $.Field<'string', $.Output.Nullable<$Scalar.String>, null> + stringWithArgEnum: $.Field< + 'stringWithArgEnum', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + ABCEnum: $.Input.Field<$.Input.Nullable> + }, true> + > + stringWithArgInputObject: $.Field< + 'stringWithArgInputObject', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + input: $.Input.Field<$.Input.Nullable> + }, true> + > + stringWithArgInputObjectRequired: $.Field< + 'stringWithArgInputObjectRequired', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + input: $.Input.Field + }, false> + > + /** + * The given arguments are reflected back as a JSON string. + */ + stringWithArgs: $.Field< + 'stringWithArgs', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + boolean: $.Input.Field<$.Input.Nullable<$Scalar.Boolean>> + float: $.Input.Field<$.Input.Nullable<$Scalar.Float>> + id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> + int: $.Input.Field<$.Input.Nullable<$Scalar.Int>> + string: $.Input.Field<$.Input.Nullable<$Scalar.String>> + }, true> + > + stringWithListArg: $.Field< + 'stringWithListArg', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + ints: $.Input.Field<$.Input.Nullable<$.Input.List<$.Input.Nullable<$Scalar.Int>>>> + }, true> + > + stringWithListArgRequired: $.Field< + 'stringWithListArgRequired', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + ints: $.Input.Field<$.Input.List<$Scalar.Int>> + }, false> + > + stringWithRequiredArg: $.Field< + 'stringWithRequiredArg', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + string: $.Input.Field<$Scalar.String> + }, false> + > + unionFooBar: $.Field<'unionFooBar', $.Output.Nullable, null> + unionFooBarNonNull: $.Field<'unionFooBarNonNull', Union.FooBarUnion, null> + unionFooBarWithArgs: $.Field< + 'unionFooBarWithArgs', + $.Output.Nullable, + $.Args<{ + id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> + }, true> + > + unionObject: $.Field<'unionObject', $.Output.Nullable, null> + unionObjectNonNull: $.Field<'unionObjectNonNull', Object.ObjectUnion, null> + }> +} +// ------------------------------------------------------------ // +// Enum // +// ------------------------------------------------------------ // +export namespace Enum { + /** + * Enum documentation. + * + * Members + * "A" - (DEPRECATED: Enum value A is deprecated.) + * "B" - Enum B member documentation. + * "C" - (DEPRECATED: Enum value C is deprecated.) + */ + export type ABCEnum = $.Enum<'ABCEnum', ['A', 'B', 'C']> + + export type Case = $.Enum<'Case', ['ErrorOne', 'ErrorTwo', 'Object1']> +} +// ------------------------------------------------------------ // +// InputObject // +// ------------------------------------------------------------ // +export namespace InputObject { + export type InputObject = $.InputObject<'InputObject', { + date: $.Input.Field<$.Input.Nullable<$Scalar.Date>> + dateRequired: $.Input.Field<$Scalar.Date> + id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> + idRequired: $.Input.Field<$Scalar.ID> + }, true> + + export type InputObjectCircular = $.InputObject<'InputObjectCircular', { + circular: $.Input.Field<$.Input.Nullable> + date: $.Input.Field<$.Input.Nullable<$Scalar.Date>> + }, true> + + export type InputObjectNested = $.InputObject<'InputObjectNested', { + InputObject: $.Input.Field<$.Input.Nullable> + }, true> + + export type InputObjectNestedNonNull = $.InputObject<'InputObjectNestedNonNull', { + InputObject: $.Input.Field + }, false> +} +// ------------------------------------------------------------ // +// Interface // +// ------------------------------------------------------------ // +export namespace Interface { + export type DateInterface1 = $.Interface<'DateInterface1', { + date1: $.Field<'date1', $.Output.Nullable<$Scalar.Date>, null> + }, [Object.DateObject1]> + + export type Error = $.Interface<'Error', { + message: $.Field<'message', $Scalar.String, null> + }, [Object.ErrorOne, Object.ErrorTwo]> + + export type Interface = $.Interface<'Interface', { + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + }, [Object.Object1ImplementingInterface, Object.Object2ImplementingInterface]> +} +// ------------------------------------------------------------ // +// Object // +// ------------------------------------------------------------ // +export namespace Object { + export type Bar = $.Object$2<'Bar', { + int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> + }> + + export type DateObject1 = $.Object$2<'DateObject1', { + date1: $.Field<'date1', $.Output.Nullable<$Scalar.Date>, null> + }> + + export type DateObject2 = $.Object$2<'DateObject2', { + date2: $.Field<'date2', $.Output.Nullable<$Scalar.Date>, null> + }> + + export type ErrorOne = $.Object$2<'ErrorOne', { + infoId: $.Field<'infoId', $.Output.Nullable<$Scalar.ID>, null> + message: $.Field<'message', $Scalar.String, null> + }> + + export type ErrorTwo = $.Object$2<'ErrorTwo', { + infoInt: $.Field<'infoInt', $.Output.Nullable<$Scalar.Int>, null> + message: $.Field<'message', $Scalar.String, null> + }> + + /** + * Object documentation. + */ + export type Foo = $.Object$2<'Foo', { + /** + * Field documentation. + * + * @deprecated Field a is deprecated. + */ + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + }> + + export type Object1 = $.Object$2<'Object1', { + boolean: $.Field<'boolean', $.Output.Nullable<$Scalar.Boolean>, null> + float: $.Field<'float', $.Output.Nullable<$Scalar.Float>, null> + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> + string: $.Field<'string', $.Output.Nullable<$Scalar.String>, null> + }> + + export type Object1ImplementingInterface = $.Object$2<'Object1ImplementingInterface', { + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> + }> + + export type Object2ImplementingInterface = $.Object$2<'Object2ImplementingInterface', { + boolean: $.Field<'boolean', $.Output.Nullable<$Scalar.Boolean>, null> + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + }> + + export type ObjectNested = $.Object$2<'ObjectNested', { + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + object: $.Field<'object', $.Output.Nullable, null> + }> + + export type ObjectUnion = $.Object$2<'ObjectUnion', { + fooBarUnion: $.Field<'fooBarUnion', $.Output.Nullable, null> + }> + + export type lowerCaseObject = $.Object$2<'lowerCaseObject', { + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + }> + + export type lowerCaseObject2 = $.Object$2<'lowerCaseObject2', { + int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> + }> +} +// ------------------------------------------------------------ // +// Union // +// ------------------------------------------------------------ // +export namespace Union { + export type DateUnion = $.Union<'DateUnion', [Object.DateObject1, Object.DateObject2]> + + /** + * Union documentation. + */ + export type FooBarUnion = $.Union<'FooBarUnion', [Object.Bar, Object.Foo]> + + export type Result = $.Union<'Result', [Object.ErrorOne, Object.ErrorTwo, Object.Object1]> + + export type lowerCaseUnion = $.Union<'lowerCaseUnion', [Object.lowerCaseObject, Object.lowerCaseObject2]> +} diff --git a/graffle/modules/SchemaDrivenDataMap.ts b/graffle/modules/SchemaDrivenDataMap.ts new file mode 100644 index 000000000..144d43e33 --- /dev/null +++ b/graffle/modules/SchemaDrivenDataMap.ts @@ -0,0 +1,689 @@ +import type * as $Utilities from 'graffle/utilities-for-generated' +import * as $Scalar from './Scalar.js' +// +// +// +// +// +// +// ================================================================================================== +// GraphQLScalarType +// ================================================================================================== +// +// +// +// +// +// + +const Boolean = $Scalar.Boolean + +const Date = $Scalar.Date + +const Float = $Scalar.Float + +const ID = $Scalar.ID + +const Int = $Scalar.Int + +const String = $Scalar.String + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLScalarTypeCustom +// ================================================================================================== +// +// +// +// +// +// + +// None of your GraphQLScalarTypeCustoms have custom scalars. + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLEnumType +// ================================================================================================== +// +// +// +// +// +// + +const ABCEnum: $Utilities.SchemaDrivenDataMap.Enum = { + k: 'enum', + n: 'ABCEnum', +} + +const Case: $Utilities.SchemaDrivenDataMap.Enum = { + k: 'enum', + n: 'Case', +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLInputObjectType +// ================================================================================================== +// +// +// +// +// +// + +const InputObject: $Utilities.SchemaDrivenDataMap.InputObject = { + n: 'InputObject', + f: { + date: {}, + dateRequired: {}, + id: {}, + idRequired: {}, + }, +} + +const InputObjectCircular: $Utilities.SchemaDrivenDataMap.InputObject = { + n: 'InputObjectCircular', + f: { + circular: {}, + date: {}, + }, +} + +const InputObjectNested: $Utilities.SchemaDrivenDataMap.InputObject = { + n: 'InputObjectNested', + f: { + InputObject: {}, + }, +} + +const InputObjectNestedNonNull: $Utilities.SchemaDrivenDataMap.InputObject = { + n: 'InputObjectNestedNonNull', + f: { + InputObject: {}, + }, +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLObjectType +// ================================================================================================== +// +// +// +// +// +// + +const Bar: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + int: {}, + }, +} + +const DateObject1: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + date1: {}, + }, +} + +const DateObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + date2: {}, + }, +} + +const ErrorOne: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + infoId: {}, + message: {}, + }, +} + +const ErrorTwo: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + infoInt: {}, + message: {}, + }, +} + +const Foo: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + }, +} + +const Object1: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + boolean: {}, + float: {}, + id: {}, + int: {}, + string: {}, + }, +} + +const Object1ImplementingInterface: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + int: {}, + }, +} + +const Object2ImplementingInterface: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + boolean: {}, + id: {}, + }, +} + +const ObjectNested: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + object: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + }, +} + +const ObjectUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + fooBarUnion: { + // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. + }, + }, +} + +const lowerCaseObject: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + }, +} + +const lowerCaseObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + int: {}, + }, +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLInterfaceType +// ================================================================================================== +// +// +// +// +// +// + +const DateInterface1: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +const Error: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +const Interface: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLUnionType +// ================================================================================================== +// +// +// +// +// +// + +const DateUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +const FooBarUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +const Result: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +const lowerCaseUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLRootType +// ================================================================================================== +// +// +// +// +// +// + +const Mutation: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + idNonNull: {}, + }, +} + +const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + InputObjectNested: { + a: { + input: { + nt: InputObjectNested, + it: [0], + }, + }, + }, + InputObjectNestedNonNull: { + a: { + input: { + nt: InputObjectNestedNonNull, + it: [1], + }, + }, + }, + abcEnum: {}, + argInputObjectCircular: { + a: { + input: { + nt: InputObjectCircular, + it: [0], + }, + }, + }, + date: {}, + dateArg: { + a: { + date: { + nt: Date, + it: [0], + }, + }, + }, + dateArgInputObject: { + a: { + input: { + nt: InputObject, + it: [0], + }, + }, + }, + dateArgList: { + a: { + date: { + nt: Date, + it: [0, [1]], + }, + }, + }, + dateArgNonNull: { + a: { + date: { + nt: Date, + it: [1], + }, + }, + }, + dateArgNonNullList: { + a: { + date: { + nt: Date, + it: [1, [0]], + }, + }, + }, + dateArgNonNullListNonNull: { + a: { + date: { + nt: Date, + it: [1, [1]], + }, + }, + }, + dateInterface1: { + // nt: DateInterface1, <-- Assigned later to avoid potential circular dependency. + }, + dateList: {}, + dateListList: {}, + dateListNonNull: {}, + dateNonNull: {}, + dateObject1: { + // nt: DateObject1, <-- Assigned later to avoid potential circular dependency. + }, + dateUnion: { + // nt: DateUnion, <-- Assigned later to avoid potential circular dependency. + }, + error: { + a: { + case: { + nt: String, + it: [0], + }, + }, + }, + id: {}, + idNonNull: {}, + interface: { + // nt: Interface, <-- Assigned later to avoid potential circular dependency. + }, + interfaceNonNull: { + // nt: Interface, <-- Assigned later to avoid potential circular dependency. + }, + interfaceWithArgs: { + a: { + id: { + nt: ID, + it: [1], + }, + }, + // nt: Interface, <-- Assigned later to avoid potential circular dependency. + }, + listInt: {}, + listIntNonNull: {}, + listListInt: {}, + listListIntNonNull: {}, + lowerCaseUnion: { + // nt: lowerCaseUnion, <-- Assigned later to avoid potential circular dependency. + }, + object: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + objectList: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + objectListNonNull: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + objectNested: { + // nt: ObjectNested, <-- Assigned later to avoid potential circular dependency. + }, + objectNonNull: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + objectWithArgs: { + a: { + boolean: { + nt: Boolean, + it: [0], + }, + float: { + nt: Float, + it: [0], + }, + id: { + nt: ID, + it: [0], + }, + int: { + nt: Int, + it: [0], + }, + string: { + nt: String, + it: [0], + }, + }, + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + result: { + a: { + case: { + nt: Case, + it: [1], + }, + }, + // nt: Result, <-- Assigned later to avoid potential circular dependency. + }, + resultNonNull: { + a: { + case: { + nt: Case, + it: [0], + }, + }, + // nt: Result, <-- Assigned later to avoid potential circular dependency. + }, + string: {}, + stringWithArgEnum: { + a: { + ABCEnum: { + nt: ABCEnum, + it: [0], + }, + }, + }, + stringWithArgInputObject: { + a: { + input: { + nt: InputObject, + it: [0], + }, + }, + }, + stringWithArgInputObjectRequired: { + a: { + input: { + nt: InputObject, + it: [1], + }, + }, + }, + stringWithArgs: { + a: { + boolean: { + nt: Boolean, + it: [0], + }, + float: { + nt: Float, + it: [0], + }, + id: { + nt: ID, + it: [0], + }, + int: { + nt: Int, + it: [0], + }, + string: { + nt: String, + it: [0], + }, + }, + }, + stringWithListArg: { + a: { + ints: { + nt: Int, + it: [0, [0]], + }, + }, + }, + stringWithListArgRequired: { + a: { + ints: { + nt: Int, + it: [1, [1]], + }, + }, + }, + stringWithRequiredArg: { + a: { + string: { + nt: String, + it: [1], + }, + }, + }, + unionFooBar: { + // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. + }, + unionFooBarNonNull: { + // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. + }, + unionFooBarWithArgs: { + a: { + id: { + nt: ID, + it: [0], + }, + }, + // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. + }, + unionObject: { + // nt: ObjectUnion, <-- Assigned later to avoid potential circular dependency. + }, + unionObjectNonNull: { + // nt: ObjectUnion, <-- Assigned later to avoid potential circular dependency. + }, + }, +} + +// +// +// +// +// +// +// ================================================================================================== +// Reference Assignments +// (avoids circular assignment issues) +// ================================================================================================== +// +// +// +// +// +// + +ObjectNested.f['object']!.nt = Object1 +ObjectUnion.f['fooBarUnion']!.nt = FooBarUnion +Query.f['dateInterface1']!.nt = DateInterface1 +Query.f['dateObject1']!.nt = DateObject1 +Query.f['dateUnion']!.nt = DateUnion +Query.f['interface']!.nt = Interface +Query.f['interfaceNonNull']!.nt = Interface +Query.f['interfaceWithArgs']!.nt = Interface +Query.f['lowerCaseUnion']!.nt = lowerCaseUnion +Query.f['object']!.nt = Object1 +Query.f['objectList']!.nt = Object1 +Query.f['objectListNonNull']!.nt = Object1 +Query.f['objectNested']!.nt = ObjectNested +Query.f['objectNonNull']!.nt = Object1 +Query.f['objectWithArgs']!.nt = Object1 +Query.f['result']!.nt = Result +Query.f['resultNonNull']!.nt = Result +Query.f['unionFooBar']!.nt = FooBarUnion +Query.f['unionFooBarNonNull']!.nt = FooBarUnion +Query.f['unionFooBarWithArgs']!.nt = FooBarUnion +Query.f['unionObject']!.nt = ObjectUnion +Query.f['unionObjectNonNull']!.nt = ObjectUnion + +// +// +// +// +// +// +// ================================================================================================== +// Index +// ================================================================================================== +// +// +// +// +// +// + +const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { + roots: { + Mutation, + Query, + }, + directives: {}, + types: { + Boolean, + Date, + Float, + ID, + Int, + String, + ABCEnum, + Case, + InputObject, + InputObjectCircular, + InputObjectNested, + InputObjectNestedNonNull, + Bar, + DateObject1, + DateObject2, + ErrorOne, + ErrorTwo, + Foo, + Object1, + Object1ImplementingInterface, + Object2ImplementingInterface, + ObjectNested, + ObjectUnion, + lowerCaseObject, + lowerCaseObject2, + DateInterface1, + Error, + Interface, + DateUnion, + FooBarUnion, + Result, + lowerCaseUnion, + Mutation, + Query, + }, +} + +export { $schemaDrivenDataMap as schemaDrivenDataMap } diff --git a/graffle/modules/SchemaIndex.ts b/graffle/modules/SchemaIndex.ts new file mode 100644 index 000000000..fff1a1977 --- /dev/null +++ b/graffle/modules/SchemaIndex.ts @@ -0,0 +1,69 @@ +/* eslint-disable */ +import type * as Utilities from 'graffle/utilities-for-generated' +import type * as Data from './Data.js' +import type * as MethodsRoot from './MethodsRoot.js' +import type * as Schema from './SchemaBuildtime.js' + +export interface Index { + name: Data.Name + RootTypesPresent: ['Mutation', 'Query'] + RootUnion: Schema.Root.Mutation | Schema.Root.Query + Root: { + Query: Schema.Root.Query + Mutation: Schema.Root.Mutation + Subscription: null + } + allTypes: { + Mutation: Schema.Root.Mutation + Query: Schema.Root.Query + ABCEnum: Schema.Enum.ABCEnum + Case: Schema.Enum.Case + Bar: Schema.Object.Bar + DateObject1: Schema.Object.DateObject1 + DateObject2: Schema.Object.DateObject2 + ErrorOne: Schema.Object.ErrorOne + ErrorTwo: Schema.Object.ErrorTwo + Foo: Schema.Object.Foo + Object1: Schema.Object.Object1 + Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface + Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface + ObjectNested: Schema.Object.ObjectNested + ObjectUnion: Schema.Object.ObjectUnion + lowerCaseObject: Schema.Object.lowerCaseObject + lowerCaseObject2: Schema.Object.lowerCaseObject2 + DateUnion: Schema.Union.DateUnion + FooBarUnion: Schema.Union.FooBarUnion + Result: Schema.Union.Result + lowerCaseUnion: Schema.Union.lowerCaseUnion + DateInterface1: Schema.Interface.DateInterface1 + Error: Schema.Interface.Error + Interface: Schema.Interface.Interface + } + objects: { + Bar: Schema.Object.Bar + DateObject1: Schema.Object.DateObject1 + DateObject2: Schema.Object.DateObject2 + ErrorOne: Schema.Object.ErrorOne + ErrorTwo: Schema.Object.ErrorTwo + Foo: Schema.Object.Foo + Object1: Schema.Object.Object1 + Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface + Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface + ObjectNested: Schema.Object.ObjectNested + ObjectUnion: Schema.Object.ObjectUnion + lowerCaseObject: Schema.Object.lowerCaseObject + lowerCaseObject2: Schema.Object.lowerCaseObject2 + } + unions: { + DateUnion: Schema.Union.DateUnion + FooBarUnion: Schema.Union.FooBarUnion + Result: Schema.Union.Result + lowerCaseUnion: Schema.Union.lowerCaseUnion + } + interfaces: { + DateInterface1: Schema.Interface.DateInterface1 + Error: Schema.Interface.Error + Interface: Schema.Interface.Interface + } + customScalars: Utilities.SchemaIndexBase['customScalars'] +} diff --git a/graffle/modules/Select.ts b/graffle/modules/Select.ts new file mode 100644 index 000000000..9b9820d4e --- /dev/null +++ b/graffle/modules/Select.ts @@ -0,0 +1,149 @@ +import type { InferResult } from 'graffle/schema' +import * as Data from './Data.js' +import type { Index } from './SchemaIndex.js' +import type * as SelectionSets from './SelectionSets.js' + +// +// +// +// +// +// +// ================================================================================================== +// Runtime +// ================================================================================================== +// +// +// +// +// +// +import { createSelect } from 'graffle/client' +export const Select = createSelect(Data.Name) + +// +// +// +// +// +// +// ================================================================================================== +// Buildtime +// ================================================================================================== +// +// +// +// +// +// + +export namespace Select { + // Root Types + // ---------- + export type Mutation<$SelectionSet extends SelectionSets.Mutation> = InferResult.Root< + $SelectionSet, + Index, + 'Mutation' + > + export type Query<$SelectionSet extends SelectionSets.Query> = InferResult.Root<$SelectionSet, Index, 'Query'> + // Object Types + // ------------ + export type Bar<$SelectionSet extends SelectionSets.Bar> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['Bar'] + > + export type DateObject1<$SelectionSet extends SelectionSets.DateObject1> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['DateObject1'] + > + export type DateObject2<$SelectionSet extends SelectionSets.DateObject2> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['DateObject2'] + > + export type ErrorOne<$SelectionSet extends SelectionSets.ErrorOne> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['ErrorOne'] + > + export type ErrorTwo<$SelectionSet extends SelectionSets.ErrorTwo> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['ErrorTwo'] + > + export type Foo<$SelectionSet extends SelectionSets.Foo> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['Foo'] + > + export type Object1<$SelectionSet extends SelectionSets.Object1> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['Object1'] + > + export type Object1ImplementingInterface<$SelectionSet extends SelectionSets.Object1ImplementingInterface> = + InferResult.Object<$SelectionSet, Index, Index['allTypes']['Object1ImplementingInterface']> + export type Object2ImplementingInterface<$SelectionSet extends SelectionSets.Object2ImplementingInterface> = + InferResult.Object<$SelectionSet, Index, Index['allTypes']['Object2ImplementingInterface']> + export type ObjectNested<$SelectionSet extends SelectionSets.ObjectNested> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['ObjectNested'] + > + export type ObjectUnion<$SelectionSet extends SelectionSets.ObjectUnion> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['ObjectUnion'] + > + export type lowerCaseObject<$SelectionSet extends SelectionSets.lowerCaseObject> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['lowerCaseObject'] + > + export type lowerCaseObject2<$SelectionSet extends SelectionSets.lowerCaseObject2> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['lowerCaseObject2'] + > + // Union Types + // ----------- + export type DateUnion<$SelectionSet extends SelectionSets.DateUnion> = InferResult.Union< + $SelectionSet, + Index, + Index['allTypes']['DateUnion'] + > + export type FooBarUnion<$SelectionSet extends SelectionSets.FooBarUnion> = InferResult.Union< + $SelectionSet, + Index, + Index['allTypes']['FooBarUnion'] + > + export type Result<$SelectionSet extends SelectionSets.Result> = InferResult.Union< + $SelectionSet, + Index, + Index['allTypes']['Result'] + > + export type lowerCaseUnion<$SelectionSet extends SelectionSets.lowerCaseUnion> = InferResult.Union< + $SelectionSet, + Index, + Index['allTypes']['lowerCaseUnion'] + > + // Interface Types + // --------------- + export type DateInterface1<$SelectionSet extends SelectionSets.DateInterface1> = InferResult.Interface< + $SelectionSet, + Index, + Index['allTypes']['DateInterface1'] + > + export type Error<$SelectionSet extends SelectionSets.Error> = InferResult.Interface< + $SelectionSet, + Index, + Index['allTypes']['Error'] + > + export type Interface<$SelectionSet extends SelectionSets.Interface> = InferResult.Interface< + $SelectionSet, + Index, + Index['allTypes']['Interface'] + > +} diff --git a/graffle/modules/SelectionSets.ts b/graffle/modules/SelectionSets.ts new file mode 100644 index 000000000..68d1599a5 --- /dev/null +++ b/graffle/modules/SelectionSets.ts @@ -0,0 +1,2102 @@ +import type { Select as $Select } from 'graffle/schema' +import type * as $Utilities from 'graffle/utilities-for-generated' + +// +// +// +// +// +// +// ================================================================================================== +// Document +// ================================================================================================== +// +// +// +// +// +// + +// Prefix with $ because this is not a schema type. A user could have a schema type named "Document" that this would conflict with. +export interface $Document { + query?: Record + mutation?: Record +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLObjectType Types +// ================================================================================================== +// +// +// +// +// +// + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Mutation +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Mutation { + /** + * Select the `id` field on the `Mutation` object. Its type is `ID` (a `Scalar`). + */ + id?: Mutation.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `idNonNull` field on the `Mutation` object. Its type is `ID` (a `Scalar`). + */ + idNonNull?: Mutation.idNonNull$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Mutation$FragmentInline | Mutation$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Mutation$FragmentInline extends Mutation, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Mutation { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `idNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type idNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type idNonNull = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Query +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Query { + /** + * Select the `InputObjectNested` field on the `Query` object. Its type is `ID` (a `Scalar`). + */ + InputObjectNested?: Query.InputObjectNested$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `InputObjectNestedNonNull` field on the `Query` object. Its type is `ID` (a `Scalar`). + */ + InputObjectNestedNonNull?: + | Query.InputObjectNestedNonNull + | $Select.SelectAlias.SelectAlias + /** + * Select the `abcEnum` field on the `Query` object. Its type is Enum. + */ + abcEnum?: Query.abcEnum$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `argInputObjectCircular` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + argInputObjectCircular?: + | Query.argInputObjectCircular$Expanded + | $Select.SelectAlias.SelectAlias + /** + * Select the `date` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + date?: Query.date$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArg` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArg?: Query.dateArg$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgInputObject` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgInputObject?: Query.dateArgInputObject$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgList` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgList?: Query.dateArgList$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgNonNull?: Query.dateArgNonNull | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgNonNullList` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgNonNullList?: Query.dateArgNonNullList | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgNonNullListNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgNonNullListNonNull?: + | Query.dateArgNonNullListNonNull + | $Select.SelectAlias.SelectAlias + /** + * Select the `dateInterface1` field on the `Query` object. Its type is Interface. + */ + dateInterface1?: Query.dateInterface1$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateList` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateList?: Query.dateList$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateListList` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateListList?: Query.dateListList$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateListNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateListNonNull?: Query.dateListNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateNonNull?: Query.dateNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateObject1` field on the `Query` object. Its type is Object. + */ + dateObject1?: Query.dateObject1$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateUnion` field on the `Query` object. Its type is Union. + */ + dateUnion?: Query.dateUnion$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `error` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + error?: Query.error$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `id` field on the `Query` object. Its type is `ID` (a `Scalar`). + */ + id?: Query.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `idNonNull` field on the `Query` object. Its type is `ID` (a `Scalar`). + */ + idNonNull?: Query.idNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `interface` field on the `Query` object. Its type is Interface. + */ + interface?: Query.$interface$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `interfaceNonNull` field on the `Query` object. Its type is Interface. + */ + interfaceNonNull?: Query.interfaceNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `interfaceWithArgs` field on the `Query` object. Its type is Interface. + */ + interfaceWithArgs?: Query.interfaceWithArgs | $Select.SelectAlias.SelectAlias + /** + * Select the `listInt` field on the `Query` object. Its type is `Int` (a `Scalar`). + */ + listInt?: Query.listInt$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `listIntNonNull` field on the `Query` object. Its type is `Int` (a `Scalar`). + */ + listIntNonNull?: Query.listIntNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `listListInt` field on the `Query` object. Its type is `Int` (a `Scalar`). + */ + listListInt?: Query.listListInt$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `listListIntNonNull` field on the `Query` object. Its type is `Int` (a `Scalar`). + */ + listListIntNonNull?: Query.listListIntNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `lowerCaseUnion` field on the `Query` object. Its type is Union. + */ + lowerCaseUnion?: Query.lowerCaseUnion$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `object` field on the `Query` object. Its type is Object. + */ + object?: Query.$object$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectList` field on the `Query` object. Its type is Object. + */ + objectList?: Query.objectList$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectListNonNull` field on the `Query` object. Its type is Object. + */ + objectListNonNull?: Query.objectListNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectNested` field on the `Query` object. Its type is Object. + */ + objectNested?: Query.objectNested$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectNonNull` field on the `Query` object. Its type is Object. + */ + objectNonNull?: Query.objectNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectWithArgs` field on the `Query` object. Its type is Object. + */ + objectWithArgs?: Query.objectWithArgs$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `result` field on the `Query` object. Its type is Union. + */ + result?: Query.result | $Select.SelectAlias.SelectAlias + /** + * Select the `resultNonNull` field on the `Query` object. Its type is Union. + */ + resultNonNull?: Query.resultNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `string` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + string?: Query.$string$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithArgEnum` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithArgEnum?: Query.stringWithArgEnum$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithArgInputObject` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithArgInputObject?: + | Query.stringWithArgInputObject$Expanded + | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithArgInputObjectRequired` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithArgInputObjectRequired?: + | Query.stringWithArgInputObjectRequired + | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithArgs` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithArgs?: Query.stringWithArgs$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithListArg` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithListArg?: Query.stringWithListArg$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithListArgRequired` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithListArgRequired?: + | Query.stringWithListArgRequired + | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithRequiredArg` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithRequiredArg?: Query.stringWithRequiredArg | $Select.SelectAlias.SelectAlias + /** + * Select the `unionFooBar` field on the `Query` object. Its type is Union. + */ + unionFooBar?: Query.unionFooBar$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `unionFooBarNonNull` field on the `Query` object. Its type is Union. + */ + unionFooBarNonNull?: Query.unionFooBarNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `unionFooBarWithArgs` field on the `Query` object. Its type is Union. + */ + unionFooBarWithArgs?: Query.unionFooBarWithArgs$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `unionObject` field on the `Query` object. Its type is Object. + */ + unionObject?: Query.unionObject$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `unionObjectNonNull` field on the `Query` object. Its type is Object. + */ + unionObjectNonNull?: Query.unionObjectNonNull$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Query$FragmentInline | Query$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Query$FragmentInline extends Query, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Query { + export type InputObjectNested$SelectionSetArguments = { + input?: _RefDefs._InputObjectNested | undefined | null + } + export type InputObjectNested$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `InputObjectNested` field. + * No arguments are required so you may omit this. + */ + $?: InputObjectNested$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `InputObjectNested` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type InputObjectNested$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | InputObjectNested$SelectionSet + > + + export type InputObjectNested = $Select.Indicator.Indicator | InputObjectNested$SelectionSet + + export type InputObjectNestedNonNull$SelectionSetArguments = { + input: _RefDefs._InputObjectNestedNonNull + } + export interface InputObjectNestedNonNull extends $Select.Bases.Base { + /** + * Arguments for `InputObjectNestedNonNull` field. + * All arguments are required so you must include this. + */ + $: InputObjectNestedNonNull$SelectionSetArguments + } + + /** + * This is the "expanded" version of the `abcEnum` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type abcEnum$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type abcEnum = $Select.Indicator.NoArgsIndicator + + export type argInputObjectCircular$SelectionSetArguments = { + input?: _RefDefs._InputObjectCircular | undefined | null + } + export type argInputObjectCircular$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `argInputObjectCircular` field. + * No arguments are required so you may omit this. + */ + $?: argInputObjectCircular$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `argInputObjectCircular` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type argInputObjectCircular$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | argInputObjectCircular$SelectionSet + > + + export type argInputObjectCircular = $Select.Indicator.Indicator | argInputObjectCircular$SelectionSet + + /** + * This is the "expanded" version of the `date` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type date$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type date = $Select.Indicator.NoArgsIndicator + + export type dateArg$SelectionSetArguments = { + date?: undefined | undefined | null + } + export type dateArg$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `dateArg` field. + * No arguments are required so you may omit this. + */ + $?: dateArg$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `dateArg` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateArg$Expanded = $Utilities.UnionExpanded<$Select.Indicator.Indicator | dateArg$SelectionSet> + + export type dateArg = $Select.Indicator.Indicator | dateArg$SelectionSet + + export type dateArgInputObject$SelectionSetArguments = { + input?: _RefDefs._InputObject | undefined | null + } + export type dateArgInputObject$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `dateArgInputObject` field. + * No arguments are required so you may omit this. + */ + $?: dateArgInputObject$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `dateArgInputObject` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateArgInputObject$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | dateArgInputObject$SelectionSet + > + + export type dateArgInputObject = $Select.Indicator.Indicator | dateArgInputObject$SelectionSet + + export type dateArgList$SelectionSetArguments = { + date?: Array | undefined | null + } + export type dateArgList$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `dateArgList` field. + * No arguments are required so you may omit this. + */ + $?: dateArgList$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `dateArgList` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateArgList$Expanded = $Utilities.UnionExpanded<$Select.Indicator.Indicator | dateArgList$SelectionSet> + + export type dateArgList = $Select.Indicator.Indicator | dateArgList$SelectionSet + + export type dateArgNonNull$SelectionSetArguments = { + date: undefined + } + export interface dateArgNonNull extends $Select.Bases.Base { + /** + * Arguments for `dateArgNonNull` field. + * All arguments are required so you must include this. + */ + $: dateArgNonNull$SelectionSetArguments + } + + export type dateArgNonNullList$SelectionSetArguments = { + date: Array + } + export interface dateArgNonNullList extends $Select.Bases.Base { + /** + * Arguments for `dateArgNonNullList` field. + * All arguments are required so you must include this. + */ + $: dateArgNonNullList$SelectionSetArguments + } + + export type dateArgNonNullListNonNull$SelectionSetArguments = { + date: Array + } + export interface dateArgNonNullListNonNull extends $Select.Bases.Base { + /** + * Arguments for `dateArgNonNullListNonNull` field. + * All arguments are required so you must include this. + */ + $: dateArgNonNullListNonNull$SelectionSetArguments + } + + export interface dateInterface1 extends _RefDefs._DateInterface1 {} + export type dateInterface1$Expanded = dateInterface1 + /** + * This is the "expanded" version of the `dateList` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateList$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type dateList = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `dateListList` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateListList$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type dateListList = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `dateListNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateListNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type dateListNonNull = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `dateNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type dateNonNull = $Select.Indicator.NoArgsIndicator + + export interface dateObject1 extends _RefDefs._DateObject1 {} + export type dateObject1$Expanded = dateObject1 + export interface dateUnion extends _RefDefs._DateUnion {} + export type dateUnion$Expanded = dateUnion + export type error$SelectionSetArguments = { + case?: string | undefined | null + } + export type error$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `error` field. + * No arguments are required so you may omit this. + */ + $?: error$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `error` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type error$Expanded = $Utilities.UnionExpanded<$Select.Indicator.Indicator | error$SelectionSet> + + export type error = $Select.Indicator.Indicator | error$SelectionSet + + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `idNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type idNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type idNonNull = $Select.Indicator.NoArgsIndicator + + export interface $interface extends _RefDefs._Interface {} + export type $interface$Expanded = $interface + export interface interfaceNonNull extends _RefDefs._Interface {} + export type interfaceNonNull$Expanded = interfaceNonNull + export interface interfaceWithArgs extends _RefDefs._Interface { + /** + * Arguments for `interfaceWithArgs` field. + * All arguments are required so you must include this. + */ + $: { + id: string + } + } + export type interfaceWithArgs$Expanded = interfaceWithArgs + /** + * This is the "expanded" version of the `listInt` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type listInt$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type listInt = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `listIntNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type listIntNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type listIntNonNull = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `listListInt` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type listListInt$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type listListInt = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `listListIntNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type listListIntNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type listListIntNonNull = $Select.Indicator.NoArgsIndicator + + export interface lowerCaseUnion extends _RefDefs._lowerCaseUnion {} + export type lowerCaseUnion$Expanded = lowerCaseUnion + export interface $object extends _RefDefs._Object1 {} + export type $object$Expanded = $object + export interface objectList extends _RefDefs._Object1 {} + export type objectList$Expanded = objectList + export interface objectListNonNull extends _RefDefs._Object1 {} + export type objectListNonNull$Expanded = objectListNonNull + export interface objectNested extends _RefDefs._ObjectNested {} + export type objectNested$Expanded = objectNested + export interface objectNonNull extends _RefDefs._Object1 {} + export type objectNonNull$Expanded = objectNonNull + export interface objectWithArgs extends _RefDefs._Object1 { + /** + * Arguments for `objectWithArgs` field. + * No arguments are required so you may omit this. + */ + $?: { + boolean?: boolean | undefined | null + float?: number | undefined | null + id?: string | undefined | null + int?: number | undefined | null + string?: string | undefined | null + } + } + export type objectWithArgs$Expanded = objectWithArgs + export interface result extends _RefDefs._Result { + /** + * Arguments for `result` field. + * All arguments are required so you must include this. + */ + $: { + $case: _RefDefs._Case + } + } + export type result$Expanded = result + export interface resultNonNull extends _RefDefs._Result { + /** + * Arguments for `resultNonNull` field. + * No arguments are required so you may omit this. + */ + $?: { + $case?: _RefDefs._Case | undefined | null + } + } + export type resultNonNull$Expanded = resultNonNull + /** + * This is the "expanded" version of the `$string` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type $string$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type $string = $Select.Indicator.NoArgsIndicator + + export type stringWithArgEnum$SelectionSetArguments = { + $ABCEnum?: _RefDefs._ABCEnum | undefined | null + } + export type stringWithArgEnum$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `stringWithArgEnum` field. + * No arguments are required so you may omit this. + */ + $?: stringWithArgEnum$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `stringWithArgEnum` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type stringWithArgEnum$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | stringWithArgEnum$SelectionSet + > + + export type stringWithArgEnum = $Select.Indicator.Indicator | stringWithArgEnum$SelectionSet + + export type stringWithArgInputObject$SelectionSetArguments = { + input?: _RefDefs._InputObject | undefined | null + } + export type stringWithArgInputObject$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `stringWithArgInputObject` field. + * No arguments are required so you may omit this. + */ + $?: stringWithArgInputObject$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `stringWithArgInputObject` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type stringWithArgInputObject$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | stringWithArgInputObject$SelectionSet + > + + export type stringWithArgInputObject = $Select.Indicator.Indicator | stringWithArgInputObject$SelectionSet + + export type stringWithArgInputObjectRequired$SelectionSetArguments = { + input: _RefDefs._InputObject + } + export interface stringWithArgInputObjectRequired extends $Select.Bases.Base { + /** + * Arguments for `stringWithArgInputObjectRequired` field. + * All arguments are required so you must include this. + */ + $: stringWithArgInputObjectRequired$SelectionSetArguments + } + + export type stringWithArgs$SelectionSetArguments = { + boolean?: boolean | undefined | null + float?: number | undefined | null + id?: string | undefined | null + int?: number | undefined | null + string?: string | undefined | null + } + export type stringWithArgs$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `stringWithArgs` field. + * No arguments are required so you may omit this. + */ + $?: stringWithArgs$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `stringWithArgs` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type stringWithArgs$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | stringWithArgs$SelectionSet + > + + export type stringWithArgs = $Select.Indicator.Indicator | stringWithArgs$SelectionSet + + export type stringWithListArg$SelectionSetArguments = { + ints?: Array | undefined | null + } + export type stringWithListArg$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `stringWithListArg` field. + * No arguments are required so you may omit this. + */ + $?: stringWithListArg$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `stringWithListArg` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type stringWithListArg$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | stringWithListArg$SelectionSet + > + + export type stringWithListArg = $Select.Indicator.Indicator | stringWithListArg$SelectionSet + + export type stringWithListArgRequired$SelectionSetArguments = { + ints: Array + } + export interface stringWithListArgRequired extends $Select.Bases.Base { + /** + * Arguments for `stringWithListArgRequired` field. + * All arguments are required so you must include this. + */ + $: stringWithListArgRequired$SelectionSetArguments + } + + export type stringWithRequiredArg$SelectionSetArguments = { + string: string + } + export interface stringWithRequiredArg extends $Select.Bases.Base { + /** + * Arguments for `stringWithRequiredArg` field. + * All arguments are required so you must include this. + */ + $: stringWithRequiredArg$SelectionSetArguments + } + + export interface unionFooBar extends _RefDefs._FooBarUnion {} + export type unionFooBar$Expanded = unionFooBar + export interface unionFooBarNonNull extends _RefDefs._FooBarUnion {} + export type unionFooBarNonNull$Expanded = unionFooBarNonNull + export interface unionFooBarWithArgs extends _RefDefs._FooBarUnion { + /** + * Arguments for `unionFooBarWithArgs` field. + * No arguments are required so you may omit this. + */ + $?: { + id?: string | undefined | null + } + } + export type unionFooBarWithArgs$Expanded = unionFooBarWithArgs + export interface unionObject extends _RefDefs._ObjectUnion {} + export type unionObject$Expanded = unionObject + export interface unionObjectNonNull extends _RefDefs._ObjectUnion {} + export type unionObjectNonNull$Expanded = unionObjectNonNull +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLEnumType Types +// ================================================================================================== +// +// +// +// +// +// + +/** + * Enum documentation. + * + * Members + * "A" - (DEPRECATED: Enum value A is deprecated.) + * "B" - Enum B member documentation. + * "C" - (DEPRECATED: Enum value C is deprecated.) + */ +export type ABCEnum = 'A' | 'B' | 'C' + +export type Case = 'ErrorOne' | 'ErrorTwo' | 'Object1' + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLInputObjectType Types +// ================================================================================================== +// +// +// +// +// +// + +export interface InputObject { + date?: undefined | undefined | null + dateRequired: undefined + id?: string | undefined | null + idRequired: string +} + +export interface InputObjectCircular { + circular?: _RefDefs._InputObjectCircular | undefined | null + date?: undefined | undefined | null +} + +export interface InputObjectNested { + InputObject?: _RefDefs._InputObject | undefined | null +} + +export interface InputObjectNestedNonNull { + InputObject: _RefDefs._InputObject +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLInterfaceType Types +// ================================================================================================== +// +// +// +// +// +// + +// -------------- +// Interface Type DateInterface1 +// -------------- + +export interface DateInterface1 extends $Select.Bases.ObjectLike { + date1?: DateInterface1.date1 + ___on_DateObject1?: DateObject1 + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: DateInterface1$FragmentInline | DateInterface1$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a interface type and thus polymorphic, + * the name is one of the implementor type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface DateInterface1$FragmentInline + extends DateInterface1, $Select.Directive.$Groups.InlineFragment.Fields +{} + +export namespace DateInterface1 { + /** + * This is the "expanded" version of the `date1` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type date1$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type date1 = $Select.Indicator.NoArgsIndicator +} + +// -------------- +// Interface Type Error +// -------------- + +export interface Error extends $Select.Bases.ObjectLike { + message?: Error.message + ___on_ErrorOne?: ErrorOne + ___on_ErrorTwo?: ErrorTwo + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Error$FragmentInline | Error$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a interface type and thus polymorphic, + * the name is one of the implementor type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Error$FragmentInline extends Error, $Select.Directive.$Groups.InlineFragment.Fields {} + +export namespace Error { + /** + * This is the "expanded" version of the `message` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type message$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type message = $Select.Indicator.NoArgsIndicator +} + +// -------------- +// Interface Type Interface +// -------------- + +export interface Interface extends $Select.Bases.ObjectLike { + id?: Interface.id + ___on_Object1ImplementingInterface?: Object1ImplementingInterface + ___on_Object2ImplementingInterface?: Object2ImplementingInterface + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Interface$FragmentInline | Interface$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a interface type and thus polymorphic, + * the name is one of the implementor type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Interface$FragmentInline extends Interface, $Select.Directive.$Groups.InlineFragment.Fields {} + +export namespace Interface { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLObjectType Types +// ================================================================================================== +// +// +// +// +// +// + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Bar +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Bar extends $Select.Bases.ObjectLike { + /** + * Select the `int` field on the `Bar` object. Its type is `Int` (a `Scalar`). + */ + int?: Bar.int$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Bar$FragmentInline | Bar$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Bar$FragmentInline extends Bar, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Bar { + /** + * This is the "expanded" version of the `int` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type int = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// DateObject1 +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface DateObject1 extends $Select.Bases.ObjectLike { + /** + * Select the `date1` field on the `DateObject1` object. Its type is `Date` (a `Scalar`). + */ + date1?: DateObject1.date1$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: DateObject1$FragmentInline | DateObject1$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface DateObject1$FragmentInline extends DateObject1, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace DateObject1 { + /** + * This is the "expanded" version of the `date1` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type date1$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type date1 = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// DateObject2 +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface DateObject2 extends $Select.Bases.ObjectLike { + /** + * Select the `date2` field on the `DateObject2` object. Its type is `Date` (a `Scalar`). + */ + date2?: DateObject2.date2$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: DateObject2$FragmentInline | DateObject2$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface DateObject2$FragmentInline extends DateObject2, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace DateObject2 { + /** + * This is the "expanded" version of the `date2` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type date2$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type date2 = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// ErrorOne +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface ErrorOne extends $Select.Bases.ObjectLike { + /** + * Select the `infoId` field on the `ErrorOne` object. Its type is `ID` (a `Scalar`). + */ + infoId?: ErrorOne.infoId$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `message` field on the `ErrorOne` object. Its type is `String` (a `Scalar`). + */ + message?: ErrorOne.message$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: ErrorOne$FragmentInline | ErrorOne$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface ErrorOne$FragmentInline extends ErrorOne, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace ErrorOne { + /** + * This is the "expanded" version of the `infoId` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type infoId$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type infoId = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `message` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type message$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type message = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// ErrorTwo +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface ErrorTwo extends $Select.Bases.ObjectLike { + /** + * Select the `infoInt` field on the `ErrorTwo` object. Its type is `Int` (a `Scalar`). + */ + infoInt?: ErrorTwo.infoInt$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `message` field on the `ErrorTwo` object. Its type is `String` (a `Scalar`). + */ + message?: ErrorTwo.message$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: ErrorTwo$FragmentInline | ErrorTwo$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface ErrorTwo$FragmentInline extends ErrorTwo, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace ErrorTwo { + /** + * This is the "expanded" version of the `infoInt` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type infoInt$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type infoInt = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `message` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type message$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type message = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Foo +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +/** + * Object documentation. + */ +export interface Foo extends $Select.Bases.ObjectLike { + /** + * Select the `id` field on the `Foo` object. Its type is `ID` (a `Scalar`). + */ + id?: Foo.id$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Foo$FragmentInline | Foo$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Foo$FragmentInline extends Foo, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Foo { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Object1 +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Object1 extends $Select.Bases.ObjectLike { + /** + * Select the `boolean` field on the `Object1` object. Its type is `Boolean` (a `Scalar`). + */ + boolean?: Object1.$boolean$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `float` field on the `Object1` object. Its type is `Float` (a `Scalar`). + */ + float?: Object1.float$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `id` field on the `Object1` object. Its type is `ID` (a `Scalar`). + */ + id?: Object1.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `int` field on the `Object1` object. Its type is `Int` (a `Scalar`). + */ + int?: Object1.int$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `string` field on the `Object1` object. Its type is `String` (a `Scalar`). + */ + string?: Object1.$string$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Object1$FragmentInline | Object1$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Object1$FragmentInline extends Object1, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Object1 { + /** + * This is the "expanded" version of the `$boolean` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type $boolean$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type $boolean = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `float` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type float$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type float = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `int` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type int = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `$string` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type $string$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type $string = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Object1ImplementingInterface +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Object1ImplementingInterface extends $Select.Bases.ObjectLike { + /** + * Select the `id` field on the `Object1ImplementingInterface` object. Its type is `ID` (a `Scalar`). + */ + id?: Object1ImplementingInterface.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `int` field on the `Object1ImplementingInterface` object. Its type is `Int` (a `Scalar`). + */ + int?: Object1ImplementingInterface.int$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Object1ImplementingInterface$FragmentInline | Object1ImplementingInterface$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Object1ImplementingInterface$FragmentInline + extends Object1ImplementingInterface, $Select.Directive.$Groups.InlineFragment.Fields +{} + +// ----------------------------------------| Fields Interfaces | + +export namespace Object1ImplementingInterface { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `int` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type int = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Object2ImplementingInterface +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Object2ImplementingInterface extends $Select.Bases.ObjectLike { + /** + * Select the `boolean` field on the `Object2ImplementingInterface` object. Its type is `Boolean` (a `Scalar`). + */ + boolean?: + | Object2ImplementingInterface.$boolean$Expanded + | $Select.SelectAlias.SelectAlias + /** + * Select the `id` field on the `Object2ImplementingInterface` object. Its type is `ID` (a `Scalar`). + */ + id?: Object2ImplementingInterface.id$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Object2ImplementingInterface$FragmentInline | Object2ImplementingInterface$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Object2ImplementingInterface$FragmentInline + extends Object2ImplementingInterface, $Select.Directive.$Groups.InlineFragment.Fields +{} + +// ----------------------------------------| Fields Interfaces | + +export namespace Object2ImplementingInterface { + /** + * This is the "expanded" version of the `$boolean` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type $boolean$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type $boolean = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// ObjectNested +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface ObjectNested extends $Select.Bases.ObjectLike { + /** + * Select the `id` field on the `ObjectNested` object. Its type is `ID` (a `Scalar`). + */ + id?: ObjectNested.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `object` field on the `ObjectNested` object. Its type is Object. + */ + object?: ObjectNested.$object$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: ObjectNested$FragmentInline | ObjectNested$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface ObjectNested$FragmentInline extends ObjectNested, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace ObjectNested { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + export interface $object extends _RefDefs._Object1 {} + export type $object$Expanded = $object +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// ObjectUnion +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface ObjectUnion extends $Select.Bases.ObjectLike { + /** + * Select the `fooBarUnion` field on the `ObjectUnion` object. Its type is Union. + */ + fooBarUnion?: ObjectUnion.fooBarUnion$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: ObjectUnion$FragmentInline | ObjectUnion$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface ObjectUnion$FragmentInline extends ObjectUnion, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace ObjectUnion { + export interface fooBarUnion extends _RefDefs._FooBarUnion {} + export type fooBarUnion$Expanded = fooBarUnion +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// lowerCaseObject +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface lowerCaseObject extends $Select.Bases.ObjectLike { + /** + * Select the `id` field on the `lowerCaseObject` object. Its type is `ID` (a `Scalar`). + */ + id?: lowerCaseObject.id$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: lowerCaseObject$FragmentInline | lowerCaseObject$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface lowerCaseObject$FragmentInline + extends lowerCaseObject, $Select.Directive.$Groups.InlineFragment.Fields +{} + +// ----------------------------------------| Fields Interfaces | + +export namespace lowerCaseObject { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// lowerCaseObject2 +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface lowerCaseObject2 extends $Select.Bases.ObjectLike { + /** + * Select the `int` field on the `lowerCaseObject2` object. Its type is `Int` (a `Scalar`). + */ + int?: lowerCaseObject2.int$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: lowerCaseObject2$FragmentInline | lowerCaseObject2$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface lowerCaseObject2$FragmentInline + extends lowerCaseObject2, $Select.Directive.$Groups.InlineFragment.Fields +{} + +// ----------------------------------------| Fields Interfaces | + +export namespace lowerCaseObject2 { + /** + * This is the "expanded" version of the `int` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type int = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLUnionType Types +// ================================================================================================== +// +// +// +// +// +// + +export interface DateUnion { + ___on_DateObject1?: DateObject1 + ___on_DateObject2?: DateObject2 + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: DateUnion$FragmentInline | DateUnion$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, + * the name is one of the member type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} +export interface DateUnion$FragmentInline extends DateUnion, $Select.Directive.$Groups.InlineFragment.Fields {} + +/** + * Union documentation. + */ +export interface FooBarUnion { + ___on_Bar?: Bar + ___on_Foo?: Foo + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: FooBarUnion$FragmentInline | FooBarUnion$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, + * the name is one of the member type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} +export interface FooBarUnion$FragmentInline extends FooBarUnion, $Select.Directive.$Groups.InlineFragment.Fields {} + +export interface Result { + ___on_ErrorOne?: ErrorOne + ___on_ErrorTwo?: ErrorTwo + ___on_Object1?: Object1 + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Result$FragmentInline | Result$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, + * the name is one of the member type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} +export interface Result$FragmentInline extends Result, $Select.Directive.$Groups.InlineFragment.Fields {} + +export interface lowerCaseUnion { + ___on_lowerCaseObject?: lowerCaseObject + ___on_lowerCaseObject2?: lowerCaseObject2 + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: lowerCaseUnion$FragmentInline | lowerCaseUnion$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, + * the name is one of the member type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} +export interface lowerCaseUnion$FragmentInline + extends lowerCaseUnion, $Select.Directive.$Groups.InlineFragment.Fields +{} + +/** + * [1] These definitions serve to allow field selection interfaces to extend their respective object type without + * name clashing between the field name and the object name. + * + * For example imagine `Query.Foo` field with type also called `Foo`. Our generated interfaces for each field + * would end up with an error of `export interface Foo extends Foo ...` + */ +export namespace _RefDefs { + export type _Mutation = Mutation + export type _Query = Query + export type _ABCEnum = ABCEnum + export type _Case = Case + export type _InputObject = InputObject + export type _InputObjectCircular = InputObjectCircular + export type _InputObjectNested = InputObjectNested + export type _InputObjectNestedNonNull = InputObjectNestedNonNull + export type _DateInterface1 = DateInterface1 + export type _Error = Error + export type _Interface = Interface + export type _Bar = Bar + export type _DateObject1 = DateObject1 + export type _DateObject2 = DateObject2 + export type _ErrorOne = ErrorOne + export type _ErrorTwo = ErrorTwo + export type _Foo = Foo + export type _Object1 = Object1 + export type _Object1ImplementingInterface = Object1ImplementingInterface + export type _Object2ImplementingInterface = Object2ImplementingInterface + export type _ObjectNested = ObjectNested + export type _ObjectUnion = ObjectUnion + export type _lowerCaseObject = lowerCaseObject + export type _lowerCaseObject2 = lowerCaseObject2 + export type _DateUnion = DateUnion + export type _FooBarUnion = FooBarUnion + export type _Result = Result + export type _lowerCaseUnion = lowerCaseUnion +} diff --git a/package.json b/package.json index 8178bb14b..4094c583e 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "scripts": { "serve:pokemon": "tsx tests/_/services/pokemonManual.ts", "gen:graffle": "pnpm gen:graffle:tests && pnpm build && cd website && pnpm gen:graffle", - "gen:graffle:tests": "tsx tests/_/schemas/generate.ts", + "gen:graffle:tests": "tsx tests/_/schemas/generate.ts && pnpm graffle --project src/extensions/SchemaErrors/tests/fixture", "graffle": "tsx ./src/cli/generate.ts", "gen:examples": "tsx scripts/generate-examples-derivatives/generate.ts && pnpm format", "dev": "rm -rf dist && tsc --watch", diff --git a/src/cli/generate.ts b/src/cli/generate.ts index 65815cdf1..60eb4b58e 100755 --- a/src/cli/generate.ts +++ b/src/cli/generate.ts @@ -1,9 +1,11 @@ #!/usr/bin/env node import { Command } from '@molt/command' +import * as Path from 'node:path' import { z } from 'zod' import { Generator } from '../layers/4_generator/__.js' -import { urlParseSafe } from '../lib/prelude.js' +import { toAbsolutePath } from '../lib/fs.js' +import { isError, urlParseSafe } from '../lib/prelude.js' const args = Command.create().description(`Generate a type safe GraphQL client.`) .parameter( @@ -14,25 +16,15 @@ const args = Command.create().description(`Generate a type safe GraphQL client.` ) .parameter( `schema`, - z.string().min(1).describe( - `Path to where your GraphQL schema is. If a URL is given it will be introspected. Otherwise assumed to be a path to your GraphQL SDL file. If a directory path is given, then will look for a "schema.graphql" within that directory. Otherwise will attempt to load the exact file path given.`, + z.string().min(1).optional().describe( + `Path to where your GraphQL schema is. If a URL is given it will be introspected. Otherwise assumed to be a path to your GraphQL SDL file. If a directory path is given, then will look for a "schema.graphql" within that directory. Otherwise will attempt to load the exact file path given. If omitted, then your project must have a configuration file which supplies the schema source.`, ), ) - .parametersExclusive( - `schemaErrorType`, - $ => - $.parameter( - `schemaErrorTypes`, - z.boolean().describe( - `Use the schema error types pattern. All object types whose name starts with "Error" will be considered to be error types. If you want to specify a custom name pattern then use the other parameter "schemaErrorTypePattern".`, - ), - ) - .parameter( - `schemaErrorTypePattern`, - z.string().min(1).describe( - `Designate objects whose name matches this JS regular expression as being error types in your schema.`, - ), - ).default(`schemaErrorTypes`, true), + .parameter( + `project`, + z.string().optional().describe( + `Path to your configuration file. By default will look for "graffle.config.{ts,js,mjs,mts}" in the current working directory. If a directory path is given, then will look for "graffle.config.{ts,js,mjs,mts}" in that directory.`, + ), ) .parameter( `defaultSchemaUrl`, @@ -43,12 +35,12 @@ const args = Command.create().description(`Generate a type safe GraphQL client.` z.string().min(1).describe( `A GraphQL endpoint to be used as the default URL in the generated client for requests.`, ), - ]).default(true), + ]).optional(), ) .parameter( `output`, - z.string().min(1).default(`./graffle`).describe( - `Directory path for where to output the generated TypeScript files.`, + z.string().min(1).optional().describe( + `Directory path for where to output the generated TypeScript files. By default will be './graffle' in the project root.`, ), ) .parameter( @@ -56,31 +48,7 @@ const args = Command.create().description(`Generate a type safe GraphQL client.` z.boolean().describe( `Try to format the generated files. At attempt to use dprint will be made. You need to have these dependencies installed in your project: @dprint/formatter, @dprint/typescript.`, ) - .default(true), - ) - .parameter( - `libraryPathClient`, - z.string().optional().describe( - `Custom location for where the generated code should import the Graffle "client" module from.`, - ), - ) - .parameter( - `libraryPathSchema`, - z.string().optional().describe( - `Custom location for where the generated code should import the Graffle "schema" module from.`, - ), - ) - .parameter( - `libraryPathScalars`, - z.string().optional().describe( - `Custom location for where the generated code should import the Graffle "scalars" module from.`, - ), - ) - .parameter( - `libraryPathUtilitiesForGenerated`, - z.string().optional().describe( - `Custom location for where the generated code should import the Graffle "utilities-for-generated" module from.`, - ), + .optional(), ) .settings({ parameters: { @@ -89,33 +57,52 @@ const args = Command.create().description(`Generate a type safe GraphQL client.` }) .parse() -const url = urlParseSafe(args.schema) +// --- Resolve Config File --- + +const configModule = await Generator.Config.load({ filePath: args.project }) +if (isError(configModule)) throw configModule +if (!configModule.builder && args.project) { + throw new Error(`Could not find a configuration file at "${configModule.paths.join(`, `)}".`) +} + +// --- Resolve Default Schema URL --- const defaultSchemaUrl = typeof args.defaultSchemaUrl === `string` ? new URL(args.defaultSchemaUrl) : args.defaultSchemaUrl -const format = args.format - -const schemaSource = url - ? { type: `url` as const, url } - : { type: `sdl` as const, dirOrFilePath: args.schema } - -await Generator.generate({ - format, - schemaSource, - defaultSchemaUrl, - name: args.name, - outputDirPath: args.output, - errorTypeNamePattern: args.schemaErrorType._tag === `schemaErrorTypePattern` - ? new RegExp(args.schemaErrorType.value) - : args.schemaErrorType.value - ? /^Error.+/ - : undefined, - libraryPaths: { - client: args.libraryPathClient, - schema: args.libraryPathSchema, - scalars: args.libraryPathScalars, - utilitiesForGenerated: args.libraryPathUtilitiesForGenerated, - }, -}) +// --- Resolve Schema --- + +const url = args.schema ? urlParseSafe(args.schema) : null + +const schemaViaCLI = args.schema + ? url + ? { type: `url` as const, url } + : { type: `sdl` as const, dirOrFilePath: Path.join(process.cwd(), args.schema) } + : undefined + +const schema = schemaViaCLI ?? configModule.builder?._.input.schema + +if (!schema) { + throw new Error(`No schema source provided. Either specify a schema source in the config file or via the CLI.`) +} + +const currentWorkingDirectory = configModule.path ? Path.dirname(configModule.path) : process.cwd() +console.log(currentWorkingDirectory) + +// --- Merge Inputs --- + +const input = { + ...configModule.builder?._.input, + currentWorkingDirectory, + schema, +} + +if (defaultSchemaUrl !== undefined) input.defaultSchemaUrl = defaultSchemaUrl +if (args.format !== undefined) input.format = args.format +if (args.name !== undefined) input.name = args.name +if (args.output !== undefined) input.outputDirPath = toAbsolutePath(process.cwd(), args.output) + +// --- Generate --- + +await Generator.generate(input) diff --git a/src/entrypoints/_Generator.ts b/src/entrypoints/_Generator.ts new file mode 100644 index 000000000..1d1e8c46e --- /dev/null +++ b/src/entrypoints/_Generator.ts @@ -0,0 +1,2 @@ +export { generate } from '../layers/4_generator/_.js' +export { create } from '../layers/4_generator/configFile/builder.js' diff --git a/src/entrypoints/__Generator.ts b/src/entrypoints/__Generator.ts new file mode 100644 index 000000000..b68c298dc --- /dev/null +++ b/src/entrypoints/__Generator.ts @@ -0,0 +1 @@ +export * as Generator from './_Generator.js' diff --git a/src/entrypoints/extensionkit.ts b/src/entrypoints/extensionkit.ts new file mode 100644 index 000000000..9ca6c4523 --- /dev/null +++ b/src/entrypoints/extensionkit.ts @@ -0,0 +1,2 @@ +export { createExtension as createGeneratorExtension } from '../layers/4_generator/extension/create.js' +export { createExtension } from '../layers/6_client/extension/extension.js' diff --git a/src/entrypoints/extensions/schema-errors/_.ts b/src/entrypoints/extensions/schema-errors/_.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/entrypoints/extensions/schema-errors/generator/_.ts b/src/entrypoints/extensions/schema-errors/generator/_.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/entrypoints/generator.ts b/src/entrypoints/generator.ts index 60fb332b1..560432904 100644 --- a/src/entrypoints/generator.ts +++ b/src/entrypoints/generator.ts @@ -1 +1 @@ -export { generate } from '../layers/4_generator/_.js' +export * from './__Generator.js' diff --git a/src/entrypoints/utilities-for-generated.ts b/src/entrypoints/utilities-for-generated.ts index dc7c59c37..daddf0396 100644 --- a/src/entrypoints/utilities-for-generated.ts +++ b/src/entrypoints/utilities-for-generated.ts @@ -1,7 +1,7 @@ export { type Simplify } from 'type-fest' -export { type SchemaDrivenDataMap } from '../extensions/CustomScalars/schemaDrivenDataMap/types.js' +export { type SchemaDrivenDataMap } from '../extensions/CustomScalars/schemaDrivenDataMap/__.js' export * from '../layers/2_Select/__.js' -export { type SchemaIndex as SchemaIndexBase } from '../layers/4_generator/generators/SchemaIndex.js' +export { type Schema as SchemaIndexBase } from '../layers/4_generator/generators/Schema.js' export type { ConfigGetOutputError, HandleOutput, diff --git a/src/extensions/CustomScalars/decode.ts b/src/extensions/CustomScalars/decode.ts index a3059e8ac..7cf27355b 100644 --- a/src/extensions/CustomScalars/decode.ts +++ b/src/extensions/CustomScalars/decode.ts @@ -1,7 +1,7 @@ import { Kind } from 'graphql' import { applyCodec } from '../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' import type { Grafaid } from '../../lib/grafaid/__.js' -import { SchemaDrivenDataMap } from './schemaDrivenDataMap/types.js' +import { SchemaDrivenDataMap } from './schemaDrivenDataMap/__.js' /** * If a document is given then aliases will be decoded as well. diff --git a/src/extensions/CustomScalars/encode.ts b/src/extensions/CustomScalars/encode.ts index 9ca7b58ad..c5cfdb0f6 100644 --- a/src/extensions/CustomScalars/encode.ts +++ b/src/extensions/CustomScalars/encode.ts @@ -1,6 +1,6 @@ import { applyCodec } from '../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' import { Grafaid } from '../../lib/grafaid/__.js' -import { SchemaDrivenDataMap } from './schemaDrivenDataMap/types.js' +import { SchemaDrivenDataMap } from './schemaDrivenDataMap/__.js' export const encodeRequestVariables = ({ sddm, request }: { sddm: SchemaDrivenDataMap diff --git a/src/extensions/CustomScalars/schemaDrivenDataMap/__.ts b/src/extensions/CustomScalars/schemaDrivenDataMap/__.ts new file mode 100644 index 000000000..d14a3b247 --- /dev/null +++ b/src/extensions/CustomScalars/schemaDrivenDataMap/__.ts @@ -0,0 +1,5 @@ +export * as SchemaDrivenDataMap from './types.js' + +import { type SchemaDrivenDataMap as SchemaDrivenDataMap_ } from './types.js' + +export type SchemaDrivenDataMap = SchemaDrivenDataMap_ diff --git a/src/extensions/CustomScalars/schemaDrivenDataMap/generator.ts b/src/extensions/CustomScalars/schemaDrivenDataMap/generator.ts index 6e1f8c227..abd4135b1 100644 --- a/src/extensions/CustomScalars/schemaDrivenDataMap/generator.ts +++ b/src/extensions/CustomScalars/schemaDrivenDataMap/generator.ts @@ -1,4 +1,4 @@ -import type { Config } from '../../../layers/4_generator/config.js' +import type { Config } from '../../../layers/4_generator/config/config.js' import { ModuleGeneratorScalar } from '../../../layers/4_generator/generators/Scalar.js' import { createModuleGenerator } from '../../../layers/4_generator/helpers/moduleGenerator.js' import { createCodeGenerator } from '../../../layers/4_generator/helpers/moduleGeneratorRunner.js' @@ -6,7 +6,7 @@ import { title1 } from '../../../layers/4_generator/helpers/render.js' import { Code } from '../../../lib/Code.js' import { Grafaid } from '../../../lib/grafaid/__.js' import { entries } from '../../../lib/prelude.js' -import { propertyNames, SchemaDrivenDataMap } from './types.js' +import { nullabilityFlags, propertyNames } from './types.js' const identifiers = { $Scalar: `$Scalar`, @@ -55,11 +55,11 @@ export const ModuleGeneratorSchemaDrivenDataMap = createModuleGenerator( code() code(`const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap =`) code(Code.termObject({ - roots: Code.termObjectWith({ + roots: Code.directiveTermObject({ $literal: kinds.GraphQLRootType.map(type => type.name + `,`).join(`\n`), }), directives: `{}`, - types: Code.termObjectWith({ + types: Code.directiveTermObject({ $literal: [ ...kindsList.map(([, _]) => _).flat().map((_) => _.name), // We also include the custom scalars here to facilitate encoding. Encoding has names of variables and @@ -92,20 +92,20 @@ export const ModuleGeneratorSchemaDrivenDataMap = createModuleGenerator( * If both are enabled the merged requirement is: all paths to inputs AND custom scalar outputs. */ const getKinds = (config: Config) => { - const { schema: { typeMapByKind } } = config + const { schema: { kindMap } } = config const condition = typeCondition(config) return { // When "variables" enabled, we need to know all named types to be able to write them out. - GraphQLScalarType: typeMapByKind.GraphQLScalarType.filter((n) => - config.runtimeFeatures.operationVariables && !Grafaid.Schema.isScalarTypeCustom(n) + GraphQLScalarTypeStandard: kindMap.GraphQLScalarTypeStandard.filter(() => + config.runtimeFeatures.operationVariables ), - GraphQLScalarTypeCustom: typeMapByKind.GraphQLScalarTypeCustom.filter(() => config.runtimeFeatures.customScalars), - GraphQLEnumType: typeMapByKind.GraphQLEnumType.filter(() => config.runtimeFeatures.operationVariables), - GraphQLInputObjectType: typeMapByKind.GraphQLInputObjectType.filter(condition), - GraphQLObjectType: typeMapByKind.GraphQLObjectType.filter(condition), - GraphQLInterfaceType: typeMapByKind.GraphQLInterfaceType.filter(condition), - GraphQLUnionType: typeMapByKind.GraphQLUnionType.filter(condition), - GraphQLRootType: typeMapByKind.GraphQLRootType.filter(condition), + GraphQLScalarTypeCustom: kindMap.GraphQLScalarTypeCustom.filter(() => config.runtimeFeatures.customScalars), + GraphQLEnumType: kindMap.GraphQLEnumType.filter(() => config.runtimeFeatures.operationVariables), + GraphQLInputObjectType: kindMap.GraphQLInputObjectType.filter(condition), + GraphQLObjectType: kindMap.GraphQLObjectType.filter(condition), + GraphQLInterfaceType: kindMap.GraphQLInterfaceType.filter(condition), + GraphQLUnionType: kindMap.GraphQLUnionType.filter(condition), + GraphQLRootType: kindMap.GraphQLRootType.filter(condition), } } @@ -171,7 +171,7 @@ const UnionType = createCodeGenerator< type.name, `$Utilities.SchemaDrivenDataMap.OutputObject`, Code.termObject({ - [propertyNames.f]: Code.termObjectWith({ + [propertyNames.f]: Code.directiveTermObject({ $spread: type.getTypes().filter(Grafaid.Schema.CustomScalars.isHasCustomScalars).map(memberType => memberType.name + `.${propertyNames.f}` ), @@ -185,12 +185,12 @@ const InterfaceType = createCodeGenerator< { type: Grafaid.Schema.InterfaceType; referenceAssignments: ReferenceAssignments } >( ({ code, type, config }) => { - const implementorTypes = Grafaid.Schema.KindMap.getInterfaceImplementors(config.schema.typeMapByKind, type) + const implementorTypes = Grafaid.Schema.KindMap.getInterfaceImplementors(config.schema.kindMap, type) code(Code.termConstTyped( type.name, `$Utilities.SchemaDrivenDataMap.OutputObject`, Code.termObject({ - [propertyNames.f]: Code.termObjectWith({ + [propertyNames.f]: Code.directiveTermObject({ $spread: implementorTypes.filter(Grafaid.Schema.CustomScalars.isHasCustomScalars).map(memberType => memberType.name + `.${propertyNames.f}` ), @@ -206,11 +206,13 @@ const ObjectType = createCodeGenerator< ({ config, code, type, referenceAssignments }) => { const o: Code.TermObject = {} - // Indicate if this is an error type. - // ---------------------------------- - if (config.schema.error.objects.find(_ => _.name === type.name)) { - o[propertyNames.e] = 1 - } + config.extensions.forEach(_ => { + _.schemaDrivenDataMap?.onObjectType?.({ + config, + sddmNode: o, + graphqlType: type, + }) + }) // Fields of this object. // --------------------- @@ -222,17 +224,17 @@ const ObjectType = createCodeGenerator< const outputFields = Object.values(type.getFields()).filter(condition) for (const outputField of outputFields) { const outputFieldNamedType = Grafaid.Schema.getNamedType(outputField.type) - const ofItem: Code.TermObjectWithLike = { + const sddmNodeOutputField: Code.DirectiveTermObjectLike = { $fields: {}, } - of[outputField.name] = ofItem + of[outputField.name] = sddmNodeOutputField // Field Arguments const inputCondition = inputTypeCondition(config) const args = outputField.args.filter(inputCondition) if (args.length > 0) { const ofItemAs: Code.TermObject = {} - ofItem.$fields[propertyNames.a] = ofItemAs + sddmNodeOutputField.$fields[propertyNames.a] = ofItemAs for (const arg of args) { const ofItemA: Code.TermObject = {} @@ -254,29 +256,26 @@ const ObjectType = createCodeGenerator< } } - // Indicate if the field is a "result field" - // ------------------------------------------ - const memberTypes = Grafaid.Schema.isUnionType(outputFieldNamedType) ? outputFieldNamedType.getTypes() : null - if ( - config.schema.error.enabled - && memberTypes - && config.schema.error.objects.find(_ => memberTypes.find(__ => __.name === _.name)) - ) { - ofItem.$fields[propertyNames.r] = 1 - } + config.extensions.forEach(_ => { + _.schemaDrivenDataMap?.onOutputField?.({ + config, + sddmNode: sddmNodeOutputField, + graphqlType: outputField, + }) + }) if (condition(outputFieldNamedType)) { if (Grafaid.Schema.isScalarTypeAndCustom(outputFieldNamedType)) { if (config.runtimeFeatures.customScalars) { - ofItem.$fields[propertyNames.nt] = outputFieldNamedType.name + sddmNodeOutputField.$fields[propertyNames.nt] = outputFieldNamedType.name } } else if ( Grafaid.Schema.isUnionType(outputFieldNamedType) || Grafaid.Schema.isObjectType(outputFieldNamedType) || Grafaid.Schema.isInterfaceType(outputFieldNamedType) ) { - referenceAssignments.push(`${type.name}.f['${outputField.name}']!.nt = ${outputFieldNamedType.name}`) + referenceAssignments.push(`${type.name}.f[\`${outputField.name}\`]!.nt = ${outputFieldNamedType.name}`) // dprint-ignore - ofItem.$literal = `// ${Code.termField(propertyNames.nt, outputFieldNamedType.name)} <-- Assigned later to avoid potential circular dependency.` + sddmNodeOutputField.$literal = `// ${Code.termField(propertyNames.nt, outputFieldNamedType.name)} <-- Assigned later to avoid potential circular dependency.` // // todo make kitchen sink schema have a pattern where this code path will be traversed. // // We just need to have arguments on a field on a nested object. // // Nested objects that in turn have custom scalar arguments @@ -324,7 +323,7 @@ const InputObjectType = createCodeGenerator< o[propertyNames.fcs] = Code.termList(customScalarFields) } } - const f: Code.TermObjectOf> = {} + const f: Code.TermObjectOf> = {} o[propertyNames.f] = f for (const inputField of inputFields) { @@ -350,7 +349,7 @@ const InputObjectType = createCodeGenerator< && Grafaid.Schema.CustomScalars.isHasCustomScalarInputs(inputFieldType) ) { referenceAssignments.push( - `${type.name}.${propertyNames.f}!['${inputField.name}']!.${propertyNames.nt} = ${inputFieldType.name}`, + `${type.name}.${propertyNames.f}![\`${inputField.name}\`]!.${propertyNames.nt} = ${inputFieldType.name}`, ) f[inputField.name]!.$literal = `// ${ Code.termField(propertyNames.nt, inputFieldType.name) @@ -363,7 +362,7 @@ const InputObjectType = createCodeGenerator< ) const kindRenders = { - GraphQLScalarType: ScalarType, + GraphQLScalarTypeStandard: ScalarType, GraphQLScalarTypeCustom: ScalarType, GraphQLEnumType: EnumType, GraphQLUnionType: UnionType, @@ -379,8 +378,8 @@ const inlineType = (type: Grafaid.Schema.InputTypes): string => { : [type, false] const nullFlag = nonNull - ? SchemaDrivenDataMap.nullabilityFlags.nonNull - : SchemaDrivenDataMap.nullabilityFlags.nullable + ? nullabilityFlags.nonNull + : nullabilityFlags.nullable const rest = Grafaid.Schema.isListType(ofType) ? inlineType(ofType.ofType) diff --git a/src/extensions/CustomScalars/schemaDrivenDataMap/types.ts b/src/extensions/CustomScalars/schemaDrivenDataMap/types.ts index 101593952..29a5b271e 100644 --- a/src/extensions/CustomScalars/schemaDrivenDataMap/types.ts +++ b/src/extensions/CustomScalars/schemaDrivenDataMap/types.ts @@ -1,6 +1,106 @@ import { Scalar, type Scalar as SchemaScalar } from '../../../layers/1_Schema/_.js' import type { Grafaid } from '../../../lib/grafaid/__.js' +declare global { + namespace GraffleGlobal { + export interface SchemaDrivenDataMap { + roots: { + [Grafaid.Schema.RootTypeName.Mutation]?: SchemaDrivenDataMap.OutputObject + [Grafaid.Schema.RootTypeName.Query]?: SchemaDrivenDataMap.OutputObject + [Grafaid.Schema.RootTypeName.Subscription]?: SchemaDrivenDataMap.OutputObject + } + types: Record + directives: Record + } + + namespace SchemaDrivenDataMap { + export interface Enum { + k: `enum` + n: string + } + + export interface OutputObject { + /** + * Fields of this output object. + */ + f: { + [key: string]: OutputField + } + } + + export interface OutputField { + /** + * The field's arguments, if any. + * + * Present when one of: + * - operationVariables is enabled and field has arguments. + * - customScalars is enabled and field has arguments that contain custom scalars. + */ + a?: ArgumentsOrInputObjectFields + /** + * The field's output type. + * + * Present when/as one of: + * - `CodecString` when customScalars enabled and this field's named type is a custom scalar. + * - `OutputObject` when customScalars enabled and this field's type contains custom scalars. + */ + nt?: OutputLike + } + + export interface ArgumentsOrInputObjectFields { + [key: string]: ArgumentOrInputField + } + + export interface ArgumentOrInputField { + /** + * Inline types (nullable/non-nullable, list) of this argument or input field. Only present when operationVariables is enabled. + */ + it?: InlineType + /** + * Named type of this argument or input field. Only present when customScalars is enabled. + */ + nt?: InputLike + } + + export interface InputObject { + /** + * Field names within this input object that are or transitively contain custom scalars. + * + * This is only present when operationVariables is enabled, because that feature requires + * all input object fields to be mapped, thus requiring a meta field to identify the custom scalar ones. + */ + fcs?: string[] + /** + * Name of the input object. Only present when "variables" is enabled. + */ + n?: string + /** + * Fields of the input object. + */ + f?: { + [key: string]: ArgumentOrInputField + } + } + } + } +} + +export type SchemaDrivenDataMap = GraffleGlobal.SchemaDrivenDataMap + +export type OutputObject = GraffleGlobal.SchemaDrivenDataMap.OutputObject + +export type OutputField = GraffleGlobal.SchemaDrivenDataMap.OutputField + +export type InputObject = GraffleGlobal.SchemaDrivenDataMap.InputObject + +export type Enum = GraffleGlobal.SchemaDrivenDataMap.Enum + +export type ArgumentsOrInputObjectFields = GraffleGlobal.SchemaDrivenDataMap.ArgumentsOrInputObjectFields + +export type Scalar = SchemaScalar.Scalar + +export type ArgumentOrInputField = GraffleGlobal.SchemaDrivenDataMap.ArgumentOrInputField + export const propertyNames = { k: `k`, n: `n`, @@ -9,152 +109,69 @@ export const propertyNames = { f: `f`, a: `a`, nt: `nt`, - // schema errors - r: `r`, - e: `e`, } as const -export interface SchemaDrivenDataMap { - roots: { - [Grafaid.Schema.RootTypeName.Mutation]?: SchemaDrivenDataMap.OutputObject - [Grafaid.Schema.RootTypeName.Query]?: SchemaDrivenDataMap.OutputObject - [Grafaid.Schema.RootTypeName.Subscription]?: SchemaDrivenDataMap.OutputObject - } - types: Record - directives: Record -} +/** + * Inline types for a field-like (directive argument, field argument, input/output field) type. + * + * Nested tuple. Each nesting represents a list. First tuple member represents nullability of the list. + * + * The outer most tuple represents not a list but the nullability for the named type itself. E.g. `[0]` would indicate + * that a scalar field is nullable while `[1]` would indicate that it is non-nullable. + */ +export type InlineType = [Nullable | NonNull, InlineType?] -export namespace SchemaDrivenDataMap { - export type NamedLike = SchemaScalar.Scalar | OutputObject | Enum | InputObject +export type Nullable = 0 - export type OutputLike = SchemaScalar.Scalar | OutputObject | Enum +export type NonNull = 1 - export type InputLike = SchemaScalar.Scalar | InputObject | Enum - - export type Enum = { - k: `enum` - n: string - } - export const isEnum = (node?: Node): node is Enum => { - return node ? `k` in node && node.k === `enum` : false - } +export const isEnum = ( + node?: Node, +): node is Enum => { + return node ? `k` in node && node.k === `enum` : false +} - export type Node = - | OutputObject - | InputObject - | ArgumentsOrInputObjectFields - | ArgumentOrInputField - | InlineType - | SchemaDrivenDataMap - | Scalar - | Enum - - export interface OutputObject { - /** - * Indicates that this object represents an error type. - */ - e?: 1 - /** - * Fields of this output object. - */ - f: { - [key: string]: OutputField - } - } +export const isScalar = Scalar.isScalar - export const isScalar = Scalar.isScalar +export const isOutputObject = ( + node?: Node, +): node is OutputObject => { + return node ? propertyNames.f in node : false +} - export const isOutputObject = (node?: Node): node is OutputObject => { - return node ? propertyNames.f in node : false - } +export const nullabilityFlags = { + 'nullable': 0, + 'nonNull': 1, +} as const - export interface OutputField { - /** - * Indicates that this is a "result field". - */ - r?: 1 - /** - * The field's arguments, if any. - * - * Present when one of: - * - operationVariables is enabled and field has arguments. - * - customScalars is enabled and field has arguments that contain custom scalars. - */ - a?: ArgumentsOrInputObjectFields - /** - * The field's output type. - * - * Present when/as one of: - * - `CodecString` when customScalars enabled and this field's named type is a custom scalar. - * - `OutputObject` when customScalars enabled and this field's type contains custom scalars. - */ - nt?: OutputLike - } - export const isOutputField = (node?: Node): node is OutputField => { - return node ? `a` in node : false - } +// todo not the best check, type has to limit to input like nodes since the check cannot tell input and output apart +// so it would be unsafe to rely on it if output objects could also be passed in. +// fixing this 1) means branding the data which means more bytes in the sddm +// or 2) means using a different key hint like `if` for "input field". +export const isInputObject = ( + node?: InputLike, +): node is InputObject => { + return node ? propertyNames.f in node : false +} - export interface ArgumentsOrInputObjectFields { - [key: string]: ArgumentOrInputField - } +export const isOutputField = ( + node?: Node, +): node is GraffleGlobal.SchemaDrivenDataMap.OutputField => { + return node ? `a` in node : false +} - export interface ArgumentOrInputField { - /** - * Inline types (nullable/non-nullable, list) of this argument or input field. Only present when operationVariables is enabled. - */ - it?: InlineType - /** - * Named type of this argument or input field. Only present when customScalars is enabled. - */ - nt?: InputLike - } +export type NamedLike = SchemaScalar.Scalar | OutputObject | Enum | InputObject - /** - * Inline types for a field-like (directive argument, field argument, input/output field) type. - * - * Nested tuple. Each nesting represents a list. First tuple member represents nullability of the list. - * - * The outer most tuple represents not a list but the nullability for the named type itself. E.g. `[0]` would indicate - * that a scalar field is nullable while `[1]` would indicate that it is non-nullable. - */ - export type InlineType = [Nullable | NonNull, InlineType?] - - export type Nullable = 0 - - export const nullabilityFlags = { - 'nullable': 0, - 'nonNull': 1, - } as const - - export type NonNull = 1 - - export interface InputObject { - /** - * Field names within this input object that are or transitively contain custom scalars. - * - * This is only present when operationVariables is enabled, because that feature requires - * all input object fields to be mapped, thus requiring a meta field to identify the custom scalar ones. - */ - fcs?: string[] - /** - * Name of the input object. Only present when "variables" is enabled. - */ - n?: string - /** - * Fields of the input object. - */ - f?: { - [key: string]: ArgumentOrInputField - } - } +export type OutputLike = SchemaScalar.Scalar | OutputObject | Enum - // todo not the best check, type has to limit to input like nodes since the check cannot tell input and output apart - // so it would be unsafe to rely on it if output objects could also be passed in. - // fixing this 1) means branding the data which means more bytes in the sddm - // or 2) means using a different key hint like `if` for "input field". - export const isInputObject = (node?: InputLike): node is InputObject => { - return node ? propertyNames.f in node : false - } +export type InputLike = SchemaScalar.Scalar | InputObject | Enum - export type Scalar = SchemaScalar.Scalar -} +export type Node = + | OutputObject + | InputObject + | ArgumentsOrInputObjectFields + | ArgumentOrInputField + | InlineType + | SchemaDrivenDataMap + | Scalar + | Enum diff --git a/src/extensions/SchemaErrors/SchemaErrors.ts b/src/extensions/SchemaErrors/SchemaErrors.ts index bd533a87d..dcb3bb0b7 100644 --- a/src/extensions/SchemaErrors/SchemaErrors.ts +++ b/src/extensions/SchemaErrors/SchemaErrors.ts @@ -1,10 +1,10 @@ -import { injectTypenameOnRootResultFields } from '../../layers/5_request/schemaErrors.js' import { createExtension, type Extension } from '../../layers/6_client/extension/extension.js' import { Errors } from '../../lib/errors/__.js' import { normalizeRequestToNode } from '../../lib/grafaid/request.js' import { type ExcludeNullAndUndefined, isString } from '../../lib/prelude.js' import { isRecordLikeObject } from '../../lib/prelude.js' -import { SchemaDrivenDataMap } from '../CustomScalars/schemaDrivenDataMap/types.js' +import { SchemaDrivenDataMap } from '../CustomScalars/schemaDrivenDataMap/__.js' +import { injectTypenameOnRootResultFields } from './injectTypenameOnRootResultFields.js' export const SchemaErrors = () => { return createExtension({ @@ -87,7 +87,7 @@ type OnRequestResult<$Params extends Extension.Hooks.OnRequestResult.Params> = [$Key in keyof ExcludeNullAndUndefined<$Params['result']['data']>]: Exclude< ExcludeNullAndUndefined<$Params['result']['data']>[$Key], - $Params['registeredSchema']['index']['error']['objectsTypename'][keyof $Params['registeredSchema']['index']['error']['objectsTypename']] + { __typename: $Params['registeredSchema']['index']['SchemaErrors']['objectNames'] } > } } & Omit<$Params['result'], 'data'> diff --git a/src/extensions/SchemaErrors/documentation.md b/src/extensions/SchemaErrors/documentation.md index d040c505b..6ef27de1b 100644 --- a/src/extensions/SchemaErrors/documentation.md +++ b/src/extensions/SchemaErrors/documentation.md @@ -4,16 +4,52 @@ This extension supports a GraphQL schema design pattern that advocates for encod ## Getting Started +This extension requires generation and also itself extends the generator. You must apply it at gentime and runtime. + +```ts +// graffle.config.ts + +import { SchemaErrors } from 'graffle/extensions' +import { Graffle } from 'graffle/generator' + +export default Graffle + .create() + .use(SchemaErrors()) +``` + ```ts twoslash +// your/app/code.ts import { Graffle } from 'graffle' import { SchemaErrors } from 'graffle/extensions' const graffle = Graffle.create({ schema: '...' }).use(SchemaErrors()) ``` -By default all objects whose name begin with `Error` will be considered to be "error objects". You can customize this at generate time with your own regular expression. +## Configuration + +Configuration is split between gentime and runtime since this extension extends the Graffle generator as well. + +### Gentime + +#### Identifying Error Objects + +By default all objects whose name begin with `Error` will be considered to be "error objects". You can customize this with your own function. + +```ts +// graffle.config.ts +import { SchemaErrors } from 'graffle/extensions/schema-errors/generator' +import { Graffle } from 'graffle/generator' + +export default Graffle + .create() + .use(SchemaErrors({ + isErrorType: (type) => type.name.match(/^Foo/), + })) +``` + +## Methods -## `isError` +### `isError` You can use a helper method `isError` that will narrow objects to just error objects. For example: @@ -26,7 +62,7 @@ if (graffle.isError(result)) { } ``` -## How It Works +## About Runtime Behavior This is achieved by automatically adding `__typename` field to each object-like root field's selection set. Then the returned object name can be analyzed. Example: diff --git a/src/extensions/SchemaErrors/generator.ts b/src/extensions/SchemaErrors/generator.ts new file mode 100644 index 000000000..fe11eaf8a --- /dev/null +++ b/src/extensions/SchemaErrors/generator.ts @@ -0,0 +1,85 @@ +import { createGeneratorExtension } from '../../entrypoints/extensionkit.js' +import type { Config as GeneratorConfig } from '../../layers/4_generator/config/config.js' +import { Code } from '../../lib/Code.js' +import { ConfigManager } from '../../lib/config-manager/__.js' +import { Grafaid } from '../../lib/grafaid/__.js' + +declare global { + namespace GraffleGlobal { + interface Schema { + SchemaErrors: { + objectNames: string + } + } + namespace SchemaDrivenDataMap { + interface OutputObject { + /** + * Is this output object an error object? + */ + e?: 1 + } + interface OutputField { + /** + * Is this output field a result field? + */ + r?: 1 + } + } + } +} + +const propertyNames = { + r: `r`, + e: `e`, +} + +interface Input { + isErrorType?: (value: Grafaid.Schema.ObjectType) => boolean +} + +const defaultErrorTypeNamePattern = /^Error.+/ + +interface Config { + isErrorType: (value: Grafaid.Schema.ObjectType) => boolean +} + +const defaults: Config = { + isErrorType: (_ => Boolean(_.name.match(defaultErrorTypeNamePattern))), +} + +export const SchemaErrors = (input?: Input) => { + const config = ConfigManager.mergeDefaults(defaults, input ?? {}) + + return createGeneratorExtension({ + name: `SchemaErrors`, + onSchema: ({ config: genConfig, schema }) => { + const errorObjects = getErrorObjects(config, genConfig) + schema[`SchemaErrors`] = { + objectNames: errorObjects.map(_ => Code.string(_.name)).join(` | `), + } + }, + schemaDrivenDataMap: { + onObjectType: ({ config: genConfig, sddmNode, graphqlType }) => { + const errorObjects = getErrorObjects(config, genConfig) + + if (errorObjects.find(_ => _.name === graphqlType.name)) { + sddmNode[propertyNames.e] = 1 + } + }, + onOutputField: ({ config: genConfig, sddmNode, graphqlType }) => { + const errorObjects = getErrorObjects(config, genConfig) + const outputFieldNamedType = Grafaid.Schema.getNamedType(graphqlType.type) + const memberTypes = Grafaid.Schema.isUnionType(outputFieldNamedType) ? outputFieldNamedType.getTypes() : null + + if (memberTypes && errorObjects.find(_ => memberTypes.find(__ => __.name === _.name))) { + sddmNode.$fields[propertyNames.r] = 1 + } + }, + }, + }) +} + +// todo memoize +const getErrorObjects = (config: Config, genConfig: GeneratorConfig) => { + return Object.values(genConfig.schema.kindMap.GraphQLObjectType).filter(config.isErrorType) +} diff --git a/src/extensions/SchemaErrors/injectTypenameOnRootResultFields.test.ts b/src/extensions/SchemaErrors/injectTypenameOnRootResultFields.test.ts new file mode 100644 index 000000000..e07bff322 --- /dev/null +++ b/src/extensions/SchemaErrors/injectTypenameOnRootResultFields.test.ts @@ -0,0 +1,49 @@ +import { expect, test } from 'vitest' +import { normalizeOrThrow } from '../../layers/2_Select/document.js' +import { SelectionSetGraphqlMapper } from '../../layers/3_SelectGraphQLMapper/__.js' +import { graffleMappedResultToRequest } from '../../layers/5_request/core.js' +import { injectTypenameOnRootResultFields } from './injectTypenameOnRootResultFields.js' +import { GraffleSchemaErrors } from './tests/fixture/graffle/__.js' + +type CasesQuery = [ + description: string, + queryWithoutTypename: GraffleSchemaErrors.SelectionSets.Query, + queryWithTypename: GraffleSchemaErrors.SelectionSets.Query, +] + +// dprint-ignore +test.each([ + [`one result field`, + { resultNonNull: {} }, + { resultNonNull: { __typename: true } }], + [`two result fields`, + { resultNonNull: {}, result: { $: { $case: `ErrorOne` } } }, + { resultNonNull: { __typename: true }, result: { $: { $case: `ErrorOne` }, __typename: true }}], + [`no result fields`, + { id: true, object: { id: true } }, + { id: true, object: { id: true } }], + [`__typename in fragment`, + { resultNonNull: { ___: { __typename: true } } }, + { resultNonNull: { ___: { __typename: true }, __typename: true }}], + [`root field in fragment`, + { ___: { resultNonNull: {} } }, + { ___: { resultNonNull: { __typename: true } } }], + [`root field in fragment in alias`, + { ___: { resultNonNull: [`x`, {}] } }, + { ___: { resultNonNull: [`x`, { __typename: true }] }, }], + [`root field alias `, + { resultNonNull: [`x`, {}] }, + { resultNonNull: [`x`, { __typename: true }] }], +])(`Query %s`, (_, queryWithoutTypenameInput, queryWithTypenameInput) => { + const docWithout = SelectionSetGraphqlMapper.toGraphQL( + normalizeOrThrow({ query: { x: queryWithoutTypenameInput as any } }), + ) + const docWith = SelectionSetGraphqlMapper.toGraphQL( + normalizeOrThrow({ query: { x: queryWithTypenameInput as any } }), + ) + injectTypenameOnRootResultFields({ + request: graffleMappedResultToRequest(docWithout), + sddm: GraffleSchemaErrors.schemaDrivenDataMap, + }) + expect(docWithout.document).toMatchObject(docWith.document) +}) diff --git a/src/layers/5_request/schemaErrors.ts b/src/extensions/SchemaErrors/injectTypenameOnRootResultFields.ts similarity index 92% rename from src/layers/5_request/schemaErrors.ts rename to src/extensions/SchemaErrors/injectTypenameOnRootResultFields.ts index ec1349b44..ea5312f3c 100644 --- a/src/layers/5_request/schemaErrors.ts +++ b/src/extensions/SchemaErrors/injectTypenameOnRootResultFields.ts @@ -1,6 +1,6 @@ -import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/types.js' import type { Grafaid } from '../../lib/grafaid/__.js' import { Nodes } from '../../lib/grafaid/graphql.js' +import type { SchemaDrivenDataMap } from '../CustomScalars/schemaDrivenDataMap/__.js' export const injectTypenameOnRootResultFields = ( { request, sddm }: { diff --git a/src/extensions/SchemaErrors/SchemaError.test-d.ts b/src/extensions/SchemaErrors/tests/SchemaError.test-d.ts similarity index 80% rename from src/extensions/SchemaErrors/SchemaError.test-d.ts rename to src/extensions/SchemaErrors/tests/SchemaError.test-d.ts index a6f666408..0836d3d5c 100644 --- a/src/extensions/SchemaErrors/SchemaError.test-d.ts +++ b/src/extensions/SchemaErrors/tests/SchemaError.test-d.ts @@ -1,15 +1,16 @@ import { describe, expectTypeOf, test } from 'vitest' -import { Graffle } from '../../../tests/_/schemas/kitchen-sink/graffle/__.js' -import { schema } from '../../../tests/_/schemas/kitchen-sink/schema.js' -import { type Extension } from '../../layers/6_client/extension/extension.js' -import { SchemaErrors } from './SchemaErrors.js' +import { schema } from '../../../../tests/_/schemas/kitchen-sink/schema.js' +import { type Extension } from '../../../layers/6_client/extension/extension.js' +import { SchemaErrors } from '../SchemaErrors.js' +import { GraffleSchemaErrors } from './fixture/graffle/__.js' -const g = Graffle.create({ schema }).use(SchemaErrors()) +const g = GraffleSchemaErrors.create({ schema }).use(SchemaErrors()) // todo move test to test suite for .use method test(`config type is augmented with type hook`, () => { expectTypeOf().toMatchTypeOf<[Extension.Hooks.OnRequestResult]>() }) + test(`config type is augmented with type hook after "with"`, () => { const g2 = g.with({ output: { defaults: { errorChannel: `throw` } } }) g2._.config.typeHooks.onRequestResult @@ -17,7 +18,7 @@ test(`config type is augmented with type hook after "with"`, () => { }) const resultFieldSelect = - Graffle.Select.Query({ resultNonNull: { $: { $case: `Object1` }, __typename: true } })[`resultNonNull`] + GraffleSchemaErrors.Select.Query({ resultNonNull: { $: { $case: `Object1` }, __typename: true } })[`resultNonNull`] describe(`.errors.schema`, () => { describe(`throw`, () => { diff --git a/src/extensions/SchemaErrors/SchemaErrors.test.ts b/src/extensions/SchemaErrors/tests/SchemaErrors.test.ts similarity index 59% rename from src/extensions/SchemaErrors/SchemaErrors.test.ts rename to src/extensions/SchemaErrors/tests/SchemaErrors.test.ts index 76a880b0f..904b92dac 100644 --- a/src/extensions/SchemaErrors/SchemaErrors.test.ts +++ b/src/extensions/SchemaErrors/tests/SchemaErrors.test.ts @@ -1,19 +1,12 @@ import { parse } from 'graphql' -import { describe, expect } from 'vitest' -import { test } from '../../../tests/_/helpers.js' -import { db } from '../../../tests/_/schemas/db.js' -import { Graffle } from '../../../tests/_/schemas/kitchen-sink/graffle/__.js' -import { schemaDrivenDataMap } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.js' -import type { Query } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js' -import { schema } from '../../../tests/_/schemas/kitchen-sink/schema.js' -import { Select } from '../../layers/2_Select/__.js' -import { SelectionSetGraphqlMapper } from '../../layers/3_SelectGraphQLMapper/__.js' -import { graffleMappedToRequest } from '../../layers/5_request/core.js' -import { injectTypenameOnRootResultFields } from '../../layers/5_request/schemaErrors.js' -import type { Errors } from '../../lib/errors/__.js' -import { SchemaErrors } from './SchemaErrors.js' +import { describe, expect, test } from 'vitest' +import { db } from '../../../../tests/_/schemas/db.js' +import { schema } from '../../../../tests/_/schemas/kitchen-sink/schema.js' +import type { Errors } from '../../../lib/errors/__.js' +import { SchemaErrors } from '../SchemaErrors.js' +import { GraffleSchemaErrors } from './fixture/graffle/__.js' -const graffle = Graffle +const graffle = GraffleSchemaErrors .create({ schema }) .with({ output: { @@ -82,44 +75,21 @@ describe(`query non-result field`, () => { }) }) -type CasesQuery = [description: string, queryWithoutTypename: Query, queryWithTypename: Query] - // todo symmetrical type tests for these cases // dprint-ignore -test.each([ - [`one result field`, { resultNonNull: { } }, { resultNonNull: { __typename: true } }], - [`two result fields`, { resultNonNull: { }, result: { $: { $case: `ErrorOne` }}}, { resultNonNull: { __typename: true }, result: { $: { $case: `ErrorOne` }, __typename: true } }], - [`no result fields`, { id: true, object: { id: true } }, { id: true, object: { id: true }}], - [`__typename in fragment`, { resultNonNull: { ___: { __typename: true }}}, { resultNonNull: { ___: { __typename: true }, __typename: true } }], - [`root field in fragment`, { ___: { resultNonNull: {} } }, { ___: { resultNonNull: { __typename: true }}}], - [`root field in fragment in alias`, { ___: { resultNonNull: [`x`, {}] } }, { ___: { resultNonNull: [`x`, { __typename: true }] }}], - [`root field alias `, { resultNonNull: [`x`, {}] }, { resultNonNull: [`x`, { __typename: true }] }], -])(`Query %s`, (_, queryWithoutTypenameInput, queryWithTypenameInput) => { - const mappedResultWithTypename = SelectionSetGraphqlMapper.toGraphQL( - Select.Document.normalizeOrThrow({ query: { x: queryWithTypenameInput as any } }) - ) - const mappedResultWithoutTypename = SelectionSetGraphqlMapper.toGraphQL( - Select.Document.normalizeOrThrow({ query: { x: queryWithoutTypenameInput as any } }) - ) - injectTypenameOnRootResultFields({ - request: graffleMappedToRequest(mappedResultWithoutTypename), - sddm: schemaDrivenDataMap, - }) - expect(mappedResultWithTypename.document).toMatchObject(mappedResultWithoutTypename.document) -}) -test(`gql string request`, async ({ kitchenSink }) => { +test(`gql string request`, async () => { // todo it would be nicer to move the extension use to the fixture but how would we get the static type for that? // This makes me think of a feature we need to have. Make it easy to get static types of the client in its various configured states. - const result = await kitchenSink + const result = await graffle .use(SchemaErrors()) .gql`query { resultNonNull (case: Object1) { ... on Object1 { id } } }` .send() expect(result).toMatchObject({ resultNonNull: { __typename: `Object1`, id: `abc` } }) }) -test(`gql document request`, async ({ kitchenSink }) => { - const result = await kitchenSink +test(`gql document request`, async () => { + const result = await graffle .use(SchemaErrors()) .gql(parse(`query { resultNonNull (case: Object1) { ... on Object1 { id } } }`)) .send() diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts b/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts new file mode 100644 index 000000000..68d281299 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts @@ -0,0 +1,17 @@ +import { schema } from '../../../../../tests/_/schemas/kitchen-sink/schema.js' +import { Generator } from '../../../../entrypoints/generator.js' +import { SchemaErrors } from '../../generator.js' + +export default Generator + .create({ + name: `GraffleSchemaErrors`, + schema, + outputDirPath: `./graffle`, + libraryPaths: { + client: `../../../../entrypoints/client.ts`, + schema: `../../../../entrypoints/schema.ts`, + scalars: `../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.ts`, + utilitiesForGenerated: `../../../../entrypoints/utilities-for-generated.ts`, + }, + }) + .use(SchemaErrors()) diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/_.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/_.ts new file mode 100644 index 000000000..d27e9e3d3 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/_.ts @@ -0,0 +1,10 @@ +// We import the global module for good measure although it is not clear it is always needed. +// It at least helps with Twoslash wherein without this import here Twoslash will not include the global module. +// In real TypeScript projects it seems the global module is included automatically. But there could be certain tsconfig +// setups where this still indeed does help. +import './modules/Global.js' + +export { create } from './modules/Client.js' +export { schemaDrivenDataMap } from './modules/SchemaDrivenDataMap.js' +export { Select } from './modules/Select.js' +export * as SelectionSets from './modules/SelectionSets.js' diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/__.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/__.ts new file mode 100644 index 000000000..f7f396bc4 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/__.ts @@ -0,0 +1 @@ +export * as GraffleSchemaErrors from './_.js' diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Client.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Client.ts new file mode 100644 index 000000000..f8886572f --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Client.ts @@ -0,0 +1,6 @@ +import { createPrefilled } from '../../../../../../entrypoints/client.js' +import { defaultSchemaUrl } from './Data.js' +import { Name } from './Data.js' +import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' + +export const create = createPrefilled(Name, schemaDrivenDataMap, defaultSchemaUrl) diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Data.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Data.ts new file mode 100644 index 000000000..d987b124e --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Data.ts @@ -0,0 +1,4 @@ +export const Name = `GraffleSchemaErrors` +export type Name = 'GraffleSchemaErrors' + +export const defaultSchemaUrl = undefined diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Global.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Global.ts new file mode 100644 index 000000000..d32ae6d30 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Global.ts @@ -0,0 +1,26 @@ +import type * as Data from './Data.js' +import type * as MethodsDocument from './MethodsDocument.js' +import type * as MethodsRoot from './MethodsRoot.js' +import type * as MethodsSelect from './MethodsSelect.js' +import type * as Scalar from './Scalar.js' +import type { Index } from './Schema.js' + +declare global { + export namespace GraffleGlobal { + export interface Schemas { + GraffleSchemaErrors: { + name: Data.Name + index: Index + interfaces: { + MethodsSelect: MethodsSelect.$MethodsSelect + Document: MethodsDocument.BuilderMethodsDocumentFn + Root: MethodsRoot.BuilderMethodsRootFn + } + customScalars: { + Date: Scalar.Date + } + defaultSchemaUrl: null + } + } + } +} diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsDocument.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsDocument.ts new file mode 100644 index 000000000..8e50a3eb3 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsDocument.ts @@ -0,0 +1,18 @@ +import type * as Utilities from '../../../../../../entrypoints/utilities-for-generated.js' +import type { Index } from './Schema.js' +import type * as SelectionSets from './SelectionSets.js' + +export interface Document<$Config extends Utilities.Config> { + <$Document>(document: Utilities.ExactNonEmpty<$Document, SelectionSets.$Document>): Utilities.DocumentRunner< + $Config, + Index, + // @ts-expect-error We use Exact instead of constraint on this function. TypeScript does not see that as + // Satisfying the constraint on the DocumentRunner type. + $Document + > +} + +export interface BuilderMethodsDocumentFn extends Utilities.TypeFunction.Fn { + // @ts-expect-error parameter is Untyped. + return: Document +} diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsRoot.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsRoot.ts new file mode 100644 index 000000000..673e20207 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsRoot.ts @@ -0,0 +1,585 @@ +import { type Simplify } from 'type-fest' +import type { InferResult } from '../../../../../../entrypoints/schema.js' +import type * as Utils from '../../../../../../entrypoints/utilities-for-generated.js' +import type { Index } from './Schema.js' +import type * as SelectionSet from './SelectionSets.js' + +export interface MutationMethods<$Config extends Utils.Config> { + // todo Use a static type here? + $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Mutation>) => Promise< + Simplify< + Utils.HandleOutput< + $Config, + InferResult.Mutation<$SelectionSet, Index> + > + > + > + // todo Use a static type here? + __typename: () => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + { __typename: 'Mutation' }, + '__typename' + > + > + > + id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.id>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Mutation<{ id: $SelectionSet }, Index>, + 'id' + > + > + > + idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.idNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Mutation<{ idNonNull: $SelectionSet }, Index>, + 'idNonNull' + > + > + > +} + +export interface QueryMethods<$Config extends Utils.Config> { + // todo Use a static type here? + $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query>) => Promise< + Simplify< + Utils.HandleOutput< + $Config, + InferResult.Query<$SelectionSet, Index> + > + > + > + // todo Use a static type here? + __typename: () => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + { __typename: 'Query' }, + '__typename' + > + > + > + InputObjectNested: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNested>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ InputObjectNested: $SelectionSet }, Index>, + 'InputObjectNested' + > + > + > + InputObjectNestedNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNestedNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ InputObjectNestedNonNull: $SelectionSet }, Index>, + 'InputObjectNestedNonNull' + > + > + > + /** + * Query enum field documentation. + */ + abcEnum: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.abcEnum>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ abcEnum: $SelectionSet }, Index>, + 'abcEnum' + > + > + > + argInputObjectCircular: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.argInputObjectCircular>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ argInputObjectCircular: $SelectionSet }, Index>, + 'argInputObjectCircular' + > + > + > + date: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.date>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ date: $SelectionSet }, Index>, + 'date' + > + > + > + dateArg: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArg>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArg: $SelectionSet }, Index>, + 'dateArg' + > + > + > + dateArgInputObject: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgInputObject>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgInputObject: $SelectionSet }, Index>, + 'dateArgInputObject' + > + > + > + dateArgList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgList>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgList: $SelectionSet }, Index>, + 'dateArgList' + > + > + > + dateArgNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgNonNull: $SelectionSet }, Index>, + 'dateArgNonNull' + > + > + > + dateArgNonNullList: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullList>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgNonNullList: $SelectionSet }, Index>, + 'dateArgNonNullList' + > + > + > + dateArgNonNullListNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullListNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateArgNonNullListNonNull: $SelectionSet }, Index>, + 'dateArgNonNullListNonNull' + > + > + > + dateInterface1: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateInterface1>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateInterface1: $SelectionSet }, Index>, + 'dateInterface1' + > + > + > + dateList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateList>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateList: $SelectionSet }, Index>, + 'dateList' + > + > + > + dateListList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListList>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateListList: $SelectionSet }, Index>, + 'dateListList' + > + > + > + dateListNonNull: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateListNonNull: $SelectionSet }, Index>, + 'dateListNonNull' + > + > + > + dateNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateNonNull: $SelectionSet }, Index>, + 'dateNonNull' + > + > + > + dateObject1: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateObject1>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateObject1: $SelectionSet }, Index>, + 'dateObject1' + > + > + > + dateUnion: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateUnion>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ dateUnion: $SelectionSet }, Index>, + 'dateUnion' + > + > + > + error: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.error>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ error: $SelectionSet }, Index>, + 'error' + > + > + > + id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.id>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ id: $SelectionSet }, Index>, + 'id' + > + > + > + idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.idNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ idNonNull: $SelectionSet }, Index>, + 'idNonNull' + > + > + > + interface: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$interface>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ interface: $SelectionSet }, Index>, + 'interface' + > + > + > + interfaceNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ interfaceNonNull: $SelectionSet }, Index>, + 'interfaceNonNull' + > + > + > + interfaceWithArgs: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceWithArgs>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ interfaceWithArgs: $SelectionSet }, Index>, + 'interfaceWithArgs' + > + > + > + listInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listInt>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ listInt: $SelectionSet }, Index>, + 'listInt' + > + > + > + listIntNonNull: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listIntNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ listIntNonNull: $SelectionSet }, Index>, + 'listIntNonNull' + > + > + > + listListInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListInt>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ listListInt: $SelectionSet }, Index>, + 'listListInt' + > + > + > + listListIntNonNull: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListIntNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ listListIntNonNull: $SelectionSet }, Index>, + 'listListIntNonNull' + > + > + > + lowerCaseUnion: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.lowerCaseUnion>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ lowerCaseUnion: $SelectionSet }, Index>, + 'lowerCaseUnion' + > + > + > + object: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$object>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ object: $SelectionSet }, Index>, + 'object' + > + > + > + objectList: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectList>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectList: $SelectionSet }, Index>, + 'objectList' + > + > + > + objectListNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectListNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectListNonNull: $SelectionSet }, Index>, + 'objectListNonNull' + > + > + > + objectNested: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNested>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectNested: $SelectionSet }, Index>, + 'objectNested' + > + > + > + objectNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectNonNull: $SelectionSet }, Index>, + 'objectNonNull' + > + > + > + objectWithArgs: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectWithArgs>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ objectWithArgs: $SelectionSet }, Index>, + 'objectWithArgs' + > + > + > + result: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.result>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ result: $SelectionSet }, Index>, + 'result' + > + > + > + resultNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.resultNonNull>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ resultNonNull: $SelectionSet }, Index>, + 'resultNonNull' + > + > + > + string: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.$string>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ string: $SelectionSet }, Index>, + 'string' + > + > + > + stringWithArgEnum: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgEnum>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithArgEnum: $SelectionSet }, Index>, + 'stringWithArgEnum' + > + > + > + stringWithArgInputObject: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObject>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithArgInputObject: $SelectionSet }, Index>, + 'stringWithArgInputObject' + > + > + > + stringWithArgInputObjectRequired: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObjectRequired>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithArgInputObjectRequired: $SelectionSet }, Index>, + 'stringWithArgInputObjectRequired' + > + > + > + /** + * The given arguments are reflected back as a JSON string. + */ + stringWithArgs: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgs>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithArgs: $SelectionSet }, Index>, + 'stringWithArgs' + > + > + > + stringWithListArg: <$SelectionSet>( + selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArg>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithListArg: $SelectionSet }, Index>, + 'stringWithListArg' + > + > + > + stringWithListArgRequired: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArgRequired>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithListArgRequired: $SelectionSet }, Index>, + 'stringWithListArgRequired' + > + > + > + stringWithRequiredArg: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithRequiredArg>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ stringWithRequiredArg: $SelectionSet }, Index>, + 'stringWithRequiredArg' + > + > + > + unionFooBar: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBar>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionFooBar: $SelectionSet }, Index>, + 'unionFooBar' + > + > + > + unionFooBarNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionFooBarNonNull: $SelectionSet }, Index>, + 'unionFooBarNonNull' + > + > + > + unionFooBarWithArgs: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarWithArgs>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionFooBarWithArgs: $SelectionSet }, Index>, + 'unionFooBarWithArgs' + > + > + > + unionObject: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObject>) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionObject: $SelectionSet }, Index>, + 'unionObject' + > + > + > + unionObjectNonNull: <$SelectionSet>( + selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObjectNonNull>, + ) => Promise< + Simplify< + Utils.HandleOutputGraffleRootField< + $Config, + InferResult.Query<{ unionObjectNonNull: $SelectionSet }, Index>, + 'unionObjectNonNull' + > + > + > +} + +export interface BuilderMethodsRoot<$Config extends Utils.Config> { + mutation: MutationMethods<$Config> + query: QueryMethods<$Config> +} + +export interface BuilderMethodsRootFn extends Utils.TypeFunction.Fn { + // @ts-expect-error parameter is Untyped. + return: BuilderMethodsRoot +} diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsSelect.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsSelect.ts new file mode 100644 index 000000000..1944a1a06 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/MethodsSelect.ts @@ -0,0 +1,199 @@ +import type * as $Utilities from '../../../../../../entrypoints/utilities-for-generated.js' +import type * as $SelectionSets from './SelectionSets.js' + +// +// +// +// +// +// +// ================================================================================================== +// Select Methods Interface +// ================================================================================================== +// +// +// +// +// +// + +export interface $MethodsSelect { + Mutation: Mutation + Query: Query + Bar: Bar + DateObject1: DateObject1 + DateObject2: DateObject2 + ErrorOne: ErrorOne + ErrorTwo: ErrorTwo + Foo: Foo + Object1: Object1 + Object1ImplementingInterface: Object1ImplementingInterface + Object2ImplementingInterface: Object2ImplementingInterface + ObjectNested: ObjectNested + ObjectUnion: ObjectUnion + lowerCaseObject: lowerCaseObject + lowerCaseObject2: lowerCaseObject2 + DateUnion: DateUnion + FooBarUnion: FooBarUnion + Result: Result + lowerCaseUnion: lowerCaseUnion + DateInterface1: DateInterface1 + Error: Error + Interface: Interface +} + +// +// +// +// +// +// +// ================================================================================================== +// Root +// ================================================================================================== +// +// +// +// +// +// + +export interface Mutation { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Mutation>): $SelectionSet +} + +export interface Query { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Query>): $SelectionSet +} + +// +// +// +// +// +// +// ================================================================================================== +// Object +// ================================================================================================== +// +// +// +// +// +// + +export interface Bar { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Bar>): $SelectionSet +} + +export interface DateObject1 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateObject1>): $SelectionSet +} + +export interface DateObject2 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateObject2>): $SelectionSet +} + +export interface ErrorOne { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ErrorOne>): $SelectionSet +} + +export interface ErrorTwo { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ErrorTwo>): $SelectionSet +} + +export interface Foo { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Foo>): $SelectionSet +} + +export interface Object1 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Object1>): $SelectionSet +} + +export interface Object1ImplementingInterface { + <$SelectionSet>( + selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Object1ImplementingInterface>, + ): $SelectionSet +} + +export interface Object2ImplementingInterface { + <$SelectionSet>( + selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Object2ImplementingInterface>, + ): $SelectionSet +} + +export interface ObjectNested { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ObjectNested>): $SelectionSet +} + +export interface ObjectUnion { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ObjectUnion>): $SelectionSet +} + +export interface lowerCaseObject { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.lowerCaseObject>): $SelectionSet +} + +export interface lowerCaseObject2 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.lowerCaseObject2>): $SelectionSet +} + +// +// +// +// +// +// +// ================================================================================================== +// Union +// ================================================================================================== +// +// +// +// +// +// + +export interface DateUnion { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateUnion>): $SelectionSet +} + +export interface FooBarUnion { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.FooBarUnion>): $SelectionSet +} + +export interface Result { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Result>): $SelectionSet +} + +export interface lowerCaseUnion { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.lowerCaseUnion>): $SelectionSet +} + +// +// +// +// +// +// +// ================================================================================================== +// Interface +// ================================================================================================== +// +// +// +// +// +// + +export interface DateInterface1 { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateInterface1>): $SelectionSet +} + +export interface Error { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Error>): $SelectionSet +} + +export interface Interface { + <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Interface>): $SelectionSet +} diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts new file mode 100644 index 000000000..046000857 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts @@ -0,0 +1,2 @@ +export * from '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' +export { String as Date } from '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts new file mode 100644 index 000000000..e973e4e97 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts @@ -0,0 +1,72 @@ +/* eslint-disable */ +import type * as Utilities from '../../../../../../entrypoints/utilities-for-generated.js' +import type * as Data from './Data.js' +import type * as MethodsRoot from './MethodsRoot.js' +import type * as Schema from './SchemaBuildtime.js' + +export interface Index { + name: Data.Name + RootTypesPresent: ['Mutation', 'Query'] + RootUnion: Schema.Root.Mutation | Schema.Root.Query + Root: { + Query: Schema.Root.Query + Mutation: Schema.Root.Mutation + Subscription: null + } + allTypes: { + Mutation: Schema.Root.Mutation + Query: Schema.Root.Query + ABCEnum: Schema.Enum.ABCEnum + Case: Schema.Enum.Case + Bar: Schema.Object.Bar + DateObject1: Schema.Object.DateObject1 + DateObject2: Schema.Object.DateObject2 + ErrorOne: Schema.Object.ErrorOne + ErrorTwo: Schema.Object.ErrorTwo + Foo: Schema.Object.Foo + Object1: Schema.Object.Object1 + Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface + Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface + ObjectNested: Schema.Object.ObjectNested + ObjectUnion: Schema.Object.ObjectUnion + lowerCaseObject: Schema.Object.lowerCaseObject + lowerCaseObject2: Schema.Object.lowerCaseObject2 + DateUnion: Schema.Union.DateUnion + FooBarUnion: Schema.Union.FooBarUnion + Result: Schema.Union.Result + lowerCaseUnion: Schema.Union.lowerCaseUnion + DateInterface1: Schema.Interface.DateInterface1 + Error: Schema.Interface.Error + Interface: Schema.Interface.Interface + } + objects: { + Bar: Schema.Object.Bar + DateObject1: Schema.Object.DateObject1 + DateObject2: Schema.Object.DateObject2 + ErrorOne: Schema.Object.ErrorOne + ErrorTwo: Schema.Object.ErrorTwo + Foo: Schema.Object.Foo + Object1: Schema.Object.Object1 + Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface + Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface + ObjectNested: Schema.Object.ObjectNested + ObjectUnion: Schema.Object.ObjectUnion + lowerCaseObject: Schema.Object.lowerCaseObject + lowerCaseObject2: Schema.Object.lowerCaseObject2 + } + unions: { + DateUnion: Schema.Union.DateUnion + FooBarUnion: Schema.Union.FooBarUnion + Result: Schema.Union.Result + lowerCaseUnion: Schema.Union.lowerCaseUnion + } + interfaces: { + DateInterface1: Schema.Interface.DateInterface1 + Error: Schema.Interface.Error + Interface: Schema.Interface.Interface + } + customScalars: Utilities.SchemaIndexBase['customScalars'] + SchemaErrors: { + objectNames: 'ErrorOne' | 'ErrorTwo' + } +} diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaBuildtime.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaBuildtime.ts new file mode 100644 index 000000000..551dd7547 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaBuildtime.ts @@ -0,0 +1,359 @@ +import type * as $ from '../../../../../../entrypoints/schema.js' +import type * as $Scalar from './Scalar.js' + +// ------------------------------------------------------------ // +// Root // +// ------------------------------------------------------------ // +export namespace Root { + export type Mutation = $.Output.ObjectMutation<{ + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + idNonNull: $.Field<'idNonNull', $Scalar.ID, null> + }> + + export type Query = $.Output.ObjectQuery<{ + InputObjectNested: $.Field< + 'InputObjectNested', + $.Output.Nullable<$Scalar.ID>, + $.Args<{ + input: $.Input.Field<$.Input.Nullable> + }, true> + > + InputObjectNestedNonNull: $.Field< + 'InputObjectNestedNonNull', + $.Output.Nullable<$Scalar.ID>, + $.Args<{ + input: $.Input.Field + }, false> + > + /** + * Query enum field documentation. + */ + abcEnum: $.Field<'abcEnum', $.Output.Nullable, null> + argInputObjectCircular: $.Field< + 'argInputObjectCircular', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + input: $.Input.Field<$.Input.Nullable> + }, true> + > + date: $.Field<'date', $.Output.Nullable<$Scalar.Date>, null> + dateArg: $.Field< + 'dateArg', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$.Input.Nullable<$Scalar.Date>> + }, true> + > + dateArgInputObject: $.Field< + 'dateArgInputObject', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + input: $.Input.Field<$.Input.Nullable> + }, true> + > + dateArgList: $.Field< + 'dateArgList', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$.Input.Nullable<$.Input.List<$Scalar.Date>>> + }, true> + > + dateArgNonNull: $.Field< + 'dateArgNonNull', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$Scalar.Date> + }, false> + > + dateArgNonNullList: $.Field< + 'dateArgNonNullList', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$.Input.List<$.Input.Nullable<$Scalar.Date>>> + }, false> + > + dateArgNonNullListNonNull: $.Field< + 'dateArgNonNullListNonNull', + $.Output.Nullable<$Scalar.Date>, + $.Args<{ + date: $.Input.Field<$.Input.List<$Scalar.Date>> + }, false> + > + dateInterface1: $.Field<'dateInterface1', $.Output.Nullable, null> + dateList: $.Field<'dateList', $.Output.Nullable<$.Output.List<$Scalar.Date>>, null> + dateListList: $.Field<'dateListList', $.Output.Nullable<$.Output.List<$.Output.List<$Scalar.Date>>>, null> + dateListNonNull: $.Field<'dateListNonNull', $.Output.List<$Scalar.Date>, null> + dateNonNull: $.Field<'dateNonNull', $Scalar.Date, null> + dateObject1: $.Field<'dateObject1', $.Output.Nullable, null> + dateUnion: $.Field<'dateUnion', $.Output.Nullable, null> + error: $.Field< + 'error', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + case: $.Input.Field<$.Input.Nullable<$Scalar.String>> + }, true> + > + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + idNonNull: $.Field<'idNonNull', $Scalar.ID, null> + interface: $.Field<'interface', $.Output.Nullable, null> + interfaceNonNull: $.Field<'interfaceNonNull', Interface.Interface, null> + interfaceWithArgs: $.Field< + 'interfaceWithArgs', + $.Output.Nullable, + $.Args<{ + id: $.Input.Field<$Scalar.ID> + }, false> + > + listInt: $.Field<'listInt', $.Output.Nullable<$.Output.List<$.Output.Nullable<$Scalar.Int>>>, null> + listIntNonNull: $.Field<'listIntNonNull', $.Output.List<$Scalar.Int>, null> + listListInt: $.Field< + 'listListInt', + $.Output.Nullable<$.Output.List<$.Output.Nullable<$.Output.List<$.Output.Nullable<$Scalar.Int>>>>>, + null + > + listListIntNonNull: $.Field<'listListIntNonNull', $.Output.List<$.Output.List<$Scalar.Int>>, null> + lowerCaseUnion: $.Field<'lowerCaseUnion', $.Output.Nullable, null> + object: $.Field<'object', $.Output.Nullable, null> + objectList: $.Field<'objectList', $.Output.Nullable<$.Output.List>, null> + objectListNonNull: $.Field<'objectListNonNull', $.Output.List, null> + objectNested: $.Field<'objectNested', $.Output.Nullable, null> + objectNonNull: $.Field<'objectNonNull', Object.Object1, null> + objectWithArgs: $.Field< + 'objectWithArgs', + $.Output.Nullable, + $.Args<{ + boolean: $.Input.Field<$.Input.Nullable<$Scalar.Boolean>> + float: $.Input.Field<$.Input.Nullable<$Scalar.Float>> + id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> + int: $.Input.Field<$.Input.Nullable<$Scalar.Int>> + string: $.Input.Field<$.Input.Nullable<$Scalar.String>> + }, true> + > + result: $.Field< + 'result', + $.Output.Nullable, + $.Args<{ + case: $.Input.Field + }, false> + > + resultNonNull: $.Field< + 'resultNonNull', + Union.Result, + $.Args<{ + case: $.Input.Field<$.Input.Nullable> + }, true> + > + string: $.Field<'string', $.Output.Nullable<$Scalar.String>, null> + stringWithArgEnum: $.Field< + 'stringWithArgEnum', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + ABCEnum: $.Input.Field<$.Input.Nullable> + }, true> + > + stringWithArgInputObject: $.Field< + 'stringWithArgInputObject', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + input: $.Input.Field<$.Input.Nullable> + }, true> + > + stringWithArgInputObjectRequired: $.Field< + 'stringWithArgInputObjectRequired', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + input: $.Input.Field + }, false> + > + /** + * The given arguments are reflected back as a JSON string. + */ + stringWithArgs: $.Field< + 'stringWithArgs', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + boolean: $.Input.Field<$.Input.Nullable<$Scalar.Boolean>> + float: $.Input.Field<$.Input.Nullable<$Scalar.Float>> + id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> + int: $.Input.Field<$.Input.Nullable<$Scalar.Int>> + string: $.Input.Field<$.Input.Nullable<$Scalar.String>> + }, true> + > + stringWithListArg: $.Field< + 'stringWithListArg', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + ints: $.Input.Field<$.Input.Nullable<$.Input.List<$.Input.Nullable<$Scalar.Int>>>> + }, true> + > + stringWithListArgRequired: $.Field< + 'stringWithListArgRequired', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + ints: $.Input.Field<$.Input.List<$Scalar.Int>> + }, false> + > + stringWithRequiredArg: $.Field< + 'stringWithRequiredArg', + $.Output.Nullable<$Scalar.String>, + $.Args<{ + string: $.Input.Field<$Scalar.String> + }, false> + > + unionFooBar: $.Field<'unionFooBar', $.Output.Nullable, null> + unionFooBarNonNull: $.Field<'unionFooBarNonNull', Union.FooBarUnion, null> + unionFooBarWithArgs: $.Field< + 'unionFooBarWithArgs', + $.Output.Nullable, + $.Args<{ + id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> + }, true> + > + unionObject: $.Field<'unionObject', $.Output.Nullable, null> + unionObjectNonNull: $.Field<'unionObjectNonNull', Object.ObjectUnion, null> + }> +} +// ------------------------------------------------------------ // +// Enum // +// ------------------------------------------------------------ // +export namespace Enum { + /** + * Enum documentation. + * + * Members + * "A" - (DEPRECATED: Enum value A is deprecated.) + * "B" - Enum B member documentation. + * "C" - (DEPRECATED: Enum value C is deprecated.) + */ + export type ABCEnum = $.Enum<'ABCEnum', ['A', 'B', 'C']> + + export type Case = $.Enum<'Case', ['ErrorOne', 'ErrorTwo', 'Object1']> +} +// ------------------------------------------------------------ // +// InputObject // +// ------------------------------------------------------------ // +export namespace InputObject { + export type InputObject = $.InputObject<'InputObject', { + date: $.Input.Field<$.Input.Nullable<$Scalar.Date>> + dateRequired: $.Input.Field<$Scalar.Date> + id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> + idRequired: $.Input.Field<$Scalar.ID> + }, true> + + export type InputObjectCircular = $.InputObject<'InputObjectCircular', { + circular: $.Input.Field<$.Input.Nullable> + date: $.Input.Field<$.Input.Nullable<$Scalar.Date>> + }, true> + + export type InputObjectNested = $.InputObject<'InputObjectNested', { + InputObject: $.Input.Field<$.Input.Nullable> + }, true> + + export type InputObjectNestedNonNull = $.InputObject<'InputObjectNestedNonNull', { + InputObject: $.Input.Field + }, false> +} +// ------------------------------------------------------------ // +// Interface // +// ------------------------------------------------------------ // +export namespace Interface { + export type DateInterface1 = $.Interface<'DateInterface1', { + date1: $.Field<'date1', $.Output.Nullable<$Scalar.Date>, null> + }, [Object.DateObject1]> + + export type Error = $.Interface<'Error', { + message: $.Field<'message', $Scalar.String, null> + }, [Object.ErrorOne, Object.ErrorTwo]> + + export type Interface = $.Interface<'Interface', { + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + }, [Object.Object1ImplementingInterface, Object.Object2ImplementingInterface]> +} +// ------------------------------------------------------------ // +// Object // +// ------------------------------------------------------------ // +export namespace Object { + export type Bar = $.Object$2<'Bar', { + int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> + }> + + export type DateObject1 = $.Object$2<'DateObject1', { + date1: $.Field<'date1', $.Output.Nullable<$Scalar.Date>, null> + }> + + export type DateObject2 = $.Object$2<'DateObject2', { + date2: $.Field<'date2', $.Output.Nullable<$Scalar.Date>, null> + }> + + export type ErrorOne = $.Object$2<'ErrorOne', { + infoId: $.Field<'infoId', $.Output.Nullable<$Scalar.ID>, null> + message: $.Field<'message', $Scalar.String, null> + }> + + export type ErrorTwo = $.Object$2<'ErrorTwo', { + infoInt: $.Field<'infoInt', $.Output.Nullable<$Scalar.Int>, null> + message: $.Field<'message', $Scalar.String, null> + }> + + /** + * Object documentation. + */ + export type Foo = $.Object$2<'Foo', { + /** + * Field documentation. + * + * @deprecated Field a is deprecated. + */ + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + }> + + export type Object1 = $.Object$2<'Object1', { + boolean: $.Field<'boolean', $.Output.Nullable<$Scalar.Boolean>, null> + float: $.Field<'float', $.Output.Nullable<$Scalar.Float>, null> + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> + string: $.Field<'string', $.Output.Nullable<$Scalar.String>, null> + }> + + export type Object1ImplementingInterface = $.Object$2<'Object1ImplementingInterface', { + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> + }> + + export type Object2ImplementingInterface = $.Object$2<'Object2ImplementingInterface', { + boolean: $.Field<'boolean', $.Output.Nullable<$Scalar.Boolean>, null> + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + }> + + export type ObjectNested = $.Object$2<'ObjectNested', { + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + object: $.Field<'object', $.Output.Nullable, null> + }> + + export type ObjectUnion = $.Object$2<'ObjectUnion', { + fooBarUnion: $.Field<'fooBarUnion', $.Output.Nullable, null> + }> + + export type lowerCaseObject = $.Object$2<'lowerCaseObject', { + id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> + }> + + export type lowerCaseObject2 = $.Object$2<'lowerCaseObject2', { + int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> + }> +} +// ------------------------------------------------------------ // +// Union // +// ------------------------------------------------------------ // +export namespace Union { + export type DateUnion = $.Union<'DateUnion', [Object.DateObject1, Object.DateObject2]> + + /** + * Union documentation. + */ + export type FooBarUnion = $.Union<'FooBarUnion', [Object.Bar, Object.Foo]> + + export type Result = $.Union<'Result', [Object.ErrorOne, Object.ErrorTwo, Object.Object1]> + + export type lowerCaseUnion = $.Union<'lowerCaseUnion', [Object.lowerCaseObject, Object.lowerCaseObject2]> +} diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaDrivenDataMap.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaDrivenDataMap.ts new file mode 100644 index 000000000..df1e84c12 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaDrivenDataMap.ts @@ -0,0 +1,735 @@ +import type * as $Utilities from '../../../../../../entrypoints/utilities-for-generated.js' +import * as $Scalar from './Scalar.js' +// +// +// +// +// +// +// ================================================================================================== +// GraphQLScalarTypeStandard +// ================================================================================================== +// +// +// +// +// +// + +const Boolean = $Scalar.Boolean + +const Float = $Scalar.Float + +const ID = $Scalar.ID + +const Int = $Scalar.Int + +const String = $Scalar.String + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLScalarTypeCustom +// ================================================================================================== +// +// +// +// +// +// + +const Date = $Scalar.Date + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLEnumType +// ================================================================================================== +// +// +// +// +// +// + +const ABCEnum: $Utilities.SchemaDrivenDataMap.Enum = { + k: 'enum', + n: 'ABCEnum', +} + +const Case: $Utilities.SchemaDrivenDataMap.Enum = { + k: 'enum', + n: 'Case', +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLInputObjectType +// ================================================================================================== +// +// +// +// +// +// + +const InputObject: $Utilities.SchemaDrivenDataMap.InputObject = { + n: 'InputObject', + fcs: ['date', 'dateRequired'], + f: { + date: { + nt: Date, + }, + dateRequired: { + nt: Date, + }, + id: {}, + idRequired: {}, + }, +} + +const InputObjectCircular: $Utilities.SchemaDrivenDataMap.InputObject = { + n: 'InputObjectCircular', + fcs: ['circular', 'date'], + f: { + circular: { + // nt: InputObjectCircular, <-- Assigned later to avoid potential circular dependency. + }, + date: { + nt: Date, + }, + }, +} + +const InputObjectNested: $Utilities.SchemaDrivenDataMap.InputObject = { + n: 'InputObjectNested', + fcs: ['InputObject'], + f: { + InputObject: { + // nt: InputObject, <-- Assigned later to avoid potential circular dependency. + }, + }, +} + +const InputObjectNestedNonNull: $Utilities.SchemaDrivenDataMap.InputObject = { + n: 'InputObjectNestedNonNull', + fcs: ['InputObject'], + f: { + InputObject: { + // nt: InputObject, <-- Assigned later to avoid potential circular dependency. + }, + }, +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLObjectType +// ================================================================================================== +// +// +// +// +// +// + +const Bar: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + int: {}, + }, +} + +const DateObject1: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + date1: { + nt: Date, + }, + }, +} + +const DateObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + date2: { + nt: Date, + }, + }, +} + +const ErrorOne: $Utilities.SchemaDrivenDataMap.OutputObject = { + e: 1, + f: { + infoId: {}, + message: {}, + }, +} + +const ErrorTwo: $Utilities.SchemaDrivenDataMap.OutputObject = { + e: 1, + f: { + infoInt: {}, + message: {}, + }, +} + +const Foo: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + }, +} + +const Object1: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + boolean: {}, + float: {}, + id: {}, + int: {}, + string: {}, + }, +} + +const Object1ImplementingInterface: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + int: {}, + }, +} + +const Object2ImplementingInterface: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + boolean: {}, + id: {}, + }, +} + +const ObjectNested: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + object: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + }, +} + +const ObjectUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + fooBarUnion: { + // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. + }, + }, +} + +const lowerCaseObject: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + }, +} + +const lowerCaseObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + int: {}, + }, +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLInterfaceType +// ================================================================================================== +// +// +// +// +// +// + +const DateInterface1: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + ...DateObject1.f, + }, +} + +const Error: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +const Interface: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLUnionType +// ================================================================================================== +// +// +// +// +// +// + +const DateUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + ...DateObject1.f, + ...DateObject2.f, + }, +} + +const FooBarUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +const Result: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +const lowerCaseUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: {}, +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLRootType +// ================================================================================================== +// +// +// +// +// +// + +const Mutation: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + id: {}, + idNonNull: {}, + }, +} + +const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { + f: { + InputObjectNested: { + a: { + input: { + nt: InputObjectNested, + it: [0], + }, + }, + }, + InputObjectNestedNonNull: { + a: { + input: { + nt: InputObjectNestedNonNull, + it: [1], + }, + }, + }, + abcEnum: {}, + argInputObjectCircular: { + a: { + input: { + nt: InputObjectCircular, + it: [0], + }, + }, + }, + date: { + nt: Date, + }, + dateArg: { + a: { + date: { + nt: Date, + it: [0], + }, + }, + nt: Date, + }, + dateArgInputObject: { + a: { + input: { + nt: InputObject, + it: [0], + }, + }, + nt: Date, + }, + dateArgList: { + a: { + date: { + nt: Date, + it: [0, [1]], + }, + }, + nt: Date, + }, + dateArgNonNull: { + a: { + date: { + nt: Date, + it: [1], + }, + }, + nt: Date, + }, + dateArgNonNullList: { + a: { + date: { + nt: Date, + it: [1, [0]], + }, + }, + nt: Date, + }, + dateArgNonNullListNonNull: { + a: { + date: { + nt: Date, + it: [1, [1]], + }, + }, + nt: Date, + }, + dateInterface1: { + // nt: DateInterface1, <-- Assigned later to avoid potential circular dependency. + }, + dateList: { + nt: Date, + }, + dateListList: { + nt: Date, + }, + dateListNonNull: { + nt: Date, + }, + dateNonNull: { + nt: Date, + }, + dateObject1: { + // nt: DateObject1, <-- Assigned later to avoid potential circular dependency. + }, + dateUnion: { + // nt: DateUnion, <-- Assigned later to avoid potential circular dependency. + }, + error: { + a: { + case: { + nt: String, + it: [0], + }, + }, + }, + id: {}, + idNonNull: {}, + interface: { + // nt: Interface, <-- Assigned later to avoid potential circular dependency. + }, + interfaceNonNull: { + // nt: Interface, <-- Assigned later to avoid potential circular dependency. + }, + interfaceWithArgs: { + a: { + id: { + nt: ID, + it: [1], + }, + }, + // nt: Interface, <-- Assigned later to avoid potential circular dependency. + }, + listInt: {}, + listIntNonNull: {}, + listListInt: {}, + listListIntNonNull: {}, + lowerCaseUnion: { + // nt: lowerCaseUnion, <-- Assigned later to avoid potential circular dependency. + }, + object: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + objectList: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + objectListNonNull: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + objectNested: { + // nt: ObjectNested, <-- Assigned later to avoid potential circular dependency. + }, + objectNonNull: { + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + objectWithArgs: { + a: { + boolean: { + nt: Boolean, + it: [0], + }, + float: { + nt: Float, + it: [0], + }, + id: { + nt: ID, + it: [0], + }, + int: { + nt: Int, + it: [0], + }, + string: { + nt: String, + it: [0], + }, + }, + // nt: Object1, <-- Assigned later to avoid potential circular dependency. + }, + result: { + a: { + case: { + nt: Case, + it: [1], + }, + }, + r: 1, + // nt: Result, <-- Assigned later to avoid potential circular dependency. + }, + resultNonNull: { + a: { + case: { + nt: Case, + it: [0], + }, + }, + r: 1, + // nt: Result, <-- Assigned later to avoid potential circular dependency. + }, + string: {}, + stringWithArgEnum: { + a: { + ABCEnum: { + nt: ABCEnum, + it: [0], + }, + }, + }, + stringWithArgInputObject: { + a: { + input: { + nt: InputObject, + it: [0], + }, + }, + }, + stringWithArgInputObjectRequired: { + a: { + input: { + nt: InputObject, + it: [1], + }, + }, + }, + stringWithArgs: { + a: { + boolean: { + nt: Boolean, + it: [0], + }, + float: { + nt: Float, + it: [0], + }, + id: { + nt: ID, + it: [0], + }, + int: { + nt: Int, + it: [0], + }, + string: { + nt: String, + it: [0], + }, + }, + }, + stringWithListArg: { + a: { + ints: { + nt: Int, + it: [0, [0]], + }, + }, + }, + stringWithListArgRequired: { + a: { + ints: { + nt: Int, + it: [1, [1]], + }, + }, + }, + stringWithRequiredArg: { + a: { + string: { + nt: String, + it: [1], + }, + }, + }, + unionFooBar: { + // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. + }, + unionFooBarNonNull: { + // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. + }, + unionFooBarWithArgs: { + a: { + id: { + nt: ID, + it: [0], + }, + }, + // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. + }, + unionObject: { + // nt: ObjectUnion, <-- Assigned later to avoid potential circular dependency. + }, + unionObjectNonNull: { + // nt: ObjectUnion, <-- Assigned later to avoid potential circular dependency. + }, + }, +} + +// +// +// +// +// +// +// ================================================================================================== +// Reference Assignments +// (avoids circular assignment issues) +// ================================================================================================== +// +// +// +// +// +// + +InputObjectCircular.f![`circular`]!.nt = InputObjectCircular +InputObjectNested.f![`InputObject`]!.nt = InputObject +InputObjectNestedNonNull.f![`InputObject`]!.nt = InputObject +ObjectNested.f[`object`]!.nt = Object1 +ObjectUnion.f[`fooBarUnion`]!.nt = FooBarUnion +Query.f[`dateInterface1`]!.nt = DateInterface1 +Query.f[`dateObject1`]!.nt = DateObject1 +Query.f[`dateUnion`]!.nt = DateUnion +Query.f[`interface`]!.nt = Interface +Query.f[`interfaceNonNull`]!.nt = Interface +Query.f[`interfaceWithArgs`]!.nt = Interface +Query.f[`lowerCaseUnion`]!.nt = lowerCaseUnion +Query.f[`object`]!.nt = Object1 +Query.f[`objectList`]!.nt = Object1 +Query.f[`objectListNonNull`]!.nt = Object1 +Query.f[`objectNested`]!.nt = ObjectNested +Query.f[`objectNonNull`]!.nt = Object1 +Query.f[`objectWithArgs`]!.nt = Object1 +Query.f[`result`]!.nt = Result +Query.f[`resultNonNull`]!.nt = Result +Query.f[`unionFooBar`]!.nt = FooBarUnion +Query.f[`unionFooBarNonNull`]!.nt = FooBarUnion +Query.f[`unionFooBarWithArgs`]!.nt = FooBarUnion +Query.f[`unionObject`]!.nt = ObjectUnion +Query.f[`unionObjectNonNull`]!.nt = ObjectUnion + +// +// +// +// +// +// +// ================================================================================================== +// Index +// ================================================================================================== +// +// +// +// +// +// + +const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { + roots: { + Mutation, + Query, + }, + directives: {}, + types: { + Boolean, + Float, + ID, + Int, + String, + Date, + ABCEnum, + Case, + InputObject, + InputObjectCircular, + InputObjectNested, + InputObjectNestedNonNull, + Bar, + DateObject1, + DateObject2, + ErrorOne, + ErrorTwo, + Foo, + Object1, + Object1ImplementingInterface, + Object2ImplementingInterface, + ObjectNested, + ObjectUnion, + lowerCaseObject, + lowerCaseObject2, + DateInterface1, + Error, + Interface, + DateUnion, + FooBarUnion, + Result, + lowerCaseUnion, + Mutation, + Query, + }, +} + +export { $schemaDrivenDataMap as schemaDrivenDataMap } diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaIndex.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaIndex.ts new file mode 100644 index 000000000..aaa42cbef --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaIndex.ts @@ -0,0 +1,69 @@ +/* eslint-disable */ +import type * as Utilities from '../../../../../../entrypoints/utilities-for-generated.js' +import type * as Data from './Data.js' +import type * as MethodsRoot from './MethodsRoot.js' +import type * as Schema from './SchemaBuildtime.js' + +export interface Index { + name: Data.Name + RootTypesPresent: ['Mutation', 'Query'] + RootUnion: Schema.Root.Mutation | Schema.Root.Query + Root: { + Query: Schema.Root.Query + Mutation: Schema.Root.Mutation + Subscription: null + } + allTypes: { + Mutation: Schema.Root.Mutation + Query: Schema.Root.Query + ABCEnum: Schema.Enum.ABCEnum + Case: Schema.Enum.Case + Bar: Schema.Object.Bar + DateObject1: Schema.Object.DateObject1 + DateObject2: Schema.Object.DateObject2 + ErrorOne: Schema.Object.ErrorOne + ErrorTwo: Schema.Object.ErrorTwo + Foo: Schema.Object.Foo + Object1: Schema.Object.Object1 + Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface + Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface + ObjectNested: Schema.Object.ObjectNested + ObjectUnion: Schema.Object.ObjectUnion + lowerCaseObject: Schema.Object.lowerCaseObject + lowerCaseObject2: Schema.Object.lowerCaseObject2 + DateUnion: Schema.Union.DateUnion + FooBarUnion: Schema.Union.FooBarUnion + Result: Schema.Union.Result + lowerCaseUnion: Schema.Union.lowerCaseUnion + DateInterface1: Schema.Interface.DateInterface1 + Error: Schema.Interface.Error + Interface: Schema.Interface.Interface + } + objects: { + Bar: Schema.Object.Bar + DateObject1: Schema.Object.DateObject1 + DateObject2: Schema.Object.DateObject2 + ErrorOne: Schema.Object.ErrorOne + ErrorTwo: Schema.Object.ErrorTwo + Foo: Schema.Object.Foo + Object1: Schema.Object.Object1 + Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface + Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface + ObjectNested: Schema.Object.ObjectNested + ObjectUnion: Schema.Object.ObjectUnion + lowerCaseObject: Schema.Object.lowerCaseObject + lowerCaseObject2: Schema.Object.lowerCaseObject2 + } + unions: { + DateUnion: Schema.Union.DateUnion + FooBarUnion: Schema.Union.FooBarUnion + Result: Schema.Union.Result + lowerCaseUnion: Schema.Union.lowerCaseUnion + } + interfaces: { + DateInterface1: Schema.Interface.DateInterface1 + Error: Schema.Interface.Error + Interface: Schema.Interface.Interface + } + customScalars: Utilities.SchemaIndexBase['customScalars'] +} diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Select.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Select.ts new file mode 100644 index 000000000..c6f5c5d2d --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Select.ts @@ -0,0 +1,149 @@ +import type { InferResult } from '../../../../../../entrypoints/schema.js' +import * as Data from './Data.js' +import type { Index } from './Schema.js' +import type * as SelectionSets from './SelectionSets.js' + +// +// +// +// +// +// +// ================================================================================================== +// Runtime +// ================================================================================================== +// +// +// +// +// +// +import { createSelect } from '../../../../../../entrypoints/client.js' +export const Select = createSelect(Data.Name) + +// +// +// +// +// +// +// ================================================================================================== +// Buildtime +// ================================================================================================== +// +// +// +// +// +// + +export namespace Select { + // Root Types + // ---------- + export type Mutation<$SelectionSet extends SelectionSets.Mutation> = InferResult.Root< + $SelectionSet, + Index, + 'Mutation' + > + export type Query<$SelectionSet extends SelectionSets.Query> = InferResult.Root<$SelectionSet, Index, 'Query'> + // Object Types + // ------------ + export type Bar<$SelectionSet extends SelectionSets.Bar> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['Bar'] + > + export type DateObject1<$SelectionSet extends SelectionSets.DateObject1> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['DateObject1'] + > + export type DateObject2<$SelectionSet extends SelectionSets.DateObject2> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['DateObject2'] + > + export type ErrorOne<$SelectionSet extends SelectionSets.ErrorOne> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['ErrorOne'] + > + export type ErrorTwo<$SelectionSet extends SelectionSets.ErrorTwo> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['ErrorTwo'] + > + export type Foo<$SelectionSet extends SelectionSets.Foo> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['Foo'] + > + export type Object1<$SelectionSet extends SelectionSets.Object1> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['Object1'] + > + export type Object1ImplementingInterface<$SelectionSet extends SelectionSets.Object1ImplementingInterface> = + InferResult.Object<$SelectionSet, Index, Index['allTypes']['Object1ImplementingInterface']> + export type Object2ImplementingInterface<$SelectionSet extends SelectionSets.Object2ImplementingInterface> = + InferResult.Object<$SelectionSet, Index, Index['allTypes']['Object2ImplementingInterface']> + export type ObjectNested<$SelectionSet extends SelectionSets.ObjectNested> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['ObjectNested'] + > + export type ObjectUnion<$SelectionSet extends SelectionSets.ObjectUnion> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['ObjectUnion'] + > + export type lowerCaseObject<$SelectionSet extends SelectionSets.lowerCaseObject> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['lowerCaseObject'] + > + export type lowerCaseObject2<$SelectionSet extends SelectionSets.lowerCaseObject2> = InferResult.Object< + $SelectionSet, + Index, + Index['allTypes']['lowerCaseObject2'] + > + // Union Types + // ----------- + export type DateUnion<$SelectionSet extends SelectionSets.DateUnion> = InferResult.Union< + $SelectionSet, + Index, + Index['allTypes']['DateUnion'] + > + export type FooBarUnion<$SelectionSet extends SelectionSets.FooBarUnion> = InferResult.Union< + $SelectionSet, + Index, + Index['allTypes']['FooBarUnion'] + > + export type Result<$SelectionSet extends SelectionSets.Result> = InferResult.Union< + $SelectionSet, + Index, + Index['allTypes']['Result'] + > + export type lowerCaseUnion<$SelectionSet extends SelectionSets.lowerCaseUnion> = InferResult.Union< + $SelectionSet, + Index, + Index['allTypes']['lowerCaseUnion'] + > + // Interface Types + // --------------- + export type DateInterface1<$SelectionSet extends SelectionSets.DateInterface1> = InferResult.Interface< + $SelectionSet, + Index, + Index['allTypes']['DateInterface1'] + > + export type Error<$SelectionSet extends SelectionSets.Error> = InferResult.Interface< + $SelectionSet, + Index, + Index['allTypes']['Error'] + > + export type Interface<$SelectionSet extends SelectionSets.Interface> = InferResult.Interface< + $SelectionSet, + Index, + Index['allTypes']['Interface'] + > +} diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SelectionSets.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SelectionSets.ts new file mode 100644 index 000000000..51b17ad31 --- /dev/null +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SelectionSets.ts @@ -0,0 +1,2103 @@ +import type { Select as $Select } from '../../../../../../entrypoints/schema.js' +import type * as $Utilities from '../../../../../../entrypoints/utilities-for-generated.js' +import type * as $Scalar from './Scalar.js' + +// +// +// +// +// +// +// ================================================================================================== +// Document +// ================================================================================================== +// +// +// +// +// +// + +// Prefix with $ because this is not a schema type. A user could have a schema type named "Document" that this would conflict with. +export interface $Document { + query?: Record + mutation?: Record +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLObjectType Types +// ================================================================================================== +// +// +// +// +// +// + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Mutation +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Mutation { + /** + * Select the `id` field on the `Mutation` object. Its type is `ID` (a `Scalar`). + */ + id?: Mutation.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `idNonNull` field on the `Mutation` object. Its type is `ID` (a `Scalar`). + */ + idNonNull?: Mutation.idNonNull$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Mutation$FragmentInline | Mutation$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Mutation$FragmentInline extends Mutation, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Mutation { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `idNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type idNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type idNonNull = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Query +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Query { + /** + * Select the `InputObjectNested` field on the `Query` object. Its type is `ID` (a `Scalar`). + */ + InputObjectNested?: Query.InputObjectNested$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `InputObjectNestedNonNull` field on the `Query` object. Its type is `ID` (a `Scalar`). + */ + InputObjectNestedNonNull?: + | Query.InputObjectNestedNonNull + | $Select.SelectAlias.SelectAlias + /** + * Select the `abcEnum` field on the `Query` object. Its type is Enum. + */ + abcEnum?: Query.abcEnum$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `argInputObjectCircular` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + argInputObjectCircular?: + | Query.argInputObjectCircular$Expanded + | $Select.SelectAlias.SelectAlias + /** + * Select the `date` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + date?: Query.date$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArg` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArg?: Query.dateArg$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgInputObject` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgInputObject?: Query.dateArgInputObject$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgList` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgList?: Query.dateArgList$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgNonNull?: Query.dateArgNonNull | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgNonNullList` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgNonNullList?: Query.dateArgNonNullList | $Select.SelectAlias.SelectAlias + /** + * Select the `dateArgNonNullListNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateArgNonNullListNonNull?: + | Query.dateArgNonNullListNonNull + | $Select.SelectAlias.SelectAlias + /** + * Select the `dateInterface1` field on the `Query` object. Its type is Interface. + */ + dateInterface1?: Query.dateInterface1$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateList` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateList?: Query.dateList$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateListList` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateListList?: Query.dateListList$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateListNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateListNonNull?: Query.dateListNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). + */ + dateNonNull?: Query.dateNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateObject1` field on the `Query` object. Its type is Object. + */ + dateObject1?: Query.dateObject1$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `dateUnion` field on the `Query` object. Its type is Union. + */ + dateUnion?: Query.dateUnion$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `error` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + error?: Query.error$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `id` field on the `Query` object. Its type is `ID` (a `Scalar`). + */ + id?: Query.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `idNonNull` field on the `Query` object. Its type is `ID` (a `Scalar`). + */ + idNonNull?: Query.idNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `interface` field on the `Query` object. Its type is Interface. + */ + interface?: Query.$interface$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `interfaceNonNull` field on the `Query` object. Its type is Interface. + */ + interfaceNonNull?: Query.interfaceNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `interfaceWithArgs` field on the `Query` object. Its type is Interface. + */ + interfaceWithArgs?: Query.interfaceWithArgs | $Select.SelectAlias.SelectAlias + /** + * Select the `listInt` field on the `Query` object. Its type is `Int` (a `Scalar`). + */ + listInt?: Query.listInt$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `listIntNonNull` field on the `Query` object. Its type is `Int` (a `Scalar`). + */ + listIntNonNull?: Query.listIntNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `listListInt` field on the `Query` object. Its type is `Int` (a `Scalar`). + */ + listListInt?: Query.listListInt$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `listListIntNonNull` field on the `Query` object. Its type is `Int` (a `Scalar`). + */ + listListIntNonNull?: Query.listListIntNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `lowerCaseUnion` field on the `Query` object. Its type is Union. + */ + lowerCaseUnion?: Query.lowerCaseUnion$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `object` field on the `Query` object. Its type is Object. + */ + object?: Query.$object$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectList` field on the `Query` object. Its type is Object. + */ + objectList?: Query.objectList$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectListNonNull` field on the `Query` object. Its type is Object. + */ + objectListNonNull?: Query.objectListNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectNested` field on the `Query` object. Its type is Object. + */ + objectNested?: Query.objectNested$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectNonNull` field on the `Query` object. Its type is Object. + */ + objectNonNull?: Query.objectNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `objectWithArgs` field on the `Query` object. Its type is Object. + */ + objectWithArgs?: Query.objectWithArgs$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `result` field on the `Query` object. Its type is Union. + */ + result?: Query.result | $Select.SelectAlias.SelectAlias + /** + * Select the `resultNonNull` field on the `Query` object. Its type is Union. + */ + resultNonNull?: Query.resultNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `string` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + string?: Query.$string$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithArgEnum` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithArgEnum?: Query.stringWithArgEnum$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithArgInputObject` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithArgInputObject?: + | Query.stringWithArgInputObject$Expanded + | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithArgInputObjectRequired` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithArgInputObjectRequired?: + | Query.stringWithArgInputObjectRequired + | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithArgs` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithArgs?: Query.stringWithArgs$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithListArg` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithListArg?: Query.stringWithListArg$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithListArgRequired` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithListArgRequired?: + | Query.stringWithListArgRequired + | $Select.SelectAlias.SelectAlias + /** + * Select the `stringWithRequiredArg` field on the `Query` object. Its type is `String` (a `Scalar`). + */ + stringWithRequiredArg?: Query.stringWithRequiredArg | $Select.SelectAlias.SelectAlias + /** + * Select the `unionFooBar` field on the `Query` object. Its type is Union. + */ + unionFooBar?: Query.unionFooBar$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `unionFooBarNonNull` field on the `Query` object. Its type is Union. + */ + unionFooBarNonNull?: Query.unionFooBarNonNull$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `unionFooBarWithArgs` field on the `Query` object. Its type is Union. + */ + unionFooBarWithArgs?: Query.unionFooBarWithArgs$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `unionObject` field on the `Query` object. Its type is Object. + */ + unionObject?: Query.unionObject$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `unionObjectNonNull` field on the `Query` object. Its type is Object. + */ + unionObjectNonNull?: Query.unionObjectNonNull$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Query$FragmentInline | Query$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Query$FragmentInline extends Query, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Query { + export type InputObjectNested$SelectionSetArguments = { + input?: _RefDefs._InputObjectNested | undefined | null + } + export type InputObjectNested$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `InputObjectNested` field. + * No arguments are required so you may omit this. + */ + $?: InputObjectNested$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `InputObjectNested` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type InputObjectNested$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | InputObjectNested$SelectionSet + > + + export type InputObjectNested = $Select.Indicator.Indicator | InputObjectNested$SelectionSet + + export type InputObjectNestedNonNull$SelectionSetArguments = { + input: _RefDefs._InputObjectNestedNonNull + } + export interface InputObjectNestedNonNull extends $Select.Bases.Base { + /** + * Arguments for `InputObjectNestedNonNull` field. + * All arguments are required so you must include this. + */ + $: InputObjectNestedNonNull$SelectionSetArguments + } + + /** + * This is the "expanded" version of the `abcEnum` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type abcEnum$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type abcEnum = $Select.Indicator.NoArgsIndicator + + export type argInputObjectCircular$SelectionSetArguments = { + input?: _RefDefs._InputObjectCircular | undefined | null + } + export type argInputObjectCircular$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `argInputObjectCircular` field. + * No arguments are required so you may omit this. + */ + $?: argInputObjectCircular$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `argInputObjectCircular` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type argInputObjectCircular$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | argInputObjectCircular$SelectionSet + > + + export type argInputObjectCircular = $Select.Indicator.Indicator | argInputObjectCircular$SelectionSet + + /** + * This is the "expanded" version of the `date` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type date$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type date = $Select.Indicator.NoArgsIndicator + + export type dateArg$SelectionSetArguments = { + date?: undefined | undefined | null + } + export type dateArg$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `dateArg` field. + * No arguments are required so you may omit this. + */ + $?: dateArg$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `dateArg` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateArg$Expanded = $Utilities.UnionExpanded<$Select.Indicator.Indicator | dateArg$SelectionSet> + + export type dateArg = $Select.Indicator.Indicator | dateArg$SelectionSet + + export type dateArgInputObject$SelectionSetArguments = { + input?: _RefDefs._InputObject | undefined | null + } + export type dateArgInputObject$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `dateArgInputObject` field. + * No arguments are required so you may omit this. + */ + $?: dateArgInputObject$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `dateArgInputObject` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateArgInputObject$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | dateArgInputObject$SelectionSet + > + + export type dateArgInputObject = $Select.Indicator.Indicator | dateArgInputObject$SelectionSet + + export type dateArgList$SelectionSetArguments = { + date?: Array | undefined | null + } + export type dateArgList$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `dateArgList` field. + * No arguments are required so you may omit this. + */ + $?: dateArgList$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `dateArgList` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateArgList$Expanded = $Utilities.UnionExpanded<$Select.Indicator.Indicator | dateArgList$SelectionSet> + + export type dateArgList = $Select.Indicator.Indicator | dateArgList$SelectionSet + + export type dateArgNonNull$SelectionSetArguments = { + date: undefined + } + export interface dateArgNonNull extends $Select.Bases.Base { + /** + * Arguments for `dateArgNonNull` field. + * All arguments are required so you must include this. + */ + $: dateArgNonNull$SelectionSetArguments + } + + export type dateArgNonNullList$SelectionSetArguments = { + date: Array + } + export interface dateArgNonNullList extends $Select.Bases.Base { + /** + * Arguments for `dateArgNonNullList` field. + * All arguments are required so you must include this. + */ + $: dateArgNonNullList$SelectionSetArguments + } + + export type dateArgNonNullListNonNull$SelectionSetArguments = { + date: Array + } + export interface dateArgNonNullListNonNull extends $Select.Bases.Base { + /** + * Arguments for `dateArgNonNullListNonNull` field. + * All arguments are required so you must include this. + */ + $: dateArgNonNullListNonNull$SelectionSetArguments + } + + export interface dateInterface1 extends _RefDefs._DateInterface1 {} + export type dateInterface1$Expanded = dateInterface1 + /** + * This is the "expanded" version of the `dateList` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateList$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type dateList = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `dateListList` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateListList$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type dateListList = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `dateListNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateListNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type dateListNonNull = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `dateNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type dateNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type dateNonNull = $Select.Indicator.NoArgsIndicator + + export interface dateObject1 extends _RefDefs._DateObject1 {} + export type dateObject1$Expanded = dateObject1 + export interface dateUnion extends _RefDefs._DateUnion {} + export type dateUnion$Expanded = dateUnion + export type error$SelectionSetArguments = { + case?: string | undefined | null + } + export type error$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `error` field. + * No arguments are required so you may omit this. + */ + $?: error$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `error` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type error$Expanded = $Utilities.UnionExpanded<$Select.Indicator.Indicator | error$SelectionSet> + + export type error = $Select.Indicator.Indicator | error$SelectionSet + + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `idNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type idNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type idNonNull = $Select.Indicator.NoArgsIndicator + + export interface $interface extends _RefDefs._Interface {} + export type $interface$Expanded = $interface + export interface interfaceNonNull extends _RefDefs._Interface {} + export type interfaceNonNull$Expanded = interfaceNonNull + export interface interfaceWithArgs extends _RefDefs._Interface { + /** + * Arguments for `interfaceWithArgs` field. + * All arguments are required so you must include this. + */ + $: { + id: string + } + } + export type interfaceWithArgs$Expanded = interfaceWithArgs + /** + * This is the "expanded" version of the `listInt` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type listInt$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type listInt = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `listIntNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type listIntNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type listIntNonNull = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `listListInt` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type listListInt$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type listListInt = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `listListIntNonNull` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type listListIntNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type listListIntNonNull = $Select.Indicator.NoArgsIndicator + + export interface lowerCaseUnion extends _RefDefs._lowerCaseUnion {} + export type lowerCaseUnion$Expanded = lowerCaseUnion + export interface $object extends _RefDefs._Object1 {} + export type $object$Expanded = $object + export interface objectList extends _RefDefs._Object1 {} + export type objectList$Expanded = objectList + export interface objectListNonNull extends _RefDefs._Object1 {} + export type objectListNonNull$Expanded = objectListNonNull + export interface objectNested extends _RefDefs._ObjectNested {} + export type objectNested$Expanded = objectNested + export interface objectNonNull extends _RefDefs._Object1 {} + export type objectNonNull$Expanded = objectNonNull + export interface objectWithArgs extends _RefDefs._Object1 { + /** + * Arguments for `objectWithArgs` field. + * No arguments are required so you may omit this. + */ + $?: { + boolean?: boolean | undefined | null + float?: number | undefined | null + id?: string | undefined | null + int?: number | undefined | null + string?: string | undefined | null + } + } + export type objectWithArgs$Expanded = objectWithArgs + export interface result extends _RefDefs._Result { + /** + * Arguments for `result` field. + * All arguments are required so you must include this. + */ + $: { + $case: _RefDefs._Case + } + } + export type result$Expanded = result + export interface resultNonNull extends _RefDefs._Result { + /** + * Arguments for `resultNonNull` field. + * No arguments are required so you may omit this. + */ + $?: { + $case?: _RefDefs._Case | undefined | null + } + } + export type resultNonNull$Expanded = resultNonNull + /** + * This is the "expanded" version of the `$string` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type $string$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type $string = $Select.Indicator.NoArgsIndicator + + export type stringWithArgEnum$SelectionSetArguments = { + $ABCEnum?: _RefDefs._ABCEnum | undefined | null + } + export type stringWithArgEnum$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `stringWithArgEnum` field. + * No arguments are required so you may omit this. + */ + $?: stringWithArgEnum$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `stringWithArgEnum` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type stringWithArgEnum$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | stringWithArgEnum$SelectionSet + > + + export type stringWithArgEnum = $Select.Indicator.Indicator | stringWithArgEnum$SelectionSet + + export type stringWithArgInputObject$SelectionSetArguments = { + input?: _RefDefs._InputObject | undefined | null + } + export type stringWithArgInputObject$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `stringWithArgInputObject` field. + * No arguments are required so you may omit this. + */ + $?: stringWithArgInputObject$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `stringWithArgInputObject` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type stringWithArgInputObject$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | stringWithArgInputObject$SelectionSet + > + + export type stringWithArgInputObject = $Select.Indicator.Indicator | stringWithArgInputObject$SelectionSet + + export type stringWithArgInputObjectRequired$SelectionSetArguments = { + input: _RefDefs._InputObject + } + export interface stringWithArgInputObjectRequired extends $Select.Bases.Base { + /** + * Arguments for `stringWithArgInputObjectRequired` field. + * All arguments are required so you must include this. + */ + $: stringWithArgInputObjectRequired$SelectionSetArguments + } + + export type stringWithArgs$SelectionSetArguments = { + boolean?: boolean | undefined | null + float?: number | undefined | null + id?: string | undefined | null + int?: number | undefined | null + string?: string | undefined | null + } + export type stringWithArgs$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `stringWithArgs` field. + * No arguments are required so you may omit this. + */ + $?: stringWithArgs$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `stringWithArgs` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type stringWithArgs$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | stringWithArgs$SelectionSet + > + + export type stringWithArgs = $Select.Indicator.Indicator | stringWithArgs$SelectionSet + + export type stringWithListArg$SelectionSetArguments = { + ints?: Array | undefined | null + } + export type stringWithListArg$SelectionSet = $Utilities.Simplify< + $Select.Bases.Base & { + /** + * Arguments for `stringWithListArg` field. + * No arguments are required so you may omit this. + */ + $?: stringWithListArg$SelectionSetArguments + } + > + + /** + * This is the "expanded" version of the `stringWithListArg` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type stringWithListArg$Expanded = $Utilities.UnionExpanded< + $Select.Indicator.Indicator | stringWithListArg$SelectionSet + > + + export type stringWithListArg = $Select.Indicator.Indicator | stringWithListArg$SelectionSet + + export type stringWithListArgRequired$SelectionSetArguments = { + ints: Array + } + export interface stringWithListArgRequired extends $Select.Bases.Base { + /** + * Arguments for `stringWithListArgRequired` field. + * All arguments are required so you must include this. + */ + $: stringWithListArgRequired$SelectionSetArguments + } + + export type stringWithRequiredArg$SelectionSetArguments = { + string: string + } + export interface stringWithRequiredArg extends $Select.Bases.Base { + /** + * Arguments for `stringWithRequiredArg` field. + * All arguments are required so you must include this. + */ + $: stringWithRequiredArg$SelectionSetArguments + } + + export interface unionFooBar extends _RefDefs._FooBarUnion {} + export type unionFooBar$Expanded = unionFooBar + export interface unionFooBarNonNull extends _RefDefs._FooBarUnion {} + export type unionFooBarNonNull$Expanded = unionFooBarNonNull + export interface unionFooBarWithArgs extends _RefDefs._FooBarUnion { + /** + * Arguments for `unionFooBarWithArgs` field. + * No arguments are required so you may omit this. + */ + $?: { + id?: string | undefined | null + } + } + export type unionFooBarWithArgs$Expanded = unionFooBarWithArgs + export interface unionObject extends _RefDefs._ObjectUnion {} + export type unionObject$Expanded = unionObject + export interface unionObjectNonNull extends _RefDefs._ObjectUnion {} + export type unionObjectNonNull$Expanded = unionObjectNonNull +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLEnumType Types +// ================================================================================================== +// +// +// +// +// +// + +/** + * Enum documentation. + * + * Members + * "A" - (DEPRECATED: Enum value A is deprecated.) + * "B" - Enum B member documentation. + * "C" - (DEPRECATED: Enum value C is deprecated.) + */ +export type ABCEnum = 'A' | 'B' | 'C' + +export type Case = 'ErrorOne' | 'ErrorTwo' | 'Object1' + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLInputObjectType Types +// ================================================================================================== +// +// +// +// +// +// + +export interface InputObject { + date?: undefined | undefined | null + dateRequired: undefined + id?: string | undefined | null + idRequired: string +} + +export interface InputObjectCircular { + circular?: _RefDefs._InputObjectCircular | undefined | null + date?: undefined | undefined | null +} + +export interface InputObjectNested { + InputObject?: _RefDefs._InputObject | undefined | null +} + +export interface InputObjectNestedNonNull { + InputObject: _RefDefs._InputObject +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLInterfaceType Types +// ================================================================================================== +// +// +// +// +// +// + +// -------------- +// Interface Type DateInterface1 +// -------------- + +export interface DateInterface1 extends $Select.Bases.ObjectLike { + date1?: DateInterface1.date1 + ___on_DateObject1?: DateObject1 + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: DateInterface1$FragmentInline | DateInterface1$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a interface type and thus polymorphic, + * the name is one of the implementor type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface DateInterface1$FragmentInline + extends DateInterface1, $Select.Directive.$Groups.InlineFragment.Fields +{} + +export namespace DateInterface1 { + /** + * This is the "expanded" version of the `date1` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type date1$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type date1 = $Select.Indicator.NoArgsIndicator +} + +// -------------- +// Interface Type Error +// -------------- + +export interface Error extends $Select.Bases.ObjectLike { + message?: Error.message + ___on_ErrorOne?: ErrorOne + ___on_ErrorTwo?: ErrorTwo + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Error$FragmentInline | Error$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a interface type and thus polymorphic, + * the name is one of the implementor type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Error$FragmentInline extends Error, $Select.Directive.$Groups.InlineFragment.Fields {} + +export namespace Error { + /** + * This is the "expanded" version of the `message` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type message$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type message = $Select.Indicator.NoArgsIndicator +} + +// -------------- +// Interface Type Interface +// -------------- + +export interface Interface extends $Select.Bases.ObjectLike { + id?: Interface.id + ___on_Object1ImplementingInterface?: Object1ImplementingInterface + ___on_Object2ImplementingInterface?: Object2ImplementingInterface + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Interface$FragmentInline | Interface$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a interface type and thus polymorphic, + * the name is one of the implementor type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Interface$FragmentInline extends Interface, $Select.Directive.$Groups.InlineFragment.Fields {} + +export namespace Interface { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLObjectType Types +// ================================================================================================== +// +// +// +// +// +// + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Bar +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Bar extends $Select.Bases.ObjectLike { + /** + * Select the `int` field on the `Bar` object. Its type is `Int` (a `Scalar`). + */ + int?: Bar.int$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Bar$FragmentInline | Bar$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Bar$FragmentInline extends Bar, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Bar { + /** + * This is the "expanded" version of the `int` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type int = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// DateObject1 +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface DateObject1 extends $Select.Bases.ObjectLike { + /** + * Select the `date1` field on the `DateObject1` object. Its type is `Date` (a `Scalar`). + */ + date1?: DateObject1.date1$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: DateObject1$FragmentInline | DateObject1$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface DateObject1$FragmentInline extends DateObject1, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace DateObject1 { + /** + * This is the "expanded" version of the `date1` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type date1$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type date1 = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// DateObject2 +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface DateObject2 extends $Select.Bases.ObjectLike { + /** + * Select the `date2` field on the `DateObject2` object. Its type is `Date` (a `Scalar`). + */ + date2?: DateObject2.date2$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: DateObject2$FragmentInline | DateObject2$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface DateObject2$FragmentInline extends DateObject2, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace DateObject2 { + /** + * This is the "expanded" version of the `date2` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type date2$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type date2 = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// ErrorOne +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface ErrorOne extends $Select.Bases.ObjectLike { + /** + * Select the `infoId` field on the `ErrorOne` object. Its type is `ID` (a `Scalar`). + */ + infoId?: ErrorOne.infoId$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `message` field on the `ErrorOne` object. Its type is `String` (a `Scalar`). + */ + message?: ErrorOne.message$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: ErrorOne$FragmentInline | ErrorOne$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface ErrorOne$FragmentInline extends ErrorOne, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace ErrorOne { + /** + * This is the "expanded" version of the `infoId` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type infoId$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type infoId = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `message` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type message$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type message = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// ErrorTwo +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface ErrorTwo extends $Select.Bases.ObjectLike { + /** + * Select the `infoInt` field on the `ErrorTwo` object. Its type is `Int` (a `Scalar`). + */ + infoInt?: ErrorTwo.infoInt$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `message` field on the `ErrorTwo` object. Its type is `String` (a `Scalar`). + */ + message?: ErrorTwo.message$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: ErrorTwo$FragmentInline | ErrorTwo$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface ErrorTwo$FragmentInline extends ErrorTwo, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace ErrorTwo { + /** + * This is the "expanded" version of the `infoInt` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type infoInt$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type infoInt = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `message` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type message$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type message = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Foo +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +/** + * Object documentation. + */ +export interface Foo extends $Select.Bases.ObjectLike { + /** + * Select the `id` field on the `Foo` object. Its type is `ID` (a `Scalar`). + */ + id?: Foo.id$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Foo$FragmentInline | Foo$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Foo$FragmentInline extends Foo, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Foo { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Object1 +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Object1 extends $Select.Bases.ObjectLike { + /** + * Select the `boolean` field on the `Object1` object. Its type is `Boolean` (a `Scalar`). + */ + boolean?: Object1.$boolean$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `float` field on the `Object1` object. Its type is `Float` (a `Scalar`). + */ + float?: Object1.float$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `id` field on the `Object1` object. Its type is `ID` (a `Scalar`). + */ + id?: Object1.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `int` field on the `Object1` object. Its type is `Int` (a `Scalar`). + */ + int?: Object1.int$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `string` field on the `Object1` object. Its type is `String` (a `Scalar`). + */ + string?: Object1.$string$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Object1$FragmentInline | Object1$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Object1$FragmentInline extends Object1, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace Object1 { + /** + * This is the "expanded" version of the `$boolean` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type $boolean$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type $boolean = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `float` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type float$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type float = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `int` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type int = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `$string` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type $string$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type $string = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Object1ImplementingInterface +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Object1ImplementingInterface extends $Select.Bases.ObjectLike { + /** + * Select the `id` field on the `Object1ImplementingInterface` object. Its type is `ID` (a `Scalar`). + */ + id?: Object1ImplementingInterface.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `int` field on the `Object1ImplementingInterface` object. Its type is `Int` (a `Scalar`). + */ + int?: Object1ImplementingInterface.int$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Object1ImplementingInterface$FragmentInline | Object1ImplementingInterface$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Object1ImplementingInterface$FragmentInline + extends Object1ImplementingInterface, $Select.Directive.$Groups.InlineFragment.Fields +{} + +// ----------------------------------------| Fields Interfaces | + +export namespace Object1ImplementingInterface { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `int` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type int = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// Object2ImplementingInterface +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface Object2ImplementingInterface extends $Select.Bases.ObjectLike { + /** + * Select the `boolean` field on the `Object2ImplementingInterface` object. Its type is `Boolean` (a `Scalar`). + */ + boolean?: + | Object2ImplementingInterface.$boolean$Expanded + | $Select.SelectAlias.SelectAlias + /** + * Select the `id` field on the `Object2ImplementingInterface` object. Its type is `ID` (a `Scalar`). + */ + id?: Object2ImplementingInterface.id$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Object2ImplementingInterface$FragmentInline | Object2ImplementingInterface$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface Object2ImplementingInterface$FragmentInline + extends Object2ImplementingInterface, $Select.Directive.$Groups.InlineFragment.Fields +{} + +// ----------------------------------------| Fields Interfaces | + +export namespace Object2ImplementingInterface { + /** + * This is the "expanded" version of the `$boolean` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type $boolean$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type $boolean = $Select.Indicator.NoArgsIndicator + + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// ObjectNested +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface ObjectNested extends $Select.Bases.ObjectLike { + /** + * Select the `id` field on the `ObjectNested` object. Its type is `ID` (a `Scalar`). + */ + id?: ObjectNested.id$Expanded | $Select.SelectAlias.SelectAlias + /** + * Select the `object` field on the `ObjectNested` object. Its type is Object. + */ + object?: ObjectNested.$object$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: ObjectNested$FragmentInline | ObjectNested$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface ObjectNested$FragmentInline extends ObjectNested, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace ObjectNested { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator + + export interface $object extends _RefDefs._Object1 {} + export type $object$Expanded = $object +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// ObjectUnion +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface ObjectUnion extends $Select.Bases.ObjectLike { + /** + * Select the `fooBarUnion` field on the `ObjectUnion` object. Its type is Union. + */ + fooBarUnion?: ObjectUnion.fooBarUnion$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: ObjectUnion$FragmentInline | ObjectUnion$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface ObjectUnion$FragmentInline extends ObjectUnion, $Select.Directive.$Groups.InlineFragment.Fields {} + +// ----------------------------------------| Fields Interfaces | + +export namespace ObjectUnion { + export interface fooBarUnion extends _RefDefs._FooBarUnion {} + export type fooBarUnion$Expanded = fooBarUnion +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// lowerCaseObject +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface lowerCaseObject extends $Select.Bases.ObjectLike { + /** + * Select the `id` field on the `lowerCaseObject` object. Its type is `ID` (a `Scalar`). + */ + id?: lowerCaseObject.id$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: lowerCaseObject$FragmentInline | lowerCaseObject$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface lowerCaseObject$FragmentInline + extends lowerCaseObject, $Select.Directive.$Groups.InlineFragment.Fields +{} + +// ----------------------------------------| Fields Interfaces | + +export namespace lowerCaseObject { + /** + * This is the "expanded" version of the `id` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type id = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// GRAPHQL SELECTION SET +// OBJECT +// -------------------------------------------------------------------------------------------------- +// lowerCaseObject2 +// -------------------------------------------------------------------------------------------------- +// +// + +// ----------------------------------------| Entrypoint Interface | + +export interface lowerCaseObject2 extends $Select.Bases.ObjectLike { + /** + * Select the `int` field on the `lowerCaseObject2` object. Its type is `Int` (a `Scalar`). + */ + int?: lowerCaseObject2.int$Expanded | $Select.SelectAlias.SelectAlias + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: lowerCaseObject2$FragmentInline | lowerCaseObject2$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} + +export interface lowerCaseObject2$FragmentInline + extends lowerCaseObject2, $Select.Directive.$Groups.InlineFragment.Fields +{} + +// ----------------------------------------| Fields Interfaces | + +export namespace lowerCaseObject2 { + /** + * This is the "expanded" version of the `int` type. It is identical except for the fact + * that IDEs will display its contents (a union type) directly, rather than the name of this type. + * In some cases, this is a preferable DX, making the types easier to read for users. + */ + export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded + + export type int = $Select.Indicator.NoArgsIndicator +} + +// +// +// +// +// +// +// ================================================================================================== +// GraphQLUnionType Types +// ================================================================================================== +// +// +// +// +// +// + +export interface DateUnion { + ___on_DateObject1?: DateObject1 + ___on_DateObject2?: DateObject2 + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: DateUnion$FragmentInline | DateUnion$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, + * the name is one of the member type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} +export interface DateUnion$FragmentInline extends DateUnion, $Select.Directive.$Groups.InlineFragment.Fields {} + +/** + * Union documentation. + */ +export interface FooBarUnion { + ___on_Bar?: Bar + ___on_Foo?: Foo + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: FooBarUnion$FragmentInline | FooBarUnion$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, + * the name is one of the member type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} +export interface FooBarUnion$FragmentInline extends FooBarUnion, $Select.Directive.$Groups.InlineFragment.Fields {} + +export interface Result { + ___on_ErrorOne?: ErrorOne + ___on_ErrorTwo?: ErrorTwo + ___on_Object1?: Object1 + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: Result$FragmentInline | Result$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, + * the name is one of the member type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} +export interface Result$FragmentInline extends Result, $Select.Directive.$Groups.InlineFragment.Fields {} + +export interface lowerCaseUnion { + ___on_lowerCaseObject?: lowerCaseObject + ___on_lowerCaseObject2?: lowerCaseObject2 + + /** + * Inline fragments for field groups. + * + * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the + * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. + * + * @see https://spec.graphql.org/draft/#sec-Inline-Fragments + */ + ___?: lowerCaseUnion$FragmentInline | lowerCaseUnion$FragmentInline[] + + /** + * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, + * the name is one of the member type names, whichever is ultimately returned at runtime. + * + * @see https://graphql.org/learn/queries/#meta-fields + */ + __typename?: + | $Select.Indicator.NoArgsIndicator$Expanded + | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> +} +export interface lowerCaseUnion$FragmentInline + extends lowerCaseUnion, $Select.Directive.$Groups.InlineFragment.Fields +{} + +/** + * [1] These definitions serve to allow field selection interfaces to extend their respective object type without + * name clashing between the field name and the object name. + * + * For example imagine `Query.Foo` field with type also called `Foo`. Our generated interfaces for each field + * would end up with an error of `export interface Foo extends Foo ...` + */ +export namespace _RefDefs { + export type _Mutation = Mutation + export type _Query = Query + export type _ABCEnum = ABCEnum + export type _Case = Case + export type _InputObject = InputObject + export type _InputObjectCircular = InputObjectCircular + export type _InputObjectNested = InputObjectNested + export type _InputObjectNestedNonNull = InputObjectNestedNonNull + export type _DateInterface1 = DateInterface1 + export type _Error = Error + export type _Interface = Interface + export type _Bar = Bar + export type _DateObject1 = DateObject1 + export type _DateObject2 = DateObject2 + export type _ErrorOne = ErrorOne + export type _ErrorTwo = ErrorTwo + export type _Foo = Foo + export type _Object1 = Object1 + export type _Object1ImplementingInterface = Object1ImplementingInterface + export type _Object2ImplementingInterface = Object2ImplementingInterface + export type _ObjectNested = ObjectNested + export type _ObjectUnion = ObjectUnion + export type _lowerCaseObject = lowerCaseObject + export type _lowerCaseObject2 = lowerCaseObject2 + export type _DateUnion = DateUnion + export type _FooBarUnion = FooBarUnion + export type _Result = Result + export type _lowerCaseUnion = lowerCaseUnion +} diff --git a/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts b/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts index 775261cb9..e4fcb96f2 100644 --- a/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts +++ b/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts @@ -106,6 +106,7 @@ export type $Any = | Boolean | ID | Float + // eslint-disable-next-line | Values type Values = T extends any ? keyof T extends never ? never : T[keyof T] : never diff --git a/src/layers/1_Schema/Output/Output.ts b/src/layers/1_Schema/Output/Output.ts index 564526a89..ee4d3f299 100644 --- a/src/layers/1_Schema/Output/Output.ts +++ b/src/layers/1_Schema/Output/Output.ts @@ -1,4 +1,4 @@ -import type { TSErrorDescriptive } from '../../../lib/TSError.js' +import type { TSErrorDescriptive } from '../../../lib/ts-error.js' import { readMaybeThunk } from '../core/helpers.js' import type { Any, Named } from './typeGroups.js' import type { __typename } from './types/__typename.js' diff --git a/src/layers/1_Schema/__.ts b/src/layers/1_Schema/__.ts index ae38428c6..14197dace 100644 --- a/src/layers/1_Schema/__.ts +++ b/src/layers/1_Schema/__.ts @@ -1,2 +1,2 @@ -export * as Schema from './_.js' +export * as SchemaKit from './_.js' export * from './_.js' diff --git a/src/layers/2_Select/Directive/$types.ts b/src/layers/2_Select/Directive/$types.ts index f73c2a828..c3760254e 100644 --- a/src/layers/2_Select/Directive/$types.ts +++ b/src/layers/2_Select/Directive/$types.ts @@ -1,9 +1,9 @@ -import type { Schema } from '../../1_Schema/__.js' +import type { SchemaKit } from '../../1_Schema/__.js' import type { Include, Skip } from './_.js' export interface Definition { name: string - type: Schema.Directives.Directive + type: SchemaKit.Directives.Directive normalizeArguments: (args: any) => Record } diff --git a/src/layers/2_Select/Directive/include.ts b/src/layers/2_Select/Directive/include.ts index 478c75f2e..697fa697f 100644 --- a/src/layers/2_Select/Directive/include.ts +++ b/src/layers/2_Select/Directive/include.ts @@ -1,10 +1,10 @@ import { shallowMergeDefaults } from '../../../lib/prelude.js' -import { Schema } from '../../1_Schema/__.js' +import { SchemaKit } from '../../1_Schema/__.js' import type { Definition } from './$types.js' export const Include: Definition = { name: `include`, - type: Schema.Directives.standardDirectivesByName.include, + type: SchemaKit.Directives.standardDirectivesByName.include, normalizeArguments: (input: ArgsInput): Args => { return typeof input === `boolean` ? expandShortHand(input) diff --git a/src/layers/2_Select/Directive/skip.ts b/src/layers/2_Select/Directive/skip.ts index 742c268a3..9169a3a2e 100644 --- a/src/layers/2_Select/Directive/skip.ts +++ b/src/layers/2_Select/Directive/skip.ts @@ -1,9 +1,9 @@ -import { Schema } from '../../1_Schema/__.js' +import { SchemaKit } from '../../1_Schema/__.js' import type { Definition } from './$types.js' export const Skip: Definition = { name: `skip`, - type: Schema.Directives.standardDirectivesByName.skip, + type: SchemaKit.Directives.standardDirectivesByName.skip, normalizeArguments: (args: ArgsInput): Args => { return { if: typeof args === `boolean` ? args : args.if === undefined ? true : args.if, diff --git a/src/layers/3_InferResult/Alias.ts b/src/layers/3_InferResult/Alias.ts index 5278811f0..aadcb5b79 100644 --- a/src/layers/3_InferResult/Alias.ts +++ b/src/layers/3_InferResult/Alias.ts @@ -1,14 +1,14 @@ import type { mergeObjectArray, ValuesOrEmptyObject } from '../../lib/prelude.js' -import type { Schema } from '../1_Schema/__.js' +import type { SchemaKit } from '../1_Schema/__.js' import type { Select } from '../2_Select/__.js' -import type { SchemaIndex } from '../4_generator/generators/SchemaIndex.js' +import type { Schema } from '../4_generator/generators/Schema.js' import type { Field } from './Field.js' // dprint-ignore export type Alias< $SelectionSet, - $Schema extends SchemaIndex, - $Node extends Schema.Output.Object$2 + $Schema extends Schema, + $Node extends SchemaKit.Output.Object$2 > = ValuesOrEmptyObject< { @@ -31,8 +31,8 @@ export type Alias< type InferSelectAlias< $SelectAlias extends Select.SelectAlias.SelectAlias, $FieldName extends string, - $Schema extends SchemaIndex, - $Node extends Schema.Output.Object$2, + $Schema extends Schema, + $Node extends SchemaKit.Output.Object$2, > = $SelectAlias extends Select.SelectAlias.SelectAliasOne ? InferSelectAliasOne<$SelectAlias, $FieldName, $Schema, $Node> : $SelectAlias extends Select.SelectAlias.SelectAliasMultiple ? InferSelectAliasMultiple<$SelectAlias, $FieldName, $Schema, $Node> : @@ -41,8 +41,8 @@ type InferSelectAlias< type InferSelectAliasMultiple< $SelectAliasMultiple extends Select.SelectAlias.SelectAliasMultiple, $FieldName extends string, - $Schema extends SchemaIndex, - $Node extends Schema.Output.Object$2, + $Schema extends Schema, + $Node extends SchemaKit.Output.Object$2, > = mergeObjectArray< { [_ in keyof $SelectAliasMultiple]: InferSelectAliasOne<$SelectAliasMultiple[_], $FieldName, $Schema, $Node> @@ -52,8 +52,8 @@ type InferSelectAliasMultiple< type InferSelectAliasOne< $SelectAliasOne extends Select.SelectAlias.SelectAliasOne, $FieldName extends string, - $Schema extends SchemaIndex, - $Node extends Schema.Output.Object$2, + $Schema extends Schema, + $Node extends SchemaKit.Output.Object$2, > = { [_ in $SelectAliasOne[0]]: Field<$SelectAliasOne[1], $Node['fields'][$FieldName], $Schema> } diff --git a/src/layers/3_InferResult/Field.ts b/src/layers/3_InferResult/Field.ts index f0001b8a9..69ec00d14 100644 --- a/src/layers/3_InferResult/Field.ts +++ b/src/layers/3_InferResult/Field.ts @@ -1,14 +1,14 @@ import type { Simplify } from 'type-fest' -import type { TSErrorDescriptive } from '../../lib/TSError.js' -import type { Schema } from '../1_Schema/__.js' +import type { TSErrorDescriptive } from '../../lib/ts-error.js' +import type { SchemaKit } from '../1_Schema/__.js' import type { Select } from '../2_Select/__.js' -import type { SchemaIndex } from '../4_generator/generators/SchemaIndex.js' +import type { Schema } from '../4_generator/generators/Schema.js' import type { Interface } from './Interface.js' import type { Object } from './Object.js' import type { Union } from './Union.js' // dprint-ignore -export type Field<$SelectionSet, $Field extends Schema.SomeField, $Schema extends SchemaIndex> = +export type Field<$SelectionSet, $Field extends SchemaKit.SomeField, $Schema extends Schema> = Simplify< $SelectionSet extends Select.Directive.Include.FieldStates.Negative | Select.Directive.Skip.FieldStates.Positive ? null : @@ -22,17 +22,17 @@ export type Field<$SelectionSet, $Field extends Schema.SomeField, $Schema extend // dprint-ignore type FieldType< $SelectionSet, - $Type extends Schema.Output.Any, - $Schema extends SchemaIndex + $Type extends SchemaKit.Output.Any, + $Schema extends Schema > = - $Type extends Schema.__typename ? $Value : - $Type extends Schema.Output.Nullable ? null | FieldType<$SelectionSet, $InnerType, $Schema> : - $Type extends Schema.Output.List ? Array> : - $Type extends Schema.Enum ? $Members[number] : - $Type extends Schema.Scalar.$Any ? ReturnType<$Type['codec']['decode']> : - $Type extends Schema.Object$2 ? Object<$SelectionSet, $Schema, $Type> : - $Type extends Schema.Interface ? Interface<$SelectionSet, $Schema, $Type> : - $Type extends Schema.Union ? Union<$SelectionSet, $Schema, $Type> : + $Type extends SchemaKit.__typename ? $Value : + $Type extends SchemaKit.Output.Nullable ? null | FieldType<$SelectionSet, $InnerType, $Schema> : + $Type extends SchemaKit.Output.List ? Array> : + $Type extends SchemaKit.Enum ? $Members[number] : + $Type extends SchemaKit.Scalar.$Any ? ReturnType<$Type['codec']['decode']> : + $Type extends SchemaKit.Object$2 ? Object<$SelectionSet, $Schema, $Type> : + $Type extends SchemaKit.Interface ? Interface<$SelectionSet, $Schema, $Type> : + $Type extends SchemaKit.Union ? Union<$SelectionSet, $Schema, $Type> : TSErrorDescriptive<'FieldType', `Unknown type`, { $Type: $Type; $SelectionSet: $SelectionSet; $Schema:$Schema }> // dprint-ignore diff --git a/src/layers/3_InferResult/InlineFragment.ts b/src/layers/3_InferResult/InlineFragment.ts index ea152725e..56647e38e 100644 --- a/src/layers/3_InferResult/InlineFragment.ts +++ b/src/layers/3_InferResult/InlineFragment.ts @@ -1,11 +1,11 @@ import { type GetKeyOr } from '../../lib/prelude.js' -import type { Schema } from '../1_Schema/__.js' +import type { SchemaKit } from '../1_Schema/__.js' import type { Select } from '../2_Select/__.js' -import type { SchemaIndex } from '../4_generator/generators/SchemaIndex.js' +import type { Schema } from '../4_generator/generators/Schema.js' import type { Object } from './Object.js' // dprint-ignore -export type InlineFragmentTypeConditional<$SelectionSet, $Node extends Schema.Output.Object$2, $Index extends SchemaIndex> = +export type InlineFragmentTypeConditional<$SelectionSet, $Node extends SchemaKit.Output.Object$2, $Index extends Schema> = $Node extends any // force distribution ? Object< & GetKeyOr< diff --git a/src/layers/3_InferResult/Interface.ts b/src/layers/3_InferResult/Interface.ts index bd305241f..36a4c9c91 100644 --- a/src/layers/3_InferResult/Interface.ts +++ b/src/layers/3_InferResult/Interface.ts @@ -1,7 +1,7 @@ -import type { Schema } from '../1_Schema/__.js' -import type { SchemaIndex } from '../4_generator/generators/SchemaIndex.js' +import type { SchemaKit } from '../1_Schema/__.js' +import type { Schema } from '../4_generator/generators/Schema.js' import type { InlineFragmentTypeConditional } from './InlineFragment.js' // dprint-ignore -export type Interface<$SelectionSet, $Index extends SchemaIndex, $Node extends Schema.Output.Interface> = +export type Interface<$SelectionSet, $Index extends Schema, $Node extends SchemaKit.Output.Interface> = InlineFragmentTypeConditional<$SelectionSet, $Node['implementors'][number], $Index> diff --git a/src/layers/3_InferResult/Object.ts b/src/layers/3_InferResult/Object.ts index 28ee44038..20f25270e 100644 --- a/src/layers/3_InferResult/Object.ts +++ b/src/layers/3_InferResult/Object.ts @@ -1,26 +1,26 @@ import type { Simplify } from 'type-fest' import { type StringKeyof } from '../../lib/prelude.js' -import type { TSErrorDescriptive } from '../../lib/TSError.js' -import type { Schema } from '../1_Schema/__.js' +import type { TSErrorDescriptive } from '../../lib/ts-error.js' +import type { SchemaKit } from '../1_Schema/__.js' import type { Select } from '../2_Select/__.js' -import type { SchemaIndex } from '../4_generator/generators/SchemaIndex.js' +import type { Schema } from '../4_generator/generators/Schema.js' import type { Alias } from './Alias.js' import type { Field } from './Field.js' import type { ScalarsWildcard } from './ScalarsWildcard.js' // dprint-ignore -export type Object<$SelectionSet, $Schema extends SchemaIndex, $Node extends Schema.Output.Object$2> = +export type Object<$SelectionSet, $Schema extends Schema, $Node extends SchemaKit.Output.Object$2> = Select.SelectScalarsWildcard.IsSelectScalarsWildcard<$SelectionSet> extends true // todo what about when scalars wildcard is combined with other fields like relations? ? ScalarsWildcard<$SelectionSet, $Schema,$Node> : - Simplify<( + Simplify< & SelectionNonSelectAlias<$SelectionSet, $Schema, $Node> & Alias<$SelectionSet, $Schema, $Node> - )> + > // dprint-ignore -type SelectionNonSelectAlias<$SelectionSet , $Schema extends SchemaIndex, $SchemaNode extends Schema.Output.Object$2> = +type SelectionNonSelectAlias<$SelectionSet , $Schema extends Schema, $SchemaNode extends SchemaKit.Output.Object$2> = { [$Key in PickSelectsPositiveIndicatorAndNotSelectAlias<$SelectionSet>]: $Key extends keyof $SchemaNode['fields'] @@ -30,7 +30,7 @@ type SelectionNonSelectAlias<$SelectionSet , $Schema extends SchemaIndex, $Schem // dprint-ignore export namespace Errors { - export type UnknownFieldName<$FieldName extends string, $Object extends Schema.Object$2 | Schema.Output.RootType> = + export type UnknownFieldName<$FieldName extends string, $Object extends SchemaKit.Object$2 | SchemaKit.Output.RootType> = TSErrorDescriptive<'Object', `field "${$FieldName}" does not exist on object "${$Object['fields']['__typename']['type']['type']}"`> } diff --git a/src/layers/3_InferResult/ScalarsWildcard.ts b/src/layers/3_InferResult/ScalarsWildcard.ts index bf3d39c9f..e78f25ede 100644 --- a/src/layers/3_InferResult/ScalarsWildcard.ts +++ b/src/layers/3_InferResult/ScalarsWildcard.ts @@ -1,20 +1,20 @@ -import type { Schema } from '../1_Schema/__.js' -import type { SchemaIndex } from '../4_generator/generators/SchemaIndex.js' +import type { SchemaKit } from '../1_Schema/__.js' +import type { Schema } from '../4_generator/generators/Schema.js' import type { Field } from './Field.js' export type ScalarsWildcard< $SelectionSet, - $Index extends SchemaIndex, - $Node extends Schema.Output.Object$2, + $Index extends Schema, + $Node extends SchemaKit.Output.Object$2, > = { [$Key in keyof PickScalarFields<$Node>]: Field<$SelectionSet, $Node['fields'][$Key], $Index> } // dprint-ignore -type PickScalarFields<$Object extends Schema.Output.Object$2> = { +type PickScalarFields<$Object extends SchemaKit.Output.Object$2> = { [ $Key in keyof $Object['fields'] - as Schema.Output.UnwrapToNamed<$Object['fields'][$Key]['type']> extends Schema.Hybrid.Scalar.$Any | Schema.Output.__typename + as SchemaKit.Output.UnwrapToNamed<$Object['fields'][$Key]['type']> extends SchemaKit.Hybrid.Scalar.$Any | SchemaKit.Output.__typename ? $Key : never ]: $Object['fields'][$Key] diff --git a/src/layers/3_InferResult/Union.ts b/src/layers/3_InferResult/Union.ts index ff86eb2aa..383a6e8fb 100644 --- a/src/layers/3_InferResult/Union.ts +++ b/src/layers/3_InferResult/Union.ts @@ -1,7 +1,7 @@ -import type { Schema } from '../1_Schema/__.js' -import type { SchemaIndex } from '../4_generator/generators/SchemaIndex.js' +import type { SchemaKit } from '../1_Schema/__.js' +import type { Schema } from '../4_generator/generators/Schema.js' import type { InlineFragmentTypeConditional } from './InlineFragment.js' // dprint-ignore -export type Union<$SelectionSet, $Index extends SchemaIndex, $Node extends Schema.Output.Union> = +export type Union<$SelectionSet, $Index extends Schema, $Node extends SchemaKit.Output.Union> = InlineFragmentTypeConditional<$SelectionSet, $Node['members'][number], $Index> diff --git a/src/layers/3_InferResult/root.ts b/src/layers/3_InferResult/root.ts index 09f87abc4..69bc6ddcc 100644 --- a/src/layers/3_InferResult/root.ts +++ b/src/layers/3_InferResult/root.ts @@ -1,12 +1,12 @@ import { type ExcludeNull } from '../../lib/prelude.js' -import type { Schema } from '../1_Schema/__.js' -import type { SchemaIndex } from '../4_generator/generators/SchemaIndex.js' +import type { SchemaKit } from '../1_Schema/__.js' +import type { Schema } from '../4_generator/generators/Schema.js' import type { Object } from './Object.js' export type RootViaObject< $SelectionSet, - $Schema extends SchemaIndex, - $RootType extends Schema.Output.RootType, + $Schema extends Schema, + $RootType extends SchemaKit.Output.RootType, > = Root< $SelectionSet, $Schema, @@ -14,19 +14,19 @@ export type RootViaObject< > // dprint-ignore -export type Query<$SelectionSet, $Schema extends SchemaIndex> = +export type Query<$SelectionSet, $Schema extends Schema> = Root<$SelectionSet, $Schema, 'Query'> // dprint-ignore -export type Mutation<$SelectionSet, $Schema extends SchemaIndex> = +export type Mutation<$SelectionSet, $Schema extends Schema> = Root<$SelectionSet, $Schema, 'Mutation'> // dprint-ignore -export type Subscription<$SelectionSet, $Schema extends SchemaIndex> = +export type Subscription<$SelectionSet, $Schema extends Schema> = Root<$SelectionSet, $Schema, 'Subscription'> export type Root< $SelectionSet, - $Schema extends SchemaIndex, - $RootTypeName extends Schema.RootTypeName, + $Schema extends Schema, + $RootTypeName extends SchemaKit.RootTypeName, > = Object<$SelectionSet, $Schema, ExcludeNull<$Schema['Root'][$RootTypeName]>> diff --git a/src/layers/3_SelectGraphQLMapper/context.ts b/src/layers/3_SelectGraphQLMapper/context.ts index febad516a..0a5cc1212 100644 --- a/src/layers/3_SelectGraphQLMapper/context.ts +++ b/src/layers/3_SelectGraphQLMapper/context.ts @@ -1,4 +1,4 @@ -import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { Grafaid } from '../../lib/grafaid/__.js' import { Nodes } from '../../lib/grafaid/_Nodes.js' import { inferVariableType } from './inferVariableType.js' diff --git a/src/layers/3_SelectGraphQLMapper/inferVariableType.ts b/src/layers/3_SelectGraphQLMapper/inferVariableType.ts index 563ed10af..f29adbbf8 100644 --- a/src/layers/3_SelectGraphQLMapper/inferVariableType.ts +++ b/src/layers/3_SelectGraphQLMapper/inferVariableType.ts @@ -1,4 +1,4 @@ -import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import { isScalar } from '../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' /** diff --git a/src/layers/3_SelectGraphQLMapper/mapper.ts b/src/layers/3_SelectGraphQLMapper/mapper.ts index b5799926a..d0dc7f53b 100644 --- a/src/layers/3_SelectGraphQLMapper/mapper.ts +++ b/src/layers/3_SelectGraphQLMapper/mapper.ts @@ -1,4 +1,4 @@ -import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { OperationContext } from './context.js' export type GraphQLPreOperationMapper< diff --git a/src/layers/3_SelectGraphQLMapper/nodes/2_OperationDefinition.ts b/src/layers/3_SelectGraphQLMapper/nodes/2_OperationDefinition.ts index 60701b036..aafd618f2 100644 --- a/src/layers/3_SelectGraphQLMapper/nodes/2_OperationDefinition.ts +++ b/src/layers/3_SelectGraphQLMapper/nodes/2_OperationDefinition.ts @@ -1,4 +1,4 @@ -import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { Grafaid } from '../../../lib/grafaid/__.js' import { Nodes } from '../../../lib/grafaid/_Nodes.js' import type { Select } from '../../2_Select/__.js' diff --git a/src/layers/3_SelectGraphQLMapper/nodes/3_GraffleSelectionSetRoot.ts b/src/layers/3_SelectGraphQLMapper/nodes/3_GraffleSelectionSetRoot.ts index f033b7ece..6fc2fb813 100644 --- a/src/layers/3_SelectGraphQLMapper/nodes/3_GraffleSelectionSetRoot.ts +++ b/src/layers/3_SelectGraphQLMapper/nodes/3_GraffleSelectionSetRoot.ts @@ -1,4 +1,4 @@ -import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import { Nodes } from '../../../lib/grafaid/_Nodes.js' import { Select } from '../../2_Select/__.js' import { type GraphQLPostOperationMapper } from '../mapper.js' diff --git a/src/layers/3_SelectGraphQLMapper/nodes/4_GraffleSelectionObjectLevel.ts b/src/layers/3_SelectGraphQLMapper/nodes/4_GraffleSelectionObjectLevel.ts index 07cbe0c10..bf58793bb 100644 --- a/src/layers/3_SelectGraphQLMapper/nodes/4_GraffleSelectionObjectLevel.ts +++ b/src/layers/3_SelectGraphQLMapper/nodes/4_GraffleSelectionObjectLevel.ts @@ -1,4 +1,4 @@ -import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { Grafaid } from '../../../lib/grafaid/__.js' import { Nodes } from '../../../lib/grafaid/_Nodes.js' import { casesExhausted, isNonNull } from '../../../lib/prelude.js' diff --git a/src/layers/3_SelectGraphQLMapper/nodes/5_Field.ts b/src/layers/3_SelectGraphQLMapper/nodes/5_Field.ts index b3961c6c2..b1e1cb6df 100644 --- a/src/layers/3_SelectGraphQLMapper/nodes/5_Field.ts +++ b/src/layers/3_SelectGraphQLMapper/nodes/5_Field.ts @@ -1,4 +1,4 @@ -import { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import { Nodes } from '../../../lib/grafaid/_Nodes.js' import { Select } from '../../2_Select/__.js' import type { GraphQLPostOperationMapper } from '../mapper.js' diff --git a/src/layers/3_SelectGraphQLMapper/nodes/Argument.ts b/src/layers/3_SelectGraphQLMapper/nodes/Argument.ts index 32b82edb8..241751d10 100644 --- a/src/layers/3_SelectGraphQLMapper/nodes/Argument.ts +++ b/src/layers/3_SelectGraphQLMapper/nodes/Argument.ts @@ -1,4 +1,4 @@ -import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import { Nodes } from '../../../lib/grafaid/_Nodes.js' import { Select } from '../../2_Select/__.js' import { type GraphQLPostOperationMapper } from '../mapper.js' diff --git a/src/layers/3_SelectGraphQLMapper/nodes/Value.ts b/src/layers/3_SelectGraphQLMapper/nodes/Value.ts index 02b15fc66..8cd95de16 100644 --- a/src/layers/3_SelectGraphQLMapper/nodes/Value.ts +++ b/src/layers/3_SelectGraphQLMapper/nodes/Value.ts @@ -1,4 +1,4 @@ -import { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { Grafaid } from '../../../lib/grafaid/__.js' import { Nodes } from '../../../lib/grafaid/_Nodes.js' import type { Scalar } from '../../1_Schema/_.js' diff --git a/src/layers/3_SelectGraphQLMapper/nodes/_collect.ts b/src/layers/3_SelectGraphQLMapper/nodes/_collect.ts index f78975027..9ec52c89c 100644 --- a/src/layers/3_SelectGraphQLMapper/nodes/_collect.ts +++ b/src/layers/3_SelectGraphQLMapper/nodes/_collect.ts @@ -1,4 +1,4 @@ -import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { Grafaid } from '../../../lib/grafaid/__.js' import type { Select } from '../../2_Select/__.js' import type { GraphQLPostOperationMapper } from '../mapper.js' diff --git a/src/layers/4_generator/_.ts b/src/layers/4_generator/_.ts index 78dc79fd3..b1b594f60 100644 --- a/src/layers/4_generator/_.ts +++ b/src/layers/4_generator/_.ts @@ -1,2 +1,4 @@ -export * from './config.js' -export * from './generate.js' +export * from './config/config.js' +export * from './config/input.js' +export * as Config from './configFile/_.js' +export * from './generator/generate.js' diff --git a/src/layers/4_generator/config.ts b/src/layers/4_generator/config.ts deleted file mode 100644 index a3a60dfda..000000000 --- a/src/layers/4_generator/config.ts +++ /dev/null @@ -1,220 +0,0 @@ -import { buildClientSchema, printSchema } from 'graphql' -import { buildSchema, type GraphQLObjectType, type GraphQLSchema } from 'graphql' -import fs from 'node:fs/promises' -import * as Path from 'node:path' -import { Graffle } from '../../entrypoints/__Graffle.js' -import { Introspection } from '../../entrypoints/extensions.js' -import { Grafaid } from '../../lib/grafaid/__.js' -import { omitUndefinedKeys } from '../../lib/prelude.js' -import { fileExists, isPathToADirectory } from './helpers/fs.js' - -export interface Input { - schemaSource: { - type: 'sdl' - /** - * Defaults to the source directory if set, otherwise the current working directory. - */ - dirOrFilePath?: string - } | { - type: 'url' - url: URL - } - outputDirPath?: string - name?: string - // code?: Omit - defaultSchemaUrl?: boolean | URL - /** - * Defaults to the current working directory. - */ - sourceDirPath?: string - sourceCustomScalarCodecsFilePath?: string - /** - * Override import paths to graffle package within the generated code. - * Used by Graffle test suite to have generated clients point to source - * code. Probably not useful to you. - */ - libraryPaths?: InputLibraryPaths - errorTypeNamePattern?: RegExp - /** - * Should custom scalars definitions be imported into the generated output? - */ - customScalars?: boolean - format?: boolean - TSDoc?: { - noDocPolicy?: 'message' | 'ignore' - } -} - -interface InputLibraryPaths { - client?: string - schema?: string - scalars?: string - utilitiesForGenerated?: string -} - -export interface Config { - name: string - paths: { - project: { - inputs: { - root: string - schema: null | string - customScalarCodecs: string - } - outputs: { - root: string - modules: string - } - } - imports: { - customScalarCodecs: string - grafflePackage: Required - } - } - schema: { - sdl: string - instance: GraphQLSchema - typeMapByKind: Grafaid.Schema.KindMap.KindMap - error: { - objects: GraphQLObjectType[] - enabled: boolean - } - } - runtimeFeatures: { - customScalars: boolean - operationVariables: boolean - } - options: { - defaultSchemaUrl: URL | null - format: boolean - errorTypeNamePattern: RegExp | null - customScalars: boolean - TSDoc: { - noDocPolicy: 'message' | 'ignore' - } - } -} - -export const defaultName = `default` - -export const defaultLibraryPaths = { - client: `graffle/client`, - scalars: `graffle/schema/scalars`, - schema: `graffle/schema`, - utilitiesForGenerated: `graffle/utilities-for-generated`, -} - -export const createConfig = async (input: Input): Promise => { - // dprint-ignore - const defaultSchemaUrl = - typeof input.defaultSchemaUrl === `boolean` - ? input.schemaSource.type === `url` - ? input.schemaSource.url - : null - : input.defaultSchemaUrl??null - - const formattingEnabled = input.format ?? true - - const inputPathDirRoot = input.sourceDirPath ?? process.cwd() - - const outputDirPathRoot = input.outputDirPath ?? Path.join(process.cwd(), `./graffle`) - - const outputDirPathModules = Path.join(outputDirPathRoot, `/modules`) - - const inputPathCustomScalarCodecs = input.sourceCustomScalarCodecsFilePath - ?? Path.join(inputPathDirRoot, `customScalarCodecs.ts`) - - const customScalarCodecsPathExists = await fileExists(inputPathCustomScalarCodecs) - - const customScalarCodecsImportPath = Path.relative( - outputDirPathModules, - inputPathCustomScalarCodecs.replace(/\.ts$/, `.js`), - ) - - const errorTypeNamePattern = input.errorTypeNamePattern ?? null - - const sourceSchema = await resolveSourceSchema(input) - - const schema = buildSchema(sourceSchema.content) - const typeMapByKind = Grafaid.Schema.KindMap.getKindMap(schema) - const errorObjects = errorTypeNamePattern - ? Object.values(typeMapByKind.GraphQLObjectType).filter(_ => _.name.match(errorTypeNamePattern)) - : [] - - return { - runtimeFeatures: { - customScalars: true, // todo do not assume true - operationVariables: true, // todo do not assume true - }, - name: input.name ?? defaultName, - paths: { - project: { - outputs: { - root: outputDirPathRoot, - modules: outputDirPathModules, - }, - inputs: { - root: inputPathDirRoot, - schema: sourceSchema.type === `introspection` ? null : sourceSchema.path, - customScalarCodecs: inputPathCustomScalarCodecs, - }, - }, - imports: { - customScalarCodecs: customScalarCodecsImportPath, - grafflePackage: { - ...defaultLibraryPaths, - ...omitUndefinedKeys(input.libraryPaths ?? {}), - }, - }, - }, - schema: { - sdl: sourceSchema.content, - instance: schema, - typeMapByKind, - error: { - enabled: Boolean(errorTypeNamePattern), - objects: errorObjects, - }, - }, - options: { - defaultSchemaUrl, - format: formattingEnabled, - errorTypeNamePattern, - customScalars: customScalarCodecsPathExists, - TSDoc: { - noDocPolicy: input.TSDoc?.noDocPolicy ?? `ignore`, - }, - }, - } -} - -const defaultSchemaFileName = `schema.graphql` - -const resolveSourceSchema = async ( - input: Input, -): Promise<{ type: 'introspection'; content: string } | { type: 'file'; content: string; path: string }> => { - if (input.schemaSource.type === `sdl`) { - const fileOrDirPath = input.schemaSource.dirOrFilePath ?? input.sourceDirPath ?? process.cwd() - const isDir = await isPathToADirectory(fileOrDirPath) - const finalPath = isDir ? Path.join(fileOrDirPath, defaultSchemaFileName) : fileOrDirPath - const sdl = await fs.readFile(finalPath, `utf8`) - return { type: `file`, content: sdl, path: finalPath } - } else { - const graffle = Graffle.create({ schema: input.schemaSource.url }).use(Introspection({ - options: { - directiveIsRepeatable: true, - schemaDescription: true, - specifiedByUrl: true, - inputValueDeprecation: true, - // todo oneOf - }, - })) - const data = await graffle.introspect() - if (!data) { - throw new Error(`No data returned for introspection query.`) - } - const schema = buildClientSchema(data) - const sdl = printSchema(schema) - return { type: `introspection`, content: sdl } - } -} diff --git a/src/layers/4_generator/__snapshots__/config.test.ts.snap b/src/layers/4_generator/config/__snapshots__/config.test.ts.snap similarity index 100% rename from src/layers/4_generator/__snapshots__/config.test.ts.snap rename to src/layers/4_generator/config/__snapshots__/config.test.ts.snap diff --git a/src/layers/4_generator/config.test.ts b/src/layers/4_generator/config/config.test.ts similarity index 73% rename from src/layers/4_generator/config.test.ts rename to src/layers/4_generator/config/config.test.ts index e422979d5..0274433d2 100644 --- a/src/layers/4_generator/config.test.ts +++ b/src/layers/4_generator/config/config.test.ts @@ -1,10 +1,10 @@ import { expect } from 'vitest' -import { test } from '../../../tests/_/helpers.js' +import { test } from '../../../../tests/_/helpers.js' import { createConfig } from './config.js' test(`can load schema from custom path`, async () => { const customPathFile = `./tests/_/fixtures/custom.graphql` - const config = await createConfig({ schemaSource: { type: `sdl`, dirOrFilePath: customPathFile } }) + const config = await createConfig({ schema: { type: `sdl`, dirOrFilePath: customPathFile } }) const field = config.schema.instance.getQueryType()?.getFields()[`customNamedSchemaFile`] expect(config.paths.project.inputs.schema).toEqual(customPathFile) expect(config.schema.sdl).toMatchSnapshot() @@ -13,7 +13,7 @@ test(`can load schema from custom path`, async () => { test(`can load schema from custom dir using default file name`, async () => { const customPathDir = `tests/_/fixtures` - const config = await createConfig({ schemaSource: { type: `sdl`, dirOrFilePath: customPathDir } }) + const config = await createConfig({ schema: { type: `sdl`, dirOrFilePath: customPathDir } }) const field = config.schema.instance.getQueryType()?.getFields()[`defaultNamedSchemaFile`] expect(config.paths.project.inputs.schema).toEqual(customPathDir + `/schema.graphql`) expect(config.schema.sdl).toMatchSnapshot() @@ -21,7 +21,7 @@ test(`can load schema from custom dir using default file name`, async () => { }) test(`can introspect schema from url`, async ({ pokemonService }) => { - const config = await createConfig({ schemaSource: { type: `url`, url: pokemonService.url } }) + const config = await createConfig({ schema: { type: `url`, url: pokemonService.url } }) expect(config.paths.project.inputs.schema).toEqual(null) expect(config.schema.sdl).toMatchSnapshot() }) diff --git a/src/layers/4_generator/config/config.ts b/src/layers/4_generator/config/config.ts new file mode 100644 index 000000000..eb1e62a2b --- /dev/null +++ b/src/layers/4_generator/config/config.ts @@ -0,0 +1,234 @@ +import fs from 'node:fs/promises' +import * as Path from 'node:path' +import { Graffle } from '../../../entrypoints/__Graffle.js' +import { Introspection } from '../../../entrypoints/extensions.js' +import { ConfigManager } from '../../../lib/config-manager/__.js' +import { fileExists, isPathToADirectory, toAbsolutePath, toFilePath } from '../../../lib/fs.js' +import { Grafaid } from '../../../lib/grafaid/__.js' +import { isString } from '../../../lib/prelude.js' +import { + type Formatter, + getTypescriptFormatterOrPassthrough, + passthroughFormatter, +} from '../../../lib/typescript-formatter.js' +import type { Extension } from '../extension/types.js' +import { defaultLibraryPaths } from './defaults.js' +import { defaultName } from './defaults.js' +import type { Input, InputLibraryPaths } from './input.js' + +export interface Config { + name: string + schema: ConfigSchema + runtimeFeatures: { + customScalars: boolean + operationVariables: boolean + } + options: { + defaultSchemaUrl: URL | null + format: boolean + customScalars: boolean + TSDoc: { + noDocPolicy: 'message' | 'ignore' + } + } + formatter: Formatter + extensions: Extension[] + paths: { + project: { + inputs: { + root: string + schema: null | string + customScalarCodecs: string + } + outputs: { + sdl: null | string + root: string + modules: string + } + } + imports: { + customScalarCodecs: string + grafflePackage: Required + } + } +} + +interface ConfigSchema { + via: 'sdl' | 'introspection' | 'instance' + sdl: string + sdlFilePath: null | string + instance: Grafaid.Schema.Schema + kindMap: Grafaid.Schema.KindMap.KindMap +} + +export const createConfig = async (input: Input): Promise => { + // --- Paths --- + + const cwd = input.currentWorkingDirectory ?? process.cwd() + + const sourceDirPath = input.sourceDirPath ? toAbsolutePath(cwd, input.sourceDirPath) : cwd + + const outputDirPathRoot = input.outputDirPath + ? toAbsolutePath(cwd, input.outputDirPath) + : Path.join(cwd, `./graffle`) + + const outputDirPathModules = Path.join(outputDirPathRoot, `/modules`) + + const inputPathCustomScalarCodecs = input.sourceCustomScalarCodecsFilePath + ? toAbsolutePath(cwd, input.sourceCustomScalarCodecsFilePath) + : Path.join(sourceDirPath, `customScalarCodecs.ts`) + + const customScalarCodecsPathExists = await fileExists(inputPathCustomScalarCodecs) + + const customScalarCodecsImportPath = Path.relative( + outputDirPathModules, + inputPathCustomScalarCodecs.replace(/\.ts$/, `.js`), + ) + + // --- Schema --- + + const schema = await createConfigSchema(cwd, sourceDirPath, input) + + // --- Default Schema URL --- + + // dprint-ignore + const defaultSchemaUrl = + typeof input.defaultSchemaUrl === `boolean` + ? input.schema instanceof Grafaid.Schema.Schema + ? null + : input.schema.type === `url` + ? input.schema.url + : null + : input.defaultSchemaUrl ?? null + + // --- Formatting --- + + const formattingEnabled = input.format ?? true + const formatter = formattingEnabled ? await getTypescriptFormatterOrPassthrough() : passthroughFormatter + + // --- Library Paths --- + + const processLibraryPath = (path: string) => { + const pathAbsolute = toAbsolutePath(cwd, path).replace(/\.ts$/, `.js`) + return Path.relative(outputDirPathModules, pathAbsolute) + } + + const libraryPaths = { + client: input.libraryPaths?.client ? processLibraryPath(input.libraryPaths.client) : undefined, + scalars: input.libraryPaths?.scalars ? processLibraryPath(input.libraryPaths.scalars) : undefined, + schema: input.libraryPaths?.schema ? processLibraryPath(input.libraryPaths.schema) : undefined, + utilitiesForGenerated: input.libraryPaths?.utilitiesForGenerated + ? processLibraryPath(input.libraryPaths.utilitiesForGenerated) + : undefined, + } + + // --- Output SDL --- + + // dprint-ignore + const outputSDLPath = + input.outputSDL + ? isString(input.outputSDL) + ? toFilePath(`schema.graphql`, toAbsolutePath(cwd, input.outputSDL)) + : Path.join(outputDirPathRoot, `schema.graphql`) + : null + + // --- Config --- + + return { + extensions: input.extensions ?? [], + formatter, + runtimeFeatures: { + customScalars: true, // todo do not assume true + operationVariables: true, // todo do not assume true + }, + name: input.name ?? defaultName, + schema, + options: { + defaultSchemaUrl, + format: formattingEnabled, + customScalars: customScalarCodecsPathExists, + TSDoc: { + noDocPolicy: input.TSDoc?.noDocPolicy ?? `ignore`, + }, + }, + paths: { + project: { + outputs: { + root: outputDirPathRoot, + sdl: outputSDLPath, + modules: outputDirPathModules, + }, + inputs: { + root: sourceDirPath, + schema: schema.sdlFilePath, + customScalarCodecs: inputPathCustomScalarCodecs, + }, + }, + imports: { + customScalarCodecs: customScalarCodecsImportPath, + grafflePackage: ConfigManager.mergeDefaults( + defaultLibraryPaths, + libraryPaths, + ), + }, + }, + } +} + +const defaultSchemaFileName = `schema.graphql` + +const createConfigSchema = async ( + cwd: string, + sourceDirPath: string, + input: Input, +): Promise => { + if (input.schema instanceof Grafaid.Schema.Schema) { + const sdl = Grafaid.Schema.print(input.schema) + const instance = input.schema + return { + via: `instance`, + sdl, + sdlFilePath: null, + instance, + kindMap: Grafaid.Schema.KindMap.getKindMap(instance), + } + } else if (input.schema.type === `sdl`) { + const fileOrDirPath = input.schema.dirOrFilePath + ? toAbsolutePath(cwd, input.schema.dirOrFilePath) + : sourceDirPath + const isDir = await isPathToADirectory(fileOrDirPath) + const sdlFilePath = isDir ? Path.join(fileOrDirPath, defaultSchemaFileName) : fileOrDirPath + const sdl = await fs.readFile(sdlFilePath, `utf8`) + const instance = Grafaid.Schema.buildSchema(sdl) + return { + via: `sdl`, + sdlFilePath, + sdl, + instance, + kindMap: Grafaid.Schema.KindMap.getKindMap(instance), + } + } else { + const graffle = Graffle.create({ schema: input.schema.url }).use(Introspection({ + options: { + directiveIsRepeatable: true, + schemaDescription: true, + specifiedByUrl: true, + inputValueDeprecation: true, + // todo oneOf + }, + })) + const data = await graffle.introspect() + if (!data) { + throw new Error(`No data returned for introspection query.`) + } + const instance = Grafaid.Schema.buildClientSchema(data) + const sdl = Grafaid.Schema.print(instance) + return { + via: `introspection`, + sdl, + sdlFilePath: null, + instance, + kindMap: Grafaid.Schema.KindMap.getKindMap(instance), + } + } +} diff --git a/src/layers/4_generator/config/defaults.ts b/src/layers/4_generator/config/defaults.ts new file mode 100644 index 000000000..b119c15c0 --- /dev/null +++ b/src/layers/4_generator/config/defaults.ts @@ -0,0 +1,8 @@ +export const defaultName = `default` + +export const defaultLibraryPaths = { + client: `graffle/client`, + scalars: `graffle/schema/scalars`, + schema: `graffle/schema`, + utilitiesForGenerated: `graffle/utilities-for-generated`, +} diff --git a/src/layers/4_generator/config/input.ts b/src/layers/4_generator/config/input.ts new file mode 100644 index 000000000..db34599b2 --- /dev/null +++ b/src/layers/4_generator/config/input.ts @@ -0,0 +1,113 @@ +import type { Grafaid } from '../../../lib/grafaid/__.js' +import type { Extension } from '../extension/types.js' + +export interface Input { + name?: string + /** + * The directory path which paths will be considered relative to. + * + * By default, uses the process current working directory. + */ + currentWorkingDirectory?: string + /** + * The schema to use for generation. Can be an existing SDL file on disk, a schema instance already in memory, or an endpoint that will be introspected. + */ + schema: Grafaid.Schema.Schema | { + type: 'sdl' + /** + * Defaults to the source directory if set, otherwise the current working directory. + */ + dirOrFilePath?: string + } | { + type: 'url' + url: URL + } + /** + * If the schema comes from a non-sdl-file source like a GraphQL endpoint URL, should a derived SDL file be written to disk? + * + * When `boolean`: + * + * If true, an SDL file will be written into the output directory. + * + * When `string`: + * + * The path to write the SDL file to. + * If a directory, then a file called "schema.graphql" will be written into it. + * If a file, then it will be written as such. + * + * @defaultValue `false` + */ + outputSDL?: boolean | string + /** + * Directory path to where the generated code should be output. + * + * Defaults to the current working directory. + */ + outputDirPath?: string + /** + * Control over the client configuration's default schema. Since an introspection URL can be used for `schema`, + * this option allows you to have this URL propagated to the generated client configuration for your convenience. + * As well, its possible to set an explicit URL. + * + * When `boolean`: + * + * If a GraphQL endpoint is given for `schema`, should it be set as the default URL in the generated client. + * If true then the client will default to using this URL when sending requests. + * + * When `URL`: + * + * A GraphQL endpoint to be used as the default URL in the generated client for requests. + * + * @defaultValue `true` + */ + defaultSchemaUrl?: boolean | URL + /** + * Directory to look for custom scalar codecs. + * + * Defaults to the current working directory. + */ + sourceDirPath?: string + /** + * todo + */ + sourceCustomScalarCodecsFilePath?: string + /** + * Override import paths to graffle package within the generated code. + * Used by Graffle test suite to have generated clients point to source + * code. Probably not useful to you. + */ + libraryPaths?: InputLibraryPaths + /** + * Should custom scalars definitions be imported into the generated output? + */ + customScalars?: boolean + /** + * Should the generated code be formatted? + */ + format?: boolean + /** + * Control over how TSDoc (JSDoc) comments are handled. + */ + TSDoc?: { + /** + * When there is no documentation for a documentable node (type, field, enum value, ...) in the GraphQL schema + * what should Graffle show for the JSDoc of the corresponding elements in the generated code? + * + * - `message`: Show a message mentioning the lack of documentation and the opportunity for it. + * - `ignore`: Ignore the lack of documentation and show nothing. + */ + noDocPolicy?: 'message' | 'ignore' + } + /** + * Graffle gentime extensions to use. Most Graffle extensions are runtime only but some + * are or have gentime components. + */ + extensions?: Extension[] +} + +export interface InputLibraryPaths { + client?: string + schema?: string + scalars?: string + utilitiesForGenerated?: string +} diff --git a/src/layers/4_generator/configFile/_.ts b/src/layers/4_generator/configFile/_.ts new file mode 100644 index 000000000..13a1d6c31 --- /dev/null +++ b/src/layers/4_generator/configFile/_.ts @@ -0,0 +1,2 @@ +export * from './builder.js' +export * from './loader.js' diff --git a/src/layers/4_generator/configFile/builder.ts b/src/layers/4_generator/configFile/builder.ts new file mode 100644 index 000000000..3882eb0df --- /dev/null +++ b/src/layers/4_generator/configFile/builder.ts @@ -0,0 +1,37 @@ +import type { SetOptional } from 'type-fest' +import type { Input } from '../config/input.js' +import type { Extension } from '../extension/types.js' + +/** + * Builder input does not require a schema source because it is designed to be used in the config file. + * The config file is read by the CLI, and can have the schema source specified in the CLI arguments. + */ +export type BuilderInput = SetOptional + +export interface Builder { + _: { + input: BuilderInput + } + use: (extension: Extension) => Builder +} + +export const create = (input: BuilderInput): Builder => { + return { + _: { + input, + }, + /** + * todo + */ + use: (extension) => { + return create({ + ...input, + extensions: [...(input.extensions ?? []), extension], + }) + }, + } +} + +export const isBuilder = (value: unknown): value is Builder => { + return true // todo +} diff --git a/src/layers/4_generator/configFile/loader.ts b/src/layers/4_generator/configFile/loader.ts new file mode 100644 index 000000000..7db1def0b --- /dev/null +++ b/src/layers/4_generator/configFile/loader.ts @@ -0,0 +1,101 @@ +import * as Path from 'node:path' +import { Errors } from '../../../lib/errors/__.js' +import { isPathToADirectory, toAbsolutePath } from '../../../lib/fs.js' +import { importFirst } from '../../../lib/import-first.js' +import { isError } from '../../../lib/prelude.js' +import { type Builder, isBuilder } from './builder.js' + +interface Config { + fileName: string +} + +interface Input { + /** + * The path to the config file. If is a directory then will look for the configured file + * name with one of the supported extensions in the directory. + */ + filePath?: string + options?: { + /** + * Config file name. + * + * @defaultValue `graffle.config` + * + * An attempt to import it using the following extensions will be made: + * + * - `.ts` + * - `.js` + * - `.mjs` + * - `.mts` + */ + fileName?: string + } +} + +export const loadDefaults: Config = { + fileName: `graffle.config`, +} + +const extensionCandidates = [`ts`, `js`, `mjs`, `mts`] + +export const load = async ( + input?: Input, +): Promise< + | { builder: null; paths: string[]; path: null } + | { builder: Builder; path: string; paths: string[] } + | Errors.ContextualError +> => { + const importPathCandidates = await processInput(input?.filePath) + + const importedModule = await importFirst(importPathCandidates) + + if (!importedModule) { + return { + builder: null, + paths: importPathCandidates, + path: null, + } + } + + if (isError(importedModule)) { + return new Errors.ContextualError( + `Failed to import project Graffle configuration file.`, + { importPathCandidates }, + importedModule, + ) + } + + if (!isBuilder(importedModule.module[`default`])) { + throw new Errors.ContextualError( + `Invalid project Graffle configuration file. It does not have a default export of the configuration.`, + { + path: importedModule.path, + value: importedModule.module, + }, + ) + } + + return { + builder: importedModule.module[`default`], + path: importedModule.path, + paths: importPathCandidates, + } +} + +const processInput = async (input?: string) => { + if (!input) { + const directoryPath = process.cwd() + const path = Path.join(directoryPath, loadDefaults.fileName) + return extensionCandidates.map(ext => toAbsolutePath(process.cwd(), `${path}.${ext}`)) + } + + const absolutePath = toAbsolutePath(process.cwd(), input) + + if (await isPathToADirectory(absolutePath)) { + const directoryPath = absolutePath + const path = Path.join(directoryPath, loadDefaults.fileName) + return extensionCandidates.map(ext => `${path}.${ext}`) + } + + return [absolutePath] +} diff --git a/src/layers/4_generator/extension/create.ts b/src/layers/4_generator/extension/create.ts new file mode 100644 index 000000000..c68c13eb9 --- /dev/null +++ b/src/layers/4_generator/extension/create.ts @@ -0,0 +1,14 @@ +import type { Extension, ObjectTypeHookParams, OutputFieldHookParams, SchemaHookParams } from './types.js' + +export interface Input { + name: string + onSchema?: (input: SchemaHookParams) => void + schemaDrivenDataMap?: { + onObjectType?: (input: ObjectTypeHookParams) => void + onOutputField?: (input: OutputFieldHookParams) => void + } +} + +export const createExtension = (input: Input): Extension => { + return input +} diff --git a/src/layers/4_generator/extension/types.ts b/src/layers/4_generator/extension/types.ts new file mode 100644 index 000000000..94b107d5a --- /dev/null +++ b/src/layers/4_generator/extension/types.ts @@ -0,0 +1,29 @@ +import type { Code } from '../../../lib/Code.js' +import type { Grafaid } from '../../../lib/grafaid/__.js' +import type { Config } from '../config/config.js' + +export interface Extension { + name: string + onSchema?: (input: SchemaHookParams) => void + schemaDrivenDataMap?: { + onObjectType?: (input: ObjectTypeHookParams) => void + onOutputField?: (input: OutputFieldHookParams) => void + } +} + +export interface SchemaHookParams { + config: Config + schema: Code.TermObject +} + +export interface ObjectTypeHookParams { + config: Config + sddmNode: Code.TermObject + graphqlType: Grafaid.Schema.ObjectType +} + +export interface OutputFieldHookParams { + config: Config + sddmNode: Code.DirectiveTermObjectLike + graphqlType: Grafaid.Schema.Field +} diff --git a/src/layers/4_generator/generate.ts b/src/layers/4_generator/generate.ts deleted file mode 100644 index 0d0f791fe..000000000 --- a/src/layers/4_generator/generate.ts +++ /dev/null @@ -1,66 +0,0 @@ -import fs from 'node:fs/promises' -import { ModuleGeneratorSchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/generator.js' -import { type Config, createConfig, type Input } from './config.js' -import { ModuleGenerator_ } from './generators/_.js' -import { ModuleGenerator__ } from './generators/__.js' -import { ModuleGeneratorClient } from './generators/Client.js' -import { ModuleGeneratorData } from './generators/Data.js' -import { ModuleGeneratorGlobal } from './generators/global.js' -import { ModuleGeneratorMethodsDocument } from './generators/MethodsDocument.js' -import { ModuleGeneratorMethodsRoot } from './generators/MethodsRoot.js' -import { ModuleGeneratorMethodsSelect } from './generators/MethodsSelect.js' -import { ModuleGeneratorScalar } from './generators/Scalar.js' -import { ModuleGeneratorSchemaBuildtime } from './generators/SchemaBuildtime.js' -import { ModuleGeneratorSchemaIndex } from './generators/SchemaIndex.js' -import { ModuleGeneratorSelect } from './generators/Select.js' -import { ModuleGeneratorSelectionSets } from './generators/SelectionSets.js' -import type { GeneratedModule } from './helpers/moduleGenerator.js' -import { getTypeScriptFormatterOrPassthrough, passthroughFormatter } from './helpers/typeScriptFormatter.js' - -export const generate = async (input: Input) => { - const config = await createConfig(input) - const generatedModules = await generateCode(config) - - // todo clear directory before generating so that removed or renamed files are cleaned up. - await fs.mkdir(config.paths.project.outputs.root, { recursive: true }) - await fs.mkdir(config.paths.project.outputs.modules, { recursive: true }) - - await Promise.all( - generatedModules.map((generatedModule) => { - const isExportsModule = generatedModule.name.match(/^_+$/) !== null - const filePath = `${config.paths.project.outputs.root}/${ - isExportsModule ? `` : `modules/` - }${generatedModule.name}.ts` - return fs.writeFile(filePath, generatedModule.content, { - encoding: `utf8`, - }) - }), - ) -} - -const generateCode = async (config: Config): Promise => { - const typeScriptFormatter = config.options.format ? await getTypeScriptFormatterOrPassthrough() : passthroughFormatter - - return [ - ModuleGeneratorGlobal, - ModuleGeneratorClient, - ModuleGeneratorData, - ModuleGeneratorScalar, - // Packaging Stuff - ModuleGenerator__, - ModuleGenerator_, - // Schema Stuff - ModuleGeneratorSchemaIndex, - ModuleGeneratorSchemaBuildtime, - ModuleGeneratorSchemaDrivenDataMap, - // Interface Stuff - ModuleGeneratorSelectionSets, - ModuleGeneratorSelect, - ModuleGeneratorMethodsSelect, - ModuleGeneratorMethodsRoot, - ModuleGeneratorMethodsDocument, - ].map(generator => generator.generate(config)).map(code => ({ - ...code, - content: typeScriptFormatter.formatText(code.content), - })) -} diff --git a/src/layers/4_generator/__snapshots__/generate.test.ts.snap b/src/layers/4_generator/generator/__snapshots__/generate.test.ts.snap similarity index 100% rename from src/layers/4_generator/__snapshots__/generate.test.ts.snap rename to src/layers/4_generator/generator/__snapshots__/generate.test.ts.snap diff --git a/src/layers/4_generator/generate.test.ts b/src/layers/4_generator/generator/generate.test.ts similarity index 100% rename from src/layers/4_generator/generate.test.ts rename to src/layers/4_generator/generator/generate.test.ts diff --git a/src/layers/4_generator/generator/generate.ts b/src/layers/4_generator/generator/generate.ts new file mode 100644 index 000000000..96da9a0e1 --- /dev/null +++ b/src/layers/4_generator/generator/generate.ts @@ -0,0 +1,65 @@ +import fs from 'node:fs/promises' +import { ModuleGeneratorSchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/generator.js' +import { createConfig } from '../config/config.js' +import type { Input } from '../config/input.js' +import { ModuleGenerator_ } from '../generators/_.js' +import { ModuleGenerator__ } from '../generators/__.js' +import { ModuleGeneratorClient } from '../generators/Client.js' +import { ModuleGeneratorData } from '../generators/Data.js' +import { ModuleGeneratorGlobal } from '../generators/global.js' +import { ModuleGeneratorMethodsDocument } from '../generators/MethodsDocument.js' +import { ModuleGeneratorMethodsRoot } from '../generators/MethodsRoot.js' +import { ModuleGeneratorMethodsSelect } from '../generators/MethodsSelect.js' +import { ModuleGeneratorScalar } from '../generators/Scalar.js' +import { ModuleGeneratorSchema } from '../generators/Schema.js' +import { ModuleGeneratorSchemaBuildtime } from '../generators/SchemaBuildtime.js' +import { ModuleGeneratorSelect } from '../generators/Select.js' +import { ModuleGeneratorSelectionSets } from '../generators/SelectionSets.js' + +const moduleGenerators = [ + ModuleGeneratorGlobal, + ModuleGeneratorClient, + ModuleGeneratorData, + ModuleGeneratorScalar, + // Packaging Stuff + ModuleGenerator__, + ModuleGenerator_, + // Schema Stuff + ModuleGeneratorSchema, + ModuleGeneratorSchemaBuildtime, + ModuleGeneratorSchemaDrivenDataMap, + // Interface Stuff + ModuleGeneratorSelectionSets, + ModuleGeneratorSelect, + ModuleGeneratorMethodsSelect, + ModuleGeneratorMethodsRoot, + ModuleGeneratorMethodsDocument, +] + +export const generate = async (input: Input) => { + const config = await createConfig(input) + + const generatedModules = moduleGenerators + .map(generator => generator.generate(config)) + .map(code => ({ + ...code, + content: config.formatter.formatText(code.content), + })) + + if (config.paths.project.outputs.sdl && config.schema.via !== `sdl`) { + await fs.writeFile(config.paths.project.outputs.sdl, config.schema.sdl) + } + + // todo clear directory before generating so that removed or renamed files are cleaned up. + await fs.mkdir(config.paths.project.outputs.root, { recursive: true }) + await fs.mkdir(config.paths.project.outputs.modules, { recursive: true }) + + await Promise.all( + generatedModules.map((generatedModule) => { + const isExportsModule = generatedModule.name.match(/^_+$/) !== null + // dprint-ignore + const filePath = `${config.paths.project.outputs.root}/${isExportsModule ? `` : `modules/`}${generatedModule.name}.ts` + return fs.writeFile(filePath, generatedModule.content) + }), + ) +} diff --git a/src/layers/4_generator/generators/Client.ts b/src/layers/4_generator/generators/Client.ts index caab5203c..386f35d8f 100644 --- a/src/layers/4_generator/generators/Client.ts +++ b/src/layers/4_generator/generators/Client.ts @@ -9,8 +9,9 @@ export const ModuleGeneratorClient = createModuleGenerator( `import { createPrefilled } from '${config.paths.imports.grafflePackage.client}'`, `import { defaultSchemaUrl } from './${ModuleGeneratorData.name}.js'`, `import { schemaDrivenDataMap } from './${ModuleGeneratorSchemaDrivenDataMap.name}.js'`, + `import { Name } from './${ModuleGeneratorData.name}.js'`, ``, - `export const create = createPrefilled(\`${config.name}\`, schemaDrivenDataMap, defaultSchemaUrl)`, + `export const create = createPrefilled(Name, schemaDrivenDataMap, defaultSchemaUrl)`, ) }, ) diff --git a/src/layers/4_generator/generators/MethodsDocument.ts b/src/layers/4_generator/generators/MethodsDocument.ts index 9e18ba07a..2aa19dcfb 100644 --- a/src/layers/4_generator/generators/MethodsDocument.ts +++ b/src/layers/4_generator/generators/MethodsDocument.ts @@ -1,7 +1,7 @@ // todo remove use of Utils.Aug when schema errors not in use // todo jsdoc import { createModuleGenerator } from '../helpers/moduleGenerator.js' -import { ModuleGeneratorSchemaIndex } from './SchemaIndex.js' +import { ModuleGeneratorSchema } from './Schema.js' import { ModuleGeneratorSelectionSets } from './SelectionSets.js' export const ModuleGeneratorMethodsDocument = createModuleGenerator( @@ -9,7 +9,7 @@ export const ModuleGeneratorMethodsDocument = createModuleGenerator( ({ config, code }) => { code(`import type * as SelectionSets from './${ModuleGeneratorSelectionSets.name}.js'`) code(`import type * as Utilities from '${config.paths.imports.grafflePackage.utilitiesForGenerated}'`) - code(`import type { Index } from './${ModuleGeneratorSchemaIndex.name}.js'`) + code(`import type { Index } from './${ModuleGeneratorSchema.name}.js'`) code() code(`export interface Document<$Config extends Utilities.Config> { diff --git a/src/layers/4_generator/generators/MethodsRoot.ts b/src/layers/4_generator/generators/MethodsRoot.ts index 58bacee4c..2114c54a5 100644 --- a/src/layers/4_generator/generators/MethodsRoot.ts +++ b/src/layers/4_generator/generators/MethodsRoot.ts @@ -3,7 +3,7 @@ import { Grafaid } from '../../../lib/grafaid/__.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { createCodeGenerator } from '../helpers/moduleGeneratorRunner.js' import { renderDocumentation, renderName } from '../helpers/render.js' -import { ModuleGeneratorSchemaIndex } from './SchemaIndex.js' +import { ModuleGeneratorSchema } from './Schema.js' import { ModuleGeneratorSelectionSets } from './SelectionSets.js' export const ModuleGeneratorMethodsRoot = createModuleGenerator( @@ -12,13 +12,13 @@ export const ModuleGeneratorMethodsRoot = createModuleGenerator( code(`import { type Simplify } from 'type-fest'`) code(`import type * as Utils from '${config.paths.imports.grafflePackage.utilitiesForGenerated}';`) code(`import type { InferResult } from '${config.paths.imports.grafflePackage.schema}';`) - code(`import type { Index } from './${ModuleGeneratorSchemaIndex.name}.js'`) + code(`import type { Index } from './${ModuleGeneratorSchema.name}.js'`) code(`import type * as SelectionSet from './${ModuleGeneratorSelectionSets.name}.js'`) code() code() - config.schema.typeMapByKind.GraphQLRootType.forEach(node => { + config.schema.kindMap.GraphQLRootType.forEach(node => { code(renderRootType({ config, node })) code() }) @@ -26,7 +26,7 @@ export const ModuleGeneratorMethodsRoot = createModuleGenerator( code(` export interface BuilderMethodsRoot<$Config extends Utils.Config> { ${ - config.schema.typeMapByKind.GraphQLRootType.map(node => { + config.schema.kindMap.GraphQLRootType.map(node => { const operationName = Grafaid.RootTypeNameToOperationName[node.name as keyof typeof Grafaid.RootTypeNameToOperationName] return `${operationName}: ${node.name}Methods<$Config>` diff --git a/src/layers/4_generator/generators/MethodsSelect.ts b/src/layers/4_generator/generators/MethodsSelect.ts index 60704082b..1ab885bc3 100644 --- a/src/layers/4_generator/generators/MethodsSelect.ts +++ b/src/layers/4_generator/generators/MethodsSelect.ts @@ -12,10 +12,10 @@ export const ModuleGeneratorMethodsSelect = createModuleGenerator( code() const graphqlTypeGroups = [ - config.schema.typeMapByKind.GraphQLRootType, - config.schema.typeMapByKind.GraphQLObjectType, - config.schema.typeMapByKind.GraphQLUnionType, - config.schema.typeMapByKind.GraphQLInterfaceType, + config.schema.kindMap.GraphQLRootType, + config.schema.kindMap.GraphQLObjectType, + config.schema.kindMap.GraphQLUnionType, + config.schema.kindMap.GraphQLInterfaceType, ].filter(_ => _.length > 0) code(title1(`Select Methods Interface`)) diff --git a/src/layers/4_generator/generators/Scalar.ts b/src/layers/4_generator/generators/Scalar.ts index 95200c1c7..589bf15b9 100644 --- a/src/layers/4_generator/generators/Scalar.ts +++ b/src/layers/4_generator/generators/Scalar.ts @@ -5,58 +5,51 @@ import { typeTitle2 } from '../helpers/render.js' export const ModuleGeneratorScalar = createModuleGenerator( `Scalar`, ({ config, code }) => { + const identifiers = { + CustomScalars: `CustomScalars`, + StandardScalar: `StandardScalar`, + } + // todo test case for when this is true - const needsDefaultCustomScalarImplementation = Grafaid.Schema.KindMap.hasCustomScalars(config.schema.typeMapByKind) + const isNeedCustomScalarDefaults = Grafaid.Schema.KindMap.hasCustomScalars(config.schema.kindMap) && !config.options.customScalars - const CustomScalarsNamespace = `CustomScalars` - const StandardScalarNamespace = `StandardScalar` - - if (needsDefaultCustomScalarImplementation) { - code(`import * as ${StandardScalarNamespace} from '${config.paths.imports.grafflePackage.scalars}'`) - } - - if (Grafaid.Schema.KindMap.hasCustomScalars(config.schema.typeMapByKind)) { + if (Grafaid.Schema.KindMap.hasCustomScalars(config.schema.kindMap) && config.options.customScalars) { code(`import type { Schema } from '${config.paths.imports.grafflePackage.schema}'`) - code(`import * as ${CustomScalarsNamespace} from '${config.paths.imports.customScalarCodecs}'`) + code(`import * as ${identifiers.CustomScalars} from '${config.paths.imports.customScalarCodecs}'`) code() - } - - code(`export * from '${config.paths.imports.grafflePackage.scalars}'`) - if (config.options.customScalars) { + code(`export * from '${config.paths.imports.grafflePackage.scalars}'`) code(`export * from '${config.paths.imports.customScalarCodecs}'`) - const names = config.schema.typeMapByKind.GraphQLScalarTypeCustom.map((scalar) => scalar.name) - code(`export { ${names.join(`, `)} } from '${config.paths.imports.customScalarCodecs}'`) - } - code() + const names = config.schema.kindMap.GraphQLScalarTypeCustom.map((scalar) => scalar.name).join(`, `) + code(`export { ${names} } from '${config.paths.imports.customScalarCodecs}'`) - for (const scalar of config.schema.typeMapByKind.GraphQLScalarTypeCustom) { - code(typeTitle2(`custom scalar type`)(scalar)) - code() - code(`export type ${scalar.name} = typeof ${CustomScalarsNamespace}.${scalar.name}`) - code( - `// Without this we get error: + for (const scalar of config.schema.kindMap.GraphQLScalarTypeCustom) { + code(typeTitle2(`custom scalar type`)(scalar)) + code() + code(`export type ${scalar.name} = typeof ${identifiers.CustomScalars}.${scalar.name}`) + code( + `// Without this we get error: // "Exported type alias 'DateDecoded' has or is using private name 'Date'."`, - ) - code(`type ${scalar.name}_ = typeof ${CustomScalarsNamespace}.${scalar.name}`) - code(`export type ${scalar.name}Decoded = Schema.Scalar.GetDecoded<${scalar.name}_>`) - code(`export type ${scalar.name}Encoded = Schema.Scalar.GetEncoded<${scalar.name}_>`) - code() + ) + code(`type ${scalar.name}_ = typeof ${identifiers.CustomScalars}.${scalar.name}`) + code(`export type ${scalar.name}Decoded = Schema.Scalar.GetDecoded<${scalar.name}_>`) + code(`export type ${scalar.name}Encoded = Schema.Scalar.GetEncoded<${scalar.name}_>`) + code() + } } - if (needsDefaultCustomScalarImplementation) { + if (isNeedCustomScalarDefaults) { + // code(`import * as ${identifiers.StandardScalar} from '${config.paths.imports.grafflePackage.scalars}'`) + code() console.log( `WARNING: Custom scalars detected in the schema, but you have not created a custom scalars module to import implementations from.`, ) + code(`export * from '${config.paths.imports.grafflePackage.scalars}'`) + code(`export {`) code( - config.schema.typeMapByKind.GraphQLScalarTypeCustom - .flatMap((_) => { - return [ - `export const ${_.name} = ${StandardScalarNamespace}.String`, - `export type ${_.name} = ${StandardScalarNamespace}.String`, - ] - }).join(`\n`), + config.schema.kindMap.GraphQLScalarTypeCustom.map((_) => `String as ${_.name}`).join(`,`), ) + code(`} from '${config.paths.imports.grafflePackage.scalars}'`) } }, ) diff --git a/src/layers/4_generator/generators/Schema.ts b/src/layers/4_generator/generators/Schema.ts new file mode 100644 index 000000000..69f8bd7c6 --- /dev/null +++ b/src/layers/4_generator/generators/Schema.ts @@ -0,0 +1,122 @@ +import type { SchemaDrivenDataMap } from '../../../entrypoints/utilities-for-generated.js' +import { Code } from '../../../lib/Code.js' +import { Grafaid } from '../../../lib/grafaid/__.js' +import type { SchemaKit } from '../../1_Schema/__.js' +import type { GlobalRegistry } from '../globalRegistry.js' +import { createModuleGenerator } from '../helpers/moduleGenerator.js' +import { ModuleGeneratorData } from './Data.js' +import { ModuleGeneratorMethodsRoot } from './MethodsRoot.js' +import { ModuleGeneratorSchemaBuildtime } from './SchemaBuildtime.js' + +declare global { + namespace GraffleGlobal { + /** + * A generic schema index type. Any particular schema index will be a subtype of this, with + * additional specificity such as on objects where here `Record` is used. + */ + export interface Schema { + name: GlobalRegistry.SchemaNames + RootTypesPresent: ('Query' | 'Mutation' | 'Subscription')[] + RootUnion: SchemaKit.Output.RootType + Root: { + Query: null | SchemaKit.Output.ObjectQuery + Mutation: null | SchemaKit.Output.ObjectMutation + Subscription: null | SchemaKit.Output.ObjectSubscription + } + allTypes: Record< + string, + | SchemaKit.Hybrid.Enum + | SchemaKit.Output.ObjectQuery + | SchemaKit.Output.ObjectMutation + | SchemaKit.Output.Object$2 + | SchemaKit.Output.Union + | SchemaKit.Output.Interface + > + objects: Record + unions: Record + interfaces: Record + customScalars: { + input: SchemaDrivenDataMap + } + } + } +} + +export type Schema = GraffleGlobal.Schema + +const identifiers = { + Utilities: `Utilities`, +} + +export const ModuleGeneratorSchema = createModuleGenerator( + `Schema`, + ({ config, code }) => { + const SchemaBuildtimeNamespace = `Schema` + const MethodsRootNamespace = `MethodsRoot` + code(`/* eslint-disable */`) + code(` + import type * as Data from './${ModuleGeneratorData.name}.js' + import type * as ${SchemaBuildtimeNamespace} from './${ModuleGeneratorSchemaBuildtime.name}.js' + import type * as ${MethodsRootNamespace} from './${ModuleGeneratorMethodsRoot.name}.js' + import type * as ${identifiers.Utilities} from '${config.paths.imports.grafflePackage.utilitiesForGenerated}' + `) + code() + + const rootTypesPresence = { + Query: Grafaid.Schema.KindMap.hasQuery(config.schema.kindMap), + Mutation: Grafaid.Schema.KindMap.hasMutation(config.schema.kindMap), + Subscription: Grafaid.Schema.KindMap.hasSubscription(config.schema.kindMap), + } + + const root = config.schema.kindMap.GraphQLRootType.map(_ => + [_.name, `${SchemaBuildtimeNamespace}.Root.${_.name}`] as const + ) + + const objects = config.schema.kindMap.GraphQLObjectType.map(_ => + [_.name, `${SchemaBuildtimeNamespace}.Object.${_.name}`] as const + ) + const unions = config.schema.kindMap.GraphQLUnionType.map(_ => + [_.name, `${SchemaBuildtimeNamespace}.Union.${_.name}`] as const + ) + const interfaces = config.schema.kindMap.GraphQLInterfaceType.map( + _ => [_.name, `${SchemaBuildtimeNamespace}.Interface.${_.name}`] as const, + ) + const enums = config.schema.kindMap.GraphQLEnumType.map( + _ => [_.name, `${SchemaBuildtimeNamespace}.Enum.${_.name}`] as const, + ) + + const schema: Code.TermObject = { + name: `Data.Name`, + RootTypesPresent: `[${config.schema.kindMap.GraphQLRootType.map((_) => Code.string(_.name)).join(`, `)}]`, + RootUnion: config.schema.kindMap.GraphQLRootType.map(_ => `${SchemaBuildtimeNamespace}.Root.${_.name}`) + .join(`|`), + Root: { + Query: rootTypesPresence.Query ? `${SchemaBuildtimeNamespace}.Root.Query` : null, + Mutation: rootTypesPresence.Mutation ? `${SchemaBuildtimeNamespace}.Root.Mutation` : null, + Subscription: rootTypesPresence.Subscription ? `${SchemaBuildtimeNamespace}.Root.Subscription` : null, + }, + allTypes: Code.objectFromEntries([ + ...root, + ...enums, + ...objects, + ...unions, + ...interfaces, + ]), + objects: Code.objectFromEntries(objects), + // schemaIndex: identifiers.customScalarsIndex, + unions: Code.objectFromEntries(unions), + interfaces: Code.objectFromEntries(interfaces), + customScalars: `${identifiers.Utilities}.SchemaIndexBase['customScalars']`, + } + + config.extensions.forEach(_ => { + _.onSchema?.({ config, schema }) + }) + + code(Code.export$( + Code.interface$(`Index`, Code.termObject(schema)), + )) + + return code + }, +) diff --git a/src/layers/4_generator/generators/SchemaBuildtime.ts b/src/layers/4_generator/generators/SchemaBuildtime.ts index b537369b4..7d81eaa0d 100644 --- a/src/layers/4_generator/generators/SchemaBuildtime.ts +++ b/src/layers/4_generator/generators/SchemaBuildtime.ts @@ -1,7 +1,7 @@ import { Code } from '../../../lib/Code.js' import { Grafaid } from '../../../lib/grafaid/__.js' import { entries, values } from '../../../lib/prelude.js' -import type { Config } from '../config.js' +import type { Config } from '../config/config.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { getDocumentation } from '../helpers/render.js' import { ModuleGeneratorScalar } from './Scalar.js' @@ -118,7 +118,7 @@ const concreteRenderers = defineConcreteRenderers({ return Code.TSDocWithBlock(doc, source) }, GraphQLInterfaceType: (config, node) => { - const implementors = Grafaid.Schema.KindMap.getInterfaceImplementors(config.schema.typeMapByKind, node) + const implementors = Grafaid.Schema.KindMap.getInterfaceImplementors(config.schema.kindMap, node) return Code.TSDocWithBlock( getDocumentation(config, node), Code.export$(Code.type( @@ -246,7 +246,7 @@ export const ModuleGeneratorSchemaBuildtime = createModuleGenerator( code(`import type * as $Scalar from './${ModuleGeneratorScalar.name}.js'`) code(`\n\n`) - for (const [name, types] of entries(config.schema.typeMapByKind)) { + for (const [name, types] of entries(config.schema.kindMap)) { if (name === `GraphQLScalarType`) continue if (name === `GraphQLScalarTypeCustom`) continue if (name === `GraphQLScalarTypeStandard`) continue diff --git a/src/layers/4_generator/generators/SchemaIndex.ts b/src/layers/4_generator/generators/SchemaIndex.ts deleted file mode 100644 index 1aa194c4a..000000000 --- a/src/layers/4_generator/generators/SchemaIndex.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { getNamedType, isUnionType } from 'graphql' -import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' -import { Code } from '../../../lib/Code.js' -import { Grafaid } from '../../../lib/grafaid/__.js' -import type { Schema } from '../../1_Schema/__.js' -import type { GlobalRegistry } from '../globalRegistry.js' -import { createModuleGenerator } from '../helpers/moduleGenerator.js' -import { ModuleGeneratorData } from './Data.js' -import { ModuleGeneratorMethodsRoot } from './MethodsRoot.js' -import { ModuleGeneratorSchemaBuildtime } from './SchemaBuildtime.js' - -/** - * A generic schema index type. Any particular schema index will be a subtype of this, with - * additional specificity such as on objects where here `Record` is used. - */ -// todo make all readonly? -export interface SchemaIndex { - name: GlobalRegistry.SchemaNames - RootTypesPresent: ('Query' | 'Mutation' | 'Subscription')[] - RootUnion: Schema.Output.RootType - Root: { - Query: null | Schema.Output.ObjectQuery - Mutation: null | Schema.Output.ObjectMutation - Subscription: null | Schema.Output.ObjectSubscription - } - allTypes: Record< - string, - | Schema.Hybrid.Enum - | Schema.Output.ObjectQuery - | Schema.Output.ObjectMutation - | Schema.Output.Object$2 - | Schema.Output.Union - | Schema.Output.Interface - > - objects: Record - unions: Record - interfaces: Record - customScalars: { - input: SchemaDrivenDataMap - } - error: { - objects: Record - objectsTypename: Record - rootResultFields: { - Query: Record - Mutation: Record - Subscription: Record - } - } -} - -const identifiers = { - Utilities: `Utilities`, -} - -export const ModuleGeneratorSchemaIndex = createModuleGenerator( - `SchemaIndex`, - ({ config, code }) => { - const SchemaBuildtimeNamespace = `Schema` - const MethodsRootNamespace = `MethodsRoot` - code(`/* eslint-disable */`) - code(` - import type * as Data from './${ModuleGeneratorData.name}.js' - import type * as ${SchemaBuildtimeNamespace} from './${ModuleGeneratorSchemaBuildtime.name}.js' - import type * as ${MethodsRootNamespace} from './${ModuleGeneratorMethodsRoot.name}.js' - import type * as ${identifiers.Utilities} from '${config.paths.imports.grafflePackage.utilitiesForGenerated}' - `) - code() - - const rootTypesPresence = { - Query: Grafaid.Schema.KindMap.hasQuery(config.schema.typeMapByKind), - Mutation: Grafaid.Schema.KindMap.hasMutation(config.schema.typeMapByKind), - Subscription: Grafaid.Schema.KindMap.hasSubscription(config.schema.typeMapByKind), - } - - const root = config.schema.typeMapByKind.GraphQLRootType.map(_ => - [_.name, `${SchemaBuildtimeNamespace}.Root.${_.name}`] as const - ) - - const objects = config.schema.typeMapByKind.GraphQLObjectType.map(_ => - [_.name, `${SchemaBuildtimeNamespace}.Object.${_.name}`] as const - ) - const unions = config.schema.typeMapByKind.GraphQLUnionType.map(_ => - [_.name, `${SchemaBuildtimeNamespace}.Union.${_.name}`] as const - ) - const interfaces = config.schema.typeMapByKind.GraphQLInterfaceType.map( - _ => [_.name, `${SchemaBuildtimeNamespace}.Interface.${_.name}`] as const, - ) - const enums = config.schema.typeMapByKind.GraphQLEnumType.map( - _ => [_.name, `${SchemaBuildtimeNamespace}.Enum.${_.name}`] as const, - ) - - code(Code.export$( - Code.interface$( - `Index`, - Code.objectFrom({ - name: `Data.Name`, - RootTypesPresent: `[${ - config.schema.typeMapByKind.GraphQLRootType.map((_) => Code.string(_.name)).join(`, `) - }]`, - RootUnion: config.schema.typeMapByKind.GraphQLRootType.map(_ => `${SchemaBuildtimeNamespace}.Root.${_.name}`) - .join(`|`), - Root: { - type: Code.objectFrom({ - Query: rootTypesPresence.Query ? `${SchemaBuildtimeNamespace}.Root.Query` : null, - Mutation: rootTypesPresence.Mutation ? `${SchemaBuildtimeNamespace}.Root.Mutation` : null, - Subscription: rootTypesPresence.Subscription ? `${SchemaBuildtimeNamespace}.Root.Subscription` : null, - }), - }, - allTypes: Code.objectFromEntries([ - ...root, - ...enums, - ...objects, - ...unions, - ...interfaces, - ]), - objects: Code.objectFromEntries(objects), - // schemaIndex: identifiers.customScalarsIndex, - unions: Code.objectFromEntries(unions), - interfaces: Code.objectFromEntries(interfaces), - customScalars: `${identifiers.Utilities}.SchemaIndexBase['customScalars']`, - // todo jsdoc comment saying: - // Objects that match this pattern name: /.../ - error: Code.objectFrom({ - objects: Code.objectFromEntries( - config.schema.error.objects.map(_ => [_.name, `${SchemaBuildtimeNamespace}.Object.${_.name}`]), - ), - objectsTypename: Code.objectFromEntries( - config.schema.error.objects.map(_ => [_.name, `{ __typename: "${_.name}" }`]), - ), - rootResultFields: `{ - ${!Grafaid.Schema.KindMap.hasQuery(config.schema.typeMapByKind) ? `Query: {}` : ``} - ${!Grafaid.Schema.KindMap.hasMutation(config.schema.typeMapByKind) ? `Mutation: {}` : ``} - ${!Grafaid.Schema.KindMap.hasSubscription(config.schema.typeMapByKind) ? `Subscription: {}` : ``} - ${ - Object.values(config.schema.typeMapByKind.GraphQLRootType).map((rootType) => { - const resultFields = Object.values(rootType.getFields()).filter((field) => { - const type = getNamedType(field.type) - return isUnionType(type) - && type.getTypes().some(_ => config.schema.error.objects.some(__ => __.name === _.name)) - }).map((field) => field.name) - - return `${rootType.name}: {\n${resultFields.map(_ => `${_}: "${_}"`).join(`,\n`)} }` - }).join(`\n`) - } - }`, - }), - }), - ), - )) - - return code - }, -) diff --git a/src/layers/4_generator/generators/Select.ts b/src/layers/4_generator/generators/Select.ts index c9f540b84..edfff81e8 100644 --- a/src/layers/4_generator/generators/Select.ts +++ b/src/layers/4_generator/generators/Select.ts @@ -2,14 +2,14 @@ import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { renderName, title1, typeTitle } from '../helpers/render.js' import { ModuleGeneratorData } from './Data.js' -import { ModuleGeneratorSchemaIndex } from './SchemaIndex.js' +import { ModuleGeneratorSchema } from './Schema.js' import { ModuleGeneratorSelectionSets } from './SelectionSets.js' export const ModuleGeneratorSelect = createModuleGenerator( `Select`, ({ config, code }) => { code(`import * as Data from './${ModuleGeneratorData.name}.js'`) - code(`import type { Index } from './${ModuleGeneratorSchemaIndex.name}.js'`) + code(`import type { Index } from './${ModuleGeneratorSchema.name}.js'`) code(`import type { InferResult } from '${config.paths.imports.grafflePackage.schema}'`) code(`import type * as SelectionSets from './${ModuleGeneratorSelectionSets.name}.js'`) code() @@ -26,7 +26,7 @@ export const ModuleGeneratorSelect = createModuleGenerator( code(typeTitle(config, `Root`)) - code(...config.schema.typeMapByKind.GraphQLRootType.map((type) => { + code(...config.schema.kindMap.GraphQLRootType.map((type) => { return `export type ${type.name}<$SelectionSet extends SelectionSets.${ renderName(type) }> = InferResult.Root<$SelectionSet, Index, '${type.name}'>` @@ -35,7 +35,7 @@ export const ModuleGeneratorSelect = createModuleGenerator( code(typeTitle(config, `Object`)) // TODO propagate descriptions to JSDoc - code(...config.schema.typeMapByKind.GraphQLObjectType.map((type) => { + code(...config.schema.kindMap.GraphQLObjectType.map((type) => { return `export type ${type.name}<$SelectionSet extends SelectionSets.${ renderName(type) }> = InferResult.Object<$SelectionSet, Index, Index['allTypes']['${type.name}']>` @@ -43,7 +43,7 @@ export const ModuleGeneratorSelect = createModuleGenerator( code(typeTitle(config, `Union`)) - code(...config.schema.typeMapByKind.GraphQLUnionType.map((type) => { + code(...config.schema.kindMap.GraphQLUnionType.map((type) => { return `export type ${type.name}<$SelectionSet extends SelectionSets.${ renderName(type) }> = InferResult.Union<$SelectionSet, Index, Index['allTypes']['${type.name}']>` @@ -51,7 +51,7 @@ export const ModuleGeneratorSelect = createModuleGenerator( code(typeTitle(config, `Interface`)) - code(...config.schema.typeMapByKind.GraphQLInterfaceType.map((type) => { + code(...config.schema.kindMap.GraphQLInterfaceType.map((type) => { return `export type ${type.name}<$SelectionSet extends SelectionSets.${ renderName(type) }> = InferResult.Interface<$SelectionSet, Index, Index['allTypes']['${type.name}']>` diff --git a/src/layers/4_generator/generators/SelectionSets.ts b/src/layers/4_generator/generators/SelectionSets.ts index 427749de2..1858cfd8b 100644 --- a/src/layers/4_generator/generators/SelectionSets.ts +++ b/src/layers/4_generator/generators/SelectionSets.ts @@ -18,7 +18,7 @@ export const ModuleGeneratorSelectionSets = createModuleGenerator( code(`import type { Select as $Select } from '${config.paths.imports.grafflePackage.schema}'`) code(`import type * as $Utilities from '${config.paths.imports.grafflePackage.utilitiesForGenerated}'`) - if (Grafaid.Schema.KindMap.hasCustomScalars(config.schema.typeMapByKind)) { + if (Grafaid.Schema.KindMap.hasCustomScalars(config.schema.kindMap)) { code(`import type * as $Scalar from './${ModuleGeneratorScalar.name}.js'`) } code() @@ -30,19 +30,19 @@ export const ModuleGeneratorSelectionSets = createModuleGenerator( ) code( `export interface $Document {`, - Grafaid.Schema.KindMap.hasQuery(config.schema.typeMapByKind) ? `query?: Record` : null, - Grafaid.Schema.KindMap.hasMutation(config.schema.typeMapByKind) ? `mutation?: Record` : null, + Grafaid.Schema.KindMap.hasQuery(config.schema.kindMap) ? `query?: Record` : null, + Grafaid.Schema.KindMap.hasMutation(config.schema.kindMap) ? `mutation?: Record` : null, `}`, ) code() const typesToRender = [ - config.schema.typeMapByKind.GraphQLRootType, - config.schema.typeMapByKind.GraphQLEnumType, - config.schema.typeMapByKind.GraphQLInputObjectType, - config.schema.typeMapByKind.GraphQLInterfaceType, - config.schema.typeMapByKind.GraphQLObjectType, - config.schema.typeMapByKind.GraphQLUnionType, + config.schema.kindMap.GraphQLRootType, + config.schema.kindMap.GraphQLEnumType, + config.schema.kindMap.GraphQLInputObjectType, + config.schema.kindMap.GraphQLInterfaceType, + config.schema.kindMap.GraphQLObjectType, + config.schema.kindMap.GraphQLUnionType, ].filter(_ => _.length > 0) typesToRender.forEach((nodes) => { @@ -137,7 +137,7 @@ const renderInterface = createCodeGenerator<{ node: Grafaid.Schema.InterfaceType const fieldsRendered = fields.map(field => { return Helpers.outputField(field.name, `${renderName(node)}.${renderName(field)}`) }).join(`\n`) - const implementorTypes = Grafaid.Schema.KindMap.getInterfaceImplementors(config.schema.typeMapByKind, node) + const implementorTypes = Grafaid.Schema.KindMap.getInterfaceImplementors(config.schema.kindMap, node) const onTypesRendered = implementorTypes.map(type => Helpers.outputField(`${Select.InlineFragment.typeConditionPRefix}${type.name}`, renderName(type)) ).join( diff --git a/src/layers/4_generator/generators/_.ts b/src/layers/4_generator/generators/_.ts index fb5f3bce0..3eb69e467 100644 --- a/src/layers/4_generator/generators/_.ts +++ b/src/layers/4_generator/generators/_.ts @@ -1,3 +1,4 @@ +import { ModuleGeneratorSchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/generator.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { ModuleGeneratorClient } from './Client.js' import { ModuleGeneratorSelect } from './Select.js' @@ -16,6 +17,7 @@ export const ModuleGenerator_ = createModuleGenerator( `export { Select } from './modules/${ModuleGeneratorSelect.name}.js'`, `export { create } from './modules/${ModuleGeneratorClient.name}.js'`, `export * as SelectionSets from './modules/${ModuleGeneratorSelectionSets.name}.js'`, + `export { schemaDrivenDataMap } from './modules/${ModuleGeneratorSchemaDrivenDataMap.name}.js'`, ) return code diff --git a/src/layers/4_generator/generators/__.ts b/src/layers/4_generator/generators/__.ts index d9cb3bf1d..819c1bb48 100644 --- a/src/layers/4_generator/generators/__.ts +++ b/src/layers/4_generator/generators/__.ts @@ -1,8 +1,9 @@ import { capitalizeFirstLetter } from '../../../lib/prelude.js' -import { defaultName } from '../config.js' +import { defaultName } from '../config/defaults.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { ModuleGenerator_ } from './_.js' +// todo remove, use config.name simply, any processing, do in config constructor export const defaultNamespace = `Graffle` export const ModuleGenerator__ = createModuleGenerator( diff --git a/src/layers/4_generator/generators/global.ts b/src/layers/4_generator/generators/global.ts index 2b13e15cb..0ef95e926 100644 --- a/src/layers/4_generator/generators/global.ts +++ b/src/layers/4_generator/generators/global.ts @@ -1,30 +1,29 @@ import { Code } from '../../../lib/Code.js' -import { Grafaid } from '../../../lib/grafaid/__.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { ModuleGeneratorData } from './Data.js' import { ModuleGeneratorMethodsDocument } from './MethodsDocument.js' import { ModuleGeneratorMethodsRoot } from './MethodsRoot.js' import { ModuleGeneratorMethodsSelect } from './MethodsSelect.js' import { ModuleGeneratorScalar } from './Scalar.js' -import { ModuleGeneratorSchemaIndex } from './SchemaIndex.js' +import { ModuleGeneratorSchema } from './Schema.js' export const ModuleGeneratorGlobal = createModuleGenerator( `Global`, ({ config, code }) => { - const StandardScalarNamespace = `StandardScalar` - const needsDefaultCustomScalarImplementation = Grafaid.Schema.KindMap.hasCustomScalars(config.schema.typeMapByKind) - && !config.options.customScalars + const identifiers = { + Scalar: `Scalar`, + } code( `import type * as Data from './${ModuleGeneratorData.name}.js'`, `import type * as MethodsSelect from './${ModuleGeneratorMethodsSelect.name}.js'`, `import type * as MethodsDocument from './${ModuleGeneratorMethodsDocument.name}.js'`, `import type * as MethodsRoot from './${ModuleGeneratorMethodsRoot.name}.js'`, - `import type { Index } from './${ModuleGeneratorSchemaIndex.name}.js'`, + `import type { Index } from './${ModuleGeneratorSchema.name}.js'`, ) - if (config.schema.typeMapByKind.GraphQLScalarTypeCustom.length > 0) { - code(`import type * as Scalar from './${ModuleGeneratorScalar.name}.js'`) + if (config.schema.kindMap.GraphQLScalarTypeCustom.length > 0) { + code(`import type * as ${identifiers.Scalar} from './${ModuleGeneratorScalar.name}.js'`) } code() @@ -32,35 +31,35 @@ export const ModuleGeneratorGlobal = createModuleGenerator( ? `\n${Code.TSDoc(config.options.defaultSchemaUrl.href)}` : `` - const customScalarsProperties = config.schema.typeMapByKind.GraphQLScalarTypeCustom - .map((_) => { - return `${_.name}: ${ - needsDefaultCustomScalarImplementation ? `${StandardScalarNamespace}.String` : `Scalar.${_.name}` - }` - }).join(`\n`) + const customScalarsProperties = config.schema.kindMap.GraphQLScalarTypeCustom + .map((_) => [_.name, `${identifiers.Scalar}.${_.name}`]) + + const SchemasFields = Code.termObjectFields({ + [config.name]: { + name: `Data.Name`, + index: `Index`, + interfaces: { + MethodsSelect: `MethodsSelect.$MethodsSelect`, + Document: `MethodsDocument.BuilderMethodsDocumentFn`, + Root: `MethodsRoot.BuilderMethodsRootFn`, + }, + customScalars: Object.fromEntries(customScalarsProperties), + defaultSchemaUrl: { + $TS_DOC: defaultSchemaUrlTsDoc, + $VALUE: config.options.defaultSchemaUrl ? `string` : `null`, + }, + }, + }) code(` declare global { - export namespace GraffleGlobalTypes { + export namespace GraffleGlobal { export interface Schemas { - ${config.name}: { - name: Data.Name - index: Index - interfaces: { - MethodsSelect: MethodsSelect.$MethodsSelect - Document: MethodsDocument.BuilderMethodsDocumentFn - Root: MethodsRoot.BuilderMethodsRootFn - } - customScalars: { - ${customScalarsProperties} - } - ${defaultSchemaUrlTsDoc} - defaultSchemaUrl: ${config.options.defaultSchemaUrl ? `string` : `null`} + ${SchemasFields} } } } - } - `) + `) return code }, diff --git a/src/layers/4_generator/globalRegistry.ts b/src/layers/4_generator/globalRegistry.ts index 00b5308a6..28c8bc953 100644 --- a/src/layers/4_generator/globalRegistry.ts +++ b/src/layers/4_generator/globalRegistry.ts @@ -1,10 +1,10 @@ import type { TypeFunction } from '../../entrypoints/utilities-for-generated.js' import type { Values } from '../../lib/prelude.js' -import type { TSErrorDescriptive } from '../../lib/TSError.js' -import type { SchemaIndex } from './generators/SchemaIndex.js' +import type { TSErrorDescriptive } from '../../lib/ts-error.js' +import type { Schema } from './generators/Schema.js' declare global { - export namespace GraffleGlobalTypes { + export namespace GraffleGlobal { interface Schemas {} // Use this is for manual internal type testing. interface SchemasAlwaysEmpty {} @@ -14,7 +14,7 @@ declare global { type ZeroSchema = { name: GlobalRegistry.DefaultSchemaName index: { name: never } - featureOptions: {} + // featureOptions: {} interfaces: { MethodsSelect: {} } @@ -26,7 +26,7 @@ export type GlobalRegistry = Record export namespace GlobalRegistry { export interface RegisteredSchema { name: string - index: SchemaIndex + index: Schema // featureOptions: {} interfaces: { Root: TypeFunction.Fn @@ -41,15 +41,15 @@ export namespace GlobalRegistry { export type DefaultSchemaName = 'default' - export type Schemas = GraffleGlobalTypes.Schemas + export type Schemas = GraffleGlobal.Schemas export type IsEmpty = keyof Schemas extends never ? true : false export type SchemaUnion = IsEmpty extends true ? ZeroSchema : Values - export type SchemaNames = keyof GraffleGlobalTypes.Schemas extends never + export type SchemaNames = keyof GraffleGlobal.Schemas extends never ? TSErrorDescriptive<'SchemaNames', 'No schemas have been registered. Did you run graffle generate?'> - : keyof GraffleGlobalTypes.Schemas + : keyof GraffleGlobal.Schemas // dprint-ignore export type HasDefaultUrlForSchema<$Schema extends SchemaUnion> = @@ -59,7 +59,7 @@ export namespace GlobalRegistry { // eslint-disable-next-line // @ts-ignore passes after generation - export type GetSchemaIndex<$Name extends SchemaNames> = GraffleGlobalTypes.Schemas[$Name]['index'] + export type GetSchemaIndex<$Name extends SchemaNames> = GraffleGlobal.Schemas[$Name]['index'] // eslint-disable-next-line // @ts-ignore passes after generation @@ -70,10 +70,10 @@ export namespace GlobalRegistry { $Name extends SchemaNames // eslint-disable-next-line // @ts-ignore passes after generation - ? GraffleGlobalTypes.Schemas[$Name] + ? GraffleGlobal.Schemas[$Name] // eslint-disable-next-line // @ts-ignore passes after generation - : GraffleGlobalTypes.Schemas[DefaultSchemaName] + : GraffleGlobal.Schemas[DefaultSchemaName] // dprint-ignore export type GetSchemaIndexOrDefault<$Name extends SchemaNames | undefined> = diff --git a/src/layers/4_generator/helpers/fs.ts b/src/layers/4_generator/helpers/fs.ts deleted file mode 100644 index 3956efe83..000000000 --- a/src/layers/4_generator/helpers/fs.ts +++ /dev/null @@ -1,18 +0,0 @@ -import fs from 'node:fs/promises' -import { errorFromMaybeError } from '../../../lib/prelude.js' - -export const fileExists = async (path: string) => { - return Boolean( - await fs.stat(path).catch((_: unknown) => { - const error = errorFromMaybeError(_) - return `code` in error && typeof error.code === `string` && error.code === `ENOENT` - ? null - : Promise.reject(error) - }), - ) -} - -export const isPathToADirectory = async (path: string) => { - const stat = await fs.stat(path) - return stat.isDirectory() -} diff --git a/src/layers/4_generator/helpers/moduleGeneratorRunner.ts b/src/layers/4_generator/helpers/moduleGeneratorRunner.ts index 6f0b38021..faf170188 100644 --- a/src/layers/4_generator/helpers/moduleGeneratorRunner.ts +++ b/src/layers/4_generator/helpers/moduleGeneratorRunner.ts @@ -1,4 +1,4 @@ -import type { Config } from '../config.js' +import type { Config } from '../config/config.js' import type { GeneratedModule } from './moduleGenerator.js' type FactoryModuleGeneratorRunner = <$CustomInput extends object = {}>( diff --git a/src/layers/4_generator/helpers/render.ts b/src/layers/4_generator/helpers/render.ts index 441e96cac..34df74c84 100644 --- a/src/layers/4_generator/helpers/render.ts +++ b/src/layers/4_generator/helpers/render.ts @@ -2,7 +2,7 @@ import { Code } from '../../../lib/Code.js' import { Grafaid } from '../../../lib/grafaid/__.js' import { getNodeDisplayName } from '../../../lib/grafaid/graphql.js' import { borderThickFullWidth, borderThinFullWidth, centerTo } from '../../../lib/text.js' -import type { Config } from '../config.js' +import type { Config } from '../config/config.js' export const title1 = (title: string, subTitle?: string) => { const titleDecorated = ` @@ -49,7 +49,7 @@ export const typeTitle2 = (category: string) => (type: Grafaid.Schema.NamedTypes export const typeTitle2SelectionSet = typeTitle2(`GRAPHQL SELECTION SET`) export const typeTitle = (config: Config, typeKind: Grafaid.Schema.NamedTypeKind) => { - const hasItems = config.schema.typeMapByKind[`GraphQL${typeKind}Type`].length > 0 + const hasItems = config.schema.kindMap[`GraphQL${typeKind}Type`].length > 0 const title = `${typeKind} Types` const titleDecorated = `// ${title}\n// ${`-`.repeat(title.length)}\n` if (hasItems) { diff --git a/src/layers/5_request/core.ts b/src/layers/5_request/core.ts index c9e655bca..a3e8c8b55 100644 --- a/src/layers/5_request/core.ts +++ b/src/layers/5_request/core.ts @@ -26,7 +26,7 @@ import { } from './hooks.js' import { Transport } from './types.js' -export const graffleMappedToRequest = ( +export const graffleMappedResultToRequest = ( { document, operationsVariables }: SelectionSetGraphqlMapper.Encoded, operationName?: string, ): Grafaid.RequestAnalyzedDocumentNodeInput => { @@ -69,7 +69,7 @@ export const anyware = Anyware.create({ if (input.interfaceType === `raw`) { request = input.request } else { - request = graffleMappedToRequest( + request = graffleMappedResultToRequest( SelectionSetGraphqlMapper.toGraphQL(input.request.document, { sddm: input.state.config.schemaMap, }), diff --git a/src/layers/6_client/Settings/Config.ts b/src/layers/6_client/Settings/Config.ts index 3bbe1c42b..3eab0c490 100644 --- a/src/layers/6_client/Settings/Config.ts +++ b/src/layers/6_client/Settings/Config.ts @@ -1,5 +1,5 @@ import type { GraphQLSchema } from 'graphql' -import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { RequireProperties } from '../../../lib/prelude.js' import type { GlobalRegistry } from '../../4_generator/globalRegistry.js' import type { TransportHttp, TransportMemory } from '../../5_request/types.js' diff --git a/src/layers/6_client/Settings/Input.ts b/src/layers/6_client/Settings/Input.ts index be28caba3..1867bf45e 100644 --- a/src/layers/6_client/Settings/Input.ts +++ b/src/layers/6_client/Settings/Input.ts @@ -1,5 +1,5 @@ import type { GraphQLSchema } from 'graphql' -import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { GlobalRegistry } from '../../4_generator/globalRegistry.js' import type { WithInput } from './inputIncrementable/inputIncrementable.js' diff --git a/src/layers/6_client/prefilled.ts b/src/layers/6_client/prefilled.ts index 0cf3c8f10..0ea97d4b0 100644 --- a/src/layers/6_client/prefilled.ts +++ b/src/layers/6_client/prefilled.ts @@ -1,5 +1,5 @@ import type { HasRequiredKeys } from 'type-fest' -import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/types.js' +import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { Exact } from '../../lib/prelude.js' import type { GlobalRegistry } from '../4_generator/globalRegistry.js' import { type Client, create } from './client.js' diff --git a/src/layers/6_client/requestMethods/document.ts b/src/layers/6_client/requestMethods/document.ts index ba7cd0ed0..588c366f3 100644 --- a/src/layers/6_client/requestMethods/document.ts +++ b/src/layers/6_client/requestMethods/document.ts @@ -2,14 +2,14 @@ import type { UnionToTuple } from 'type-fest' import type { IsTupleMultiple } from '../../../lib/prelude.js' import type { Select } from '../../2_Select/__.js' import type { InferResult } from '../../3_InferResult/__.js' -import type { SchemaIndex } from '../../4_generator/generators/SchemaIndex.js' +import type { Schema } from '../../4_generator/generators/Schema.js' import { type HandleOutput } from '../handleOutput.js' import type { Config } from '../Settings/Config.js' // dprint-ignore export type DocumentRunner< $$Config extends Config, - $$Schema extends SchemaIndex, + $$Schema extends Schema, $$Document extends Select.Document.SomeDocument, $$Name extends Select.Document.GetOperationNames<$$Document> = Select.Document.GetOperationNames<$$Document> > = { diff --git a/src/lib/Code.ts b/src/lib/Code.ts index 73ce8a9f2..6b29d2552 100644 --- a/src/lib/Code.ts +++ b/src/lib/Code.ts @@ -1,76 +1,108 @@ import { entries, isString } from './prelude.js' import { linesPrepend, linesTrim } from './text.js' -type FieldTuple = [k: string, v: string] +type FieldTuple = [k: string, v: string | null, tsDoc?: string | null] export namespace Code { export const field = (name: string, type: string, options?: { optional?: boolean }) => { if (options?.optional) return `${name}?: ${type}` return `${name}: ${type}` } - export interface TermObjectWith { + export interface DirectiveTermObject { $spread?: string[] - $fields?: TermObject | TermObjectWith + $fields?: TermObject | DirectiveTermObject $literal?: string } - export type TermPrimitive = string | number | boolean + export type TermPrimitive = null | string | number | boolean - export type TermObjectWithLike<$Fields extends null | TermObject | TermObjectWith = null> = { + export type DirectiveTermObjectLike<$Fields extends null | TermObject | DirectiveTermObject = null> = { $spread?: string[] $literal?: string - } & ($Fields extends null ? { $fields?: TermObject | TermObjectWith } : { $fields: $Fields }) + } & ($Fields extends null ? { $fields?: TermObject | DirectiveTermObject } : { $fields: $Fields }) - const isTermObjectWith = (value: unknown): value is TermObjectWith => { + const isDirectiveTermObject = (value: unknown): value is DirectiveTermObject => { if (typeof value !== `object` || value === null) return false return Object.keys(value).some(key => key === `$spread` || key === `$fields` || key === `$fieldsMerge`) } + const isDirectiveField = (value: unknown): value is DirectiveField => { + if (typeof value !== `object` || value === null) return false + return DirectiveFieldKeys.$VALUE in value + } + + const isFieldPrimitive = (value: unknown): value is TermPrimitive => { + return isString(value) || typeof value === `number` || typeof value === `boolean` + } + + type Field = TermPrimitive | DirectiveTermObject | TermObject + + interface DirectiveField { + $TS_DOC?: string + $VALUE: Field + } + + const DirectiveFieldKeys = { + $TS_DOC: `$TS_DOC`, + $VALUE: `$VALUE`, + } + export interface TermObject { - [key: string]: TermPrimitive | TermObjectWith | TermObject + [key: string]: Field | DirectiveField } export type TermObjectOf = { [key: string]: T } - export const termObjectWith = (objectWith: TermObjectWith): string => { - // const object = [...(objectWith.$fields ? [objectWith.$fields] : []), ...(objectWith.$fieldsMerge ?? [])].reduce( - // (finalO, o) => { - // if (isTermObjectWith(o)) { - // return { ...finalO, ...o } - // } - // return { ...finalO, ...o } - // }, - // {}, - // ) + export const directiveTermObject = (objectWith: DirectiveTermObject): string => { const spreads = (objectWith.$spread ?? []).map(spread => `...${spread},`) return block( - spreads.join(`\n`) + `\n` + termObjectFields(objectWith.$fields ?? {}) + spreads.join(`\n`) + + `\n` + + termObjectFields(objectWith.$fields ?? {}) + (objectWith.$literal ? `\n${objectWith.$literal}` : ``), ) } + // terms - export const termObject = (object: TermObject): string => { + + export const termObject = (object: TermObject | DirectiveTermObject): string => { + if (isDirectiveTermObject(object)) return directiveTermObject(object) return block(termObjectFields(object)) } - export const termObjectFields = (object: TermObject | TermObjectWith): string => + + export const termObjectFields = (object: TermObject | DirectiveTermObject): string => termFieldsFromTuples( entries(object).map(([key, value]): FieldTuple => { - const valueNormalized = isTermObjectWith(value) - ? termObjectWith(value) + if (value === null) return [key, null] + + const [valueNormalized, tsDoc] = isDirectiveTermObject(value) + ? [directiveTermObject(value), null] + : isDirectiveField(value) + ? [termObjectField(value.$VALUE), value.$TS_DOC] : isString(value) || typeof value === `number` || typeof value === `boolean` - ? String(value) - : termObject(value as any) - return [key, valueNormalized] + ? [String(value), null] + : [termObject(value as any), null] + return [key, valueNormalized, tsDoc] }), ) + const termObjectField = (field: Field): string => { + if (isFieldPrimitive(field)) return String(field) + return termObject(field) + } + export const termFieldsFromTuples = (fields: FieldTuple[]) => fields.map(termFieldFromTuple).join(`\n`) export const termList = (value: string[]) => `[${value.join(`, `)}]` - export const termFieldFromTuple = (tuple: FieldTuple) => Code.termField(tuple[0], tuple[1]) - export const termField = (name: string, type: string, options?: { comma?: boolean }) => { - return `${name}: ${type}${(options?.comma ?? true) ? `,` : ``}` + export const termFieldFromTuple = (tuple: FieldTuple) => Code.termField(tuple[0], tuple[1], { tsDoc: tuple[2] }) + export const termField = ( + key: string, + value: string | undefined | null, + options?: { tsDoc?: string | null; comma?: boolean }, + ) => { + if (value === undefined || value === ``) return `` + return `${options?.tsDoc ? `${options.tsDoc}\n` : ``}${key}: ${String(value)}${(options?.comma ?? true) ? `,` : ``}` } export const termConst = (name: string, value?: string) => termConstTyped(name, null, value) export const termConstTyped = (name: string, type: string | null, value?: string) => diff --git a/src/lib/analyzeFunction.ts b/src/lib/analyze-function.ts similarity index 100% rename from src/lib/analyzeFunction.ts rename to src/lib/analyze-function.ts diff --git a/src/lib/anyware/getEntrypoint.ts b/src/lib/anyware/getEntrypoint.ts index 539d458cc..f372784a5 100644 --- a/src/lib/anyware/getEntrypoint.ts +++ b/src/lib/anyware/getEntrypoint.ts @@ -1,5 +1,5 @@ // import type { Extension, HookName } from '../../layers/5_client/extension/types.js' -import { analyzeFunction } from '../analyzeFunction.js' +import { analyzeFunction } from '../analyze-function.js' import { ContextualError } from '../errors/ContextualError.js' import type { HookName } from './hook/definition.js' import type { NonRetryingExtensionInput } from './main.js' diff --git a/src/lib/config-manager/ConfigManager.test.ts b/src/lib/config-manager/ConfigManager.test.ts new file mode 100644 index 000000000..c6c69a5fc --- /dev/null +++ b/src/lib/config-manager/ConfigManager.test.ts @@ -0,0 +1,120 @@ +import { describe, expect, expectTypeOf, test } from 'vitest' +import { ConfigManager } from './__.js' + +test(`defaults are merged into input value`, () => { + const defaults = { a: 1 } + const input = {} + const result = ConfigManager.mergeDefaults(defaults, input) + expectTypeOf(result).toEqualTypeOf<{ a: number }>() + expect(result).toEqual({ a: 1 }) +}) + +test(`keys with undefined are ignored`, () => { + const defaults = { a: 1 } + const input = { a: undefined } + const result = ConfigManager.mergeDefaults(defaults, input) + expectTypeOf(result).toEqualTypeOf<{ a: number }>() + expect(result).toEqual({ a: 1 }) +}) + +test(`input value is mutated`, () => { + const defaults = { a: 1 } + const input = {} + const result = ConfigManager.mergeDefaults(defaults, input) + expect(result).toBe(input) +}) + +test(`input value takes precedence`, () => { + const defaults = { a: 1 } + const input = { a: 2 } + const result = ConfigManager.mergeDefaults(defaults, input) + expect(result).toEqual({ a: 2 }) +}) + +test(`defaults is not mutated`, () => { + const defaults = { a: 1 } + const input = { a: 2 } + ConfigManager.mergeDefaults(defaults, input) + expect(defaults).toEqual({ a: 1 }) +}) + +test(`nested objects are merged`, () => { + const defaults = { a: { b: 2 } } + const input = {} + const result = ConfigManager.mergeDefaults(defaults, input) + expectTypeOf(result).toEqualTypeOf<{ a: { b: number } }>() + expect(result).toEqual({ a: { b: 2 } }) +}) + +test(`nested object input value takes precedence`, () => { + const defaults = { a: { b: 2 } } + const input = { a: { b: 3 } } + const result = ConfigManager.mergeDefaults(defaults, input) + expectTypeOf(result).toEqualTypeOf<{ a: { b: number } }>() + expect(result).toEqual({ a: { b: 3 } }) +}) + +test(`error if input object has non-object at expected object node`, () => { + const defaults = { a: { b: 2 } } + const input = { a: 1 } + // @ts-expect-error: input is not a sub-type of defaults + expect(() => ConfigManager.mergeDefaults(defaults, input)).toThrowErrorMatchingInlineSnapshot( + `[Error: Mismatch between defaults and input. Defaults expect an object at this node. Input was: 1]`, + ) +}) + +test(`works with interface-typed values`, () => { + interface Defaults { + a: number + } + interface Input { + a?: number + } + const defaults: Defaults = { a: 1 } + const input: Input = {} + const result = ConfigManager.mergeDefaults(defaults, input) + expectTypeOf(result).toEqualTypeOf<{ a: number }>() + expect(result).toEqual({ a: 1 }) +}) + +test(`works with interface-typed nested-object values`, () => { + interface Defaults { + a: { + b: number + } + } + interface Input { + a?: { + b?: number + } + } + const defaults: Defaults = { a: { b: 2 } } + const input: Input = {} + const result = ConfigManager.mergeDefaults(defaults, input) + expectTypeOf(result).toEqualTypeOf<{ a: { b: number } }>() + expect(result).toEqual({ a: { b: 2 } }) +}) + +test(`input can be undefined, returns defaults`, () => { + const defaults = { a: 1 } + const result = ConfigManager.mergeDefaults(defaults, undefined) + expectTypeOf(result).toEqualTypeOf(defaults) + expect(result).toBe(defaults) +}) + +describe(`default custom scalars`, () => { + test(`By default are dates and functions`, () => { + const defaults = { a: new Date(0), b: () => 0 } + const input = {} + const result = ConfigManager.mergeDefaults(defaults, input) + expectTypeOf(result).toEqualTypeOf<{ a: Date; b: () => number }>() + expect(result).toEqual({ a: defaults.a, b: defaults.b }) + }) + test(`input takes precedence`, () => { + const defaults = { a: new Date(0), b: () => 0 } + const input = { a: new Date(1), b: () => 2 } + const result = ConfigManager.mergeDefaults(defaults, input) + expectTypeOf(result).toEqualTypeOf<{ a: Date; b: () => number }>() + expect(result).toEqual({ a: input.a, b: input.b }) + }) +}) diff --git a/src/lib/config-manager/ConfigManager.ts b/src/lib/config-manager/ConfigManager.ts index b03f9e002..f0fb98f97 100644 --- a/src/lib/config-manager/ConfigManager.ts +++ b/src/lib/config-manager/ConfigManager.ts @@ -1,4 +1,93 @@ -import type { IsUnknown, Simplify } from 'type-fest' +import type { IsUnknown, PartialDeep, Simplify } from 'type-fest' +import { isDate } from 'util/types' +import { type ExcludeUndefined, type GuardedType, isAnyFunction, isNonNullObject } from '../prelude.js' + +// dprint-ignore +export type MergeDefaults<$Defaults extends object, $Input extends undefined | object, $CustomScalars> = + $Input extends undefined + ? $Defaults + : { + [$Key in keyof $Defaults]: + $Key extends keyof $Input + ? $Input[$Key] extends undefined + ? $Defaults[$Key] + : MergeDefaultsValues<$Defaults[$Key], ExcludeUndefined<$Input[$Key]>, $CustomScalars> + : $Defaults[$Key] + } + +// dprint-ignore +type MergeDefaultsValues<$DefaultValue, $InputValue, $CustomScalars> = +$InputValue extends $CustomScalars + ? $DefaultValue extends $CustomScalars + ? $InputValue // Treat as terminal + : never // Mismatch between defaults and input + : $InputValue extends object + ? $DefaultValue extends object + ? Simplify> + : never // Defaults disagrees with Input + : $InputValue + +export const createMerger = <$CustomScalars extends CustomScalarGuard[]>( + customScalars: $CustomScalars, +): MergeDefaultsFn> => { + return (defaults, input) => mergeDefaults_(defaults, input, customScalars) as any +} + +type MergeDefaultsFn<$CustomScalars> = <$Defaults extends object, $Input extends undefined | PartialDeep<$Defaults>>( + defaults: $Defaults, + input?: $Input, +) => Simplify> + +type MergeDefaultsInnerFn = ( + defaults: object, + input: object | undefined, + customScalars: CustomScalarGuard[], +) => object + +type CustomScalarGuard = (value: object) => boolean + +const isUrl = (value: object): value is URL => value instanceof URL + +export const mergeDefaults = createMerger([isAnyFunction, isDate, isUrl]) + +const mergeDefaults_: MergeDefaultsInnerFn = ( + defaults, + input, + customScalars, +) => { + if (input === undefined) { + return defaults + } + + const i = input as Record + const d = defaults as Record + + for (const key in d) { + const defaultValue = d[key] + + if (key in i && i[key] !== undefined) { + const inputValue = i[key] + if (isNonNullObject(defaultValue)) { + if (isNonNullObject(inputValue)) { + const isCustomScalar = customScalars.some(isCustomScalar => isCustomScalar(inputValue)) + if (!isCustomScalar) { + mergeDefaults_(inputValue, defaultValue, customScalars) + } + } else { + throw new Error( + `Mismatch between defaults and input. Defaults expect an object at this node. Input was: ${ + String(inputValue) + }`, + ) + } + } + } else { + i[key] = defaultValue + } + } + + return i +} type Path = [...string[]] diff --git a/src/lib/fs.ts b/src/lib/fs.ts new file mode 100644 index 000000000..622c716f0 --- /dev/null +++ b/src/lib/fs.ts @@ -0,0 +1,44 @@ +import fs from 'node:fs/promises' +import { extname, isAbsolute, join } from 'node:path' +import { errorFromMaybeError } from './prelude.js' + +export const statMaybeExists = async (path: string) => { + return await fs.stat(path).catch((_: unknown) => { + const error = errorFromMaybeError(_) + return `code` in error && typeof error.code === `string` && error.code === `ENOENT` + ? null + : Promise.reject(error) + }) +} + +export const fileExists = async (path: string) => { + return Boolean(await statMaybeExists(path)) +} + +export const isPathToADirectory = async (path: string) => { + const stat = await fs.stat(path) + return stat.isDirectory() +} + +export const toAbsolutePath = (cwd: string, maybeAbsolutePath: string) => + isAbsolute(maybeAbsolutePath) ? maybeAbsolutePath : join(cwd, maybeAbsolutePath) + +const isFileLikePath = (path: string) => { + return Boolean(extname(path)) +} + +export const toFilePath = (fileName: string, path: string) => { + if (isFileLikePath(path)) { + return path + } else { + return join(path, fileName) + } +} + +// export const toFileChecked = async (fileName: string, path: string) => { +// if (isFileLikePath(path)) { +// return path +// } else { +// return join(path, fileName) +// } +// } diff --git a/src/lib/grafaid/schema/kindMap.ts b/src/lib/grafaid/schema/kindMap.ts index e5d20f5cf..bf0dc53c6 100644 --- a/src/lib/grafaid/schema/kindMap.ts +++ b/src/lib/grafaid/schema/kindMap.ts @@ -20,7 +20,7 @@ export type KindMap = export const getKindMap = (schema: GraphQLSchema): KindMap => { const typeMap = schema.getTypeMap() const typeMapValues = Object.values(typeMap) - const typeMapByKind: KindMap = { + const kindMap: KindMap = { GraphQLRootType: [], GraphQLScalarType: [], GraphQLScalarTypeCustom: [], @@ -35,38 +35,38 @@ export const getKindMap = (schema: GraphQLSchema): KindMap => { if (type.name.startsWith(`__`)) continue switch (true) { case type instanceof GraphQLScalarType: - typeMapByKind.GraphQLScalarType.push(type) + kindMap.GraphQLScalarType.push(type) if (isScalarTypeAndCustom(type)) { - typeMapByKind.GraphQLScalarTypeCustom.push(type) + kindMap.GraphQLScalarTypeCustom.push(type) } else { - typeMapByKind.GraphQLScalarTypeStandard.push(type) + kindMap.GraphQLScalarTypeStandard.push(type) } break case type instanceof GraphQLEnumType: - typeMapByKind.GraphQLEnumType.push(type) + kindMap.GraphQLEnumType.push(type) break case type instanceof GraphQLInputObjectType: - typeMapByKind.GraphQLInputObjectType.push(type) + kindMap.GraphQLInputObjectType.push(type) break case type instanceof GraphQLInterfaceType: - typeMapByKind.GraphQLInterfaceType.push(type) + kindMap.GraphQLInterfaceType.push(type) break case type instanceof GraphQLObjectType: if (type.name === `Query` || type.name === `Mutation` || type.name === `Subscription`) { - typeMapByKind.GraphQLRootType.push(type) + kindMap.GraphQLRootType.push(type) } else { - typeMapByKind.GraphQLObjectType.push(type) + kindMap.GraphQLObjectType.push(type) } break case type instanceof GraphQLUnionType: - typeMapByKind.GraphQLUnionType.push(type) + kindMap.GraphQLUnionType.push(type) break default: // skip break } } - return typeMapByKind + return kindMap } export const hasMutation = (typeMapByKind: KindMap) => typeMapByKind.GraphQLRootType.find((_) => _.name === `Mutation`) diff --git a/src/lib/grafaid/schema/schema.ts b/src/lib/grafaid/schema/schema.ts index 3d396823f..f2fdf4d65 100644 --- a/src/lib/grafaid/schema/schema.ts +++ b/src/lib/grafaid/schema/schema.ts @@ -21,6 +21,8 @@ import { import { GraphQLInputObjectType, isScalarType } from 'graphql' export { + buildClientSchema, + buildSchema, getNamedType, getNullableType, type GraphQLArgument as Argument, @@ -51,6 +53,7 @@ export { isRequiredInputField, isScalarType, isUnionType, + printSchema as print, } from 'graphql' export * as Args from './args.js' @@ -106,8 +109,16 @@ export const isScalarTypeCustom = (node: GraphQLScalarType): boolean => { return node.astNode !== undefined } +export const standardScalarTypeNames = { + String: `String`, + ID: `ID`, + Int: `Int`, + Float: `Float`, + Boolean: `Boolean`, +} + export const isScalarTypeAndCustom = (node: unknown): node is GraphQLScalarType => { - return isScalarType(node) && node.astNode !== undefined + return isScalarType(node) && !(node.name in standardScalarTypeNames) } export const isAllInputObjectFieldsNullable = (node: GraphQLInputObjectType) => { diff --git a/src/lib/import-first.ts b/src/lib/import-first.ts new file mode 100644 index 000000000..9db2c8ef7 --- /dev/null +++ b/src/lib/import-first.ts @@ -0,0 +1,28 @@ +import { errorFromMaybeError } from './prelude.js' + +export const importFirst = async ( + paths: string[], +): Promise; path: string }> => { + for (const path of paths) { + try { + return { + module: await import(path), + path, + } + } catch (value) { + if (isModuleNotFoundError(value)) { + // silence + } else { + return errorFromMaybeError(value) + } + } + } + + return undefined +} + +const isModuleNotFoundError = (value: unknown) => { + return (value instanceof Error && `code` in value && value.code === ERR_MODULE_NOT_FOUND) +} + +const ERR_MODULE_NOT_FOUND = `ERR_MODULE_NOT_FOUND` diff --git a/src/lib/prelude.ts b/src/lib/prelude.ts index 0ce3182a5..c717b2629 100644 --- a/src/lib/prelude.ts +++ b/src/lib/prelude.ts @@ -553,14 +553,6 @@ export const getOptionalNullablePropertyOrThrow = < return value as ExcludeNullAndUndefined<$Record[$Key]> } -export const omitUndefinedKeys = (obj: T): OmitUndefinedKeys => { - return Object.fromEntries(Object.entries(obj).filter(([_, v]) => v !== undefined)) as any -} - -type OmitUndefinedKeys = { - [K in keyof T as undefined extends T[K] ? K : never]: T[K] -} - export type StringKeyof = keyof T & string export const keysStrict = (obj: T): (keyof T)[] => { @@ -603,3 +595,21 @@ export type AssertConstraint<$Constraint, $Type> = $Type extends $Constraint ? $Type : never + +export const isNonNullObject = (value: unknown): value is object => { + return typeof value === 'object' && value !== null +} + +export const isError = (value: unknown) => { + return value instanceof Error +} + +export type GuardedType = T extends (x: any) => x is infer U ? U : never + +export const isAnyFunction = (value: unknown): value is (...args: any[]) => any => { + return typeof value === 'function' +} + +export const isDate = (value: unknown): value is Date => { + return value instanceof Date +} diff --git a/src/lib/TSError.ts b/src/lib/ts-error.ts similarity index 100% rename from src/lib/TSError.ts rename to src/lib/ts-error.ts diff --git a/src/layers/4_generator/helpers/typeScriptFormatter.ts b/src/lib/typescript-formatter.ts similarity index 95% rename from src/layers/4_generator/helpers/typeScriptFormatter.ts rename to src/lib/typescript-formatter.ts index b93a841d3..15fd88ffc 100644 --- a/src/layers/4_generator/helpers/typeScriptFormatter.ts +++ b/src/lib/typescript-formatter.ts @@ -8,7 +8,7 @@ export const passthroughFormatter: Formatter = { formatText: (content) => content, } -export const getTypeScriptFormatterOrPassthrough = async (): Promise => { +export const getTypescriptFormatterOrPassthrough = async (): Promise => { const formatter = await getTypeScriptFormatter() return formatter ?? passthroughFormatter } diff --git a/tests/_/schemas/generate.ts b/tests/_/schemas/generate.ts index b3dd97acb..4e7b3add8 100644 --- a/tests/_/schemas/generate.ts +++ b/tests/_/schemas/generate.ts @@ -1,62 +1,62 @@ -import { pascalCase } from 'es-toolkit' -import { printSchema } from 'graphql' -import fs from 'node:fs/promises' -import { dirname, join } from 'node:path' +import { join } from 'node:path' import { Generator } from '../../../src/layers/4_generator/__.js' +import { Grafaid } from '../../../src/lib/grafaid/__.js' const generate = async ( input: { dirName: string - name?: boolean - generatorInput?: Omit - defaultSchemaUrl?: URL + input?: Generator.Config.BuilderInput }, ) => { - const name = input.name === false ? undefined : pascalCase(input.dirName) - - const rootDir = join(`./tests/_/schemas/`, input.dirName) - - const outputSchemaPath = join(rootDir, `schema.graphql`) const { schema } = await import(`./${input.dirName}/schema.js`) - await fs.writeFile(outputSchemaPath, printSchema(schema)) + if (!(schema instanceof Grafaid.Schema.Schema)) { + throw new Error(`Expected schema to be an instance of Grafaid.Schema.Schema`) + } - const inputPathRootDir = dirname(outputSchemaPath) - const outputPathRootDir = join(rootDir, `/graffle`) + const inputPathRootDir = join(import.meta.dirname, input.dirName) await Generator.generate({ - schemaSource: { type: `sdl` }, + currentWorkingDirectory: import.meta.dirname, + schema, // todo funky between this and passing path to sdl sourceDirPath: inputPathRootDir, - defaultSchemaUrl: input.defaultSchemaUrl, + outputSDL: true, sourceCustomScalarCodecsFilePath: join(`./tests/_/customScalarCodecs.ts`), - outputDirPath: outputPathRootDir, + outputDirPath: join(input.dirName, `graffle`), libraryPaths: { - client: `../../../../../../src/entrypoints/client.js`, - schema: `../../../../../../src/entrypoints/schema.js`, - scalars: `../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js`, - utilitiesForGenerated: `../../../../../../src/entrypoints/utilities-for-generated.js`, + client: `../../../src/entrypoints/client.ts`, + schema: `../../../src/entrypoints/schema.ts`, + scalars: `../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts`, + utilitiesForGenerated: `../../../src/entrypoints/utilities-for-generated.ts`, }, - name, - ...input.generatorInput, + ...input.input, }) + console.log(`generated at`, inputPathRootDir) } await generate({ dirName: `pokemon`, - defaultSchemaUrl: new URL(`http://localhost:3000/graphql`), + input: { + defaultSchemaUrl: new URL(`http://localhost:3000/graphql`), + name: `Pokemon`, + }, }) await generate({ dirName: `query-only`, + input: { + name: `QueryOnly`, + }, }) await generate({ dirName: `mutation-only`, + input: { + name: `MutationOnly`, + }, }) await generate({ dirName: `kitchen-sink`, - name: false, - generatorInput: { errorTypeNamePattern: /^Error.+/ }, }) diff --git a/tests/_/schemas/kitchen-sink/graffle/_.ts b/tests/_/schemas/kitchen-sink/graffle/_.ts index d5cdf0031..d27e9e3d3 100644 --- a/tests/_/schemas/kitchen-sink/graffle/_.ts +++ b/tests/_/schemas/kitchen-sink/graffle/_.ts @@ -5,5 +5,6 @@ import './modules/Global.js' export { create } from './modules/Client.js' +export { schemaDrivenDataMap } from './modules/SchemaDrivenDataMap.js' export { Select } from './modules/Select.js' export * as SelectionSets from './modules/SelectionSets.js' diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/Client.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Client.ts index bd2e48835..5a25cf4ed 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/Client.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Client.ts @@ -1,5 +1,6 @@ import { createPrefilled } from '../../../../../../src/entrypoints/client.js' import { defaultSchemaUrl } from './Data.js' +import { Name } from './Data.js' import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' -export const create = createPrefilled(`default`, schemaDrivenDataMap, defaultSchemaUrl) +export const create = createPrefilled(Name, schemaDrivenDataMap, defaultSchemaUrl) diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/Global.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Global.ts index b6d4f3a83..f7af69d03 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/Global.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Global.ts @@ -2,11 +2,10 @@ import type * as Data from './Data.js' import type * as MethodsDocument from './MethodsDocument.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as MethodsSelect from './MethodsSelect.js' -import type * as Scalar from './Scalar.js' import type { Index } from './SchemaIndex.js' declare global { - export namespace GraffleGlobalTypes { + export namespace GraffleGlobal { export interface Schemas { default: { name: Data.Name @@ -16,9 +15,7 @@ declare global { Document: MethodsDocument.BuilderMethodsDocumentFn Root: MethodsRoot.BuilderMethodsRootFn } - customScalars: { - Date: Scalar.Date - } + customScalars: {} defaultSchemaUrl: null } diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts index a018bde50..872cc54b5 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts @@ -1,25 +1 @@ -import type { Schema } from '../../../../../../src/entrypoints/schema.js' -import * as CustomScalars from '../../../../customScalarCodecs.js' - export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' -export * from '../../../../customScalarCodecs.js' -export { Date } from '../../../../customScalarCodecs.js' - -// -// -// -// -// CUSTOM SCALAR TYPE -// DATE -// -------------------------------------------------------------------------------------------------- -// Date -// -------------------------------------------------------------------------------------------------- -// -// - -export type Date = typeof CustomScalars.Date -// Without this we get error: -// "Exported type alias 'DateDecoded' has or is using private name 'Date'." -type Date_ = typeof CustomScalars.Date -export type DateDecoded = Schema.Scalar.GetDecoded -export type DateEncoded = Schema.Scalar.GetEncoded diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.ts b/tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.ts index db510e87f..bdeec40c7 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.ts @@ -16,15 +16,17 @@ import * as $Scalar from './Scalar.js' // // -const Int = $Scalar.Int +const Boolean = $Scalar.Boolean -const String = $Scalar.String +const Date = $Scalar.Date + +const Float = $Scalar.Float const ID = $Scalar.ID -const Boolean = $Scalar.Boolean +const Int = $Scalar.Int -const Float = $Scalar.Float +const String = $Scalar.String // // @@ -42,7 +44,7 @@ const Float = $Scalar.Float // // -const Date = $Scalar.Date +// None of your GraphQLScalarTypeCustoms have custom scalars. // // @@ -88,14 +90,9 @@ const Case: $Utilities.SchemaDrivenDataMap.Enum = { const InputObject: $Utilities.SchemaDrivenDataMap.InputObject = { n: 'InputObject', - fcs: ['date', 'dateRequired'], f: { - date: { - nt: Date, - }, - dateRequired: { - nt: Date, - }, + date: {}, + dateRequired: {}, id: {}, idRequired: {}, }, @@ -103,34 +100,23 @@ const InputObject: $Utilities.SchemaDrivenDataMap.InputObject = { const InputObjectCircular: $Utilities.SchemaDrivenDataMap.InputObject = { n: 'InputObjectCircular', - fcs: ['circular', 'date'], f: { - circular: { - // nt: InputObjectCircular, <-- Assigned later to avoid potential circular dependency. - }, - date: { - nt: Date, - }, + circular: {}, + date: {}, }, } const InputObjectNested: $Utilities.SchemaDrivenDataMap.InputObject = { n: 'InputObjectNested', - fcs: ['InputObject'], f: { - InputObject: { - // nt: InputObject, <-- Assigned later to avoid potential circular dependency. - }, + InputObject: {}, }, } const InputObjectNestedNonNull: $Utilities.SchemaDrivenDataMap.InputObject = { n: 'InputObjectNestedNonNull', - fcs: ['InputObject'], f: { - InputObject: { - // nt: InputObject, <-- Assigned later to avoid potential circular dependency. - }, + InputObject: {}, }, } @@ -158,22 +144,17 @@ const Bar: $Utilities.SchemaDrivenDataMap.OutputObject = { const DateObject1: $Utilities.SchemaDrivenDataMap.OutputObject = { f: { - date1: { - nt: Date, - }, + date1: {}, }, } const DateObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { f: { - date2: { - nt: Date, - }, + date2: {}, }, } const ErrorOne: $Utilities.SchemaDrivenDataMap.OutputObject = { - e: 1, f: { infoId: {}, message: {}, @@ -181,7 +162,6 @@ const ErrorOne: $Utilities.SchemaDrivenDataMap.OutputObject = { } const ErrorTwo: $Utilities.SchemaDrivenDataMap.OutputObject = { - e: 1, f: { infoInt: {}, message: {}, @@ -264,9 +244,7 @@ const lowerCaseObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { // const DateInterface1: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - ...DateObject1.f, - }, + f: {}, } const Error: $Utilities.SchemaDrivenDataMap.OutputObject = { @@ -294,10 +272,7 @@ const Interface: $Utilities.SchemaDrivenDataMap.OutputObject = { // const DateUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - ...DateObject1.f, - ...DateObject2.f, - }, + f: {}, } const FooBarUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { @@ -362,9 +337,7 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { }, }, }, - date: { - nt: Date, - }, + date: {}, dateArg: { a: { date: { @@ -372,7 +345,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [0], }, }, - nt: Date, }, dateArgInputObject: { a: { @@ -381,7 +353,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [0], }, }, - nt: Date, }, dateArgList: { a: { @@ -390,7 +361,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [0, [1]], }, }, - nt: Date, }, dateArgNonNull: { a: { @@ -399,7 +369,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [1], }, }, - nt: Date, }, dateArgNonNullList: { a: { @@ -408,7 +377,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [1, [0]], }, }, - nt: Date, }, dateArgNonNullListNonNull: { a: { @@ -417,23 +385,14 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [1, [1]], }, }, - nt: Date, }, dateInterface1: { // nt: DateInterface1, <-- Assigned later to avoid potential circular dependency. }, - dateList: { - nt: Date, - }, - dateListList: { - nt: Date, - }, - dateListNonNull: { - nt: Date, - }, - dateNonNull: { - nt: Date, - }, + dateList: {}, + dateListList: {}, + dateListNonNull: {}, + dateNonNull: {}, dateObject1: { // nt: DateObject1, <-- Assigned later to avoid potential circular dependency. }, @@ -519,7 +478,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [1], }, }, - r: 1, // nt: Result, <-- Assigned later to avoid potential circular dependency. }, resultNonNull: { @@ -529,7 +487,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [0], }, }, - r: 1, // nt: Result, <-- Assigned later to avoid potential circular dependency. }, string: {}, @@ -646,9 +603,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { // // -InputObjectCircular.f!['circular']!.nt = InputObjectCircular -InputObjectNested.f!['InputObject']!.nt = InputObject -InputObjectNestedNonNull.f!['InputObject']!.nt = InputObject ObjectNested.f['object']!.nt = Object1 ObjectUnion.f['fooBarUnion']!.nt = FooBarUnion Query.f['dateInterface1']!.nt = DateInterface1 @@ -695,12 +649,12 @@ const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { }, directives: {}, types: { - Int, - String, - ID, Boolean, - Float, Date, + Float, + ID, + Int, + String, ABCEnum, Case, InputObject, diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/SchemaIndex.ts b/tests/_/schemas/kitchen-sink/graffle/modules/SchemaIndex.ts index 4cc4f6e4d..07026e1de 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/SchemaIndex.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/SchemaIndex.ts @@ -66,22 +66,4 @@ export interface Index { Interface: Schema.Interface.Interface } customScalars: Utilities.SchemaIndexBase['customScalars'] - error: { - objects: { - ErrorOne: Schema.Object.ErrorOne - ErrorTwo: Schema.Object.ErrorTwo - } - objectsTypename: { - ErrorOne: { __typename: 'ErrorOne' } - ErrorTwo: { __typename: 'ErrorTwo' } - } - rootResultFields: { - Subscription: {} - Mutation: {} - Query: { - result: 'result' - resultNonNull: 'resultNonNull' - } - } - } } diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.ts b/tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.ts index 4632a1147..c8b8c60ab 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.ts @@ -1,6 +1,5 @@ import type { Select as $Select } from '../../../../../../src/entrypoints/schema.js' import type * as $Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type * as $Scalar from './Scalar.js' // // @@ -439,7 +438,7 @@ export namespace Query { export type date = $Select.Indicator.NoArgsIndicator export type dateArg$SelectionSetArguments = { - date?: $Scalar.DateDecoded | undefined | null + date?: undefined | undefined | null } export type dateArg$SelectionSet = $Utilities.Simplify< $Select.Bases.Base & { @@ -485,7 +484,7 @@ export namespace Query { export type dateArgInputObject = $Select.Indicator.Indicator | dateArgInputObject$SelectionSet export type dateArgList$SelectionSetArguments = { - date?: Array<$Scalar.DateDecoded | undefined | null> | undefined | null + date?: Array | undefined | null } export type dateArgList$SelectionSet = $Utilities.Simplify< $Select.Bases.Base & { @@ -507,7 +506,7 @@ export namespace Query { export type dateArgList = $Select.Indicator.Indicator | dateArgList$SelectionSet export type dateArgNonNull$SelectionSetArguments = { - date: $Scalar.DateDecoded + date: undefined } export interface dateArgNonNull extends $Select.Bases.Base { /** @@ -518,7 +517,7 @@ export namespace Query { } export type dateArgNonNullList$SelectionSetArguments = { - date: Array<$Scalar.DateDecoded | undefined | null> + date: Array } export interface dateArgNonNullList extends $Select.Bases.Base { /** @@ -529,7 +528,7 @@ export namespace Query { } export type dateArgNonNullListNonNull$SelectionSetArguments = { - date: Array<$Scalar.DateDecoded | undefined | null> + date: Array } export interface dateArgNonNullListNonNull extends $Select.Bases.Base { /** @@ -924,15 +923,15 @@ export type Case = 'ErrorOne' | 'ErrorTwo' | 'Object1' // export interface InputObject { - date?: $Scalar.DateDecoded | undefined | null - dateRequired: $Scalar.DateDecoded + date?: undefined | undefined | null + dateRequired: undefined id?: string | undefined | null idRequired: string } export interface InputObjectCircular { circular?: _RefDefs._InputObjectCircular | undefined | null - date?: $Scalar.DateDecoded | undefined | null + date?: undefined | undefined | null } export interface InputObjectNested { diff --git a/tests/_/schemas/kitchen-sink/schema.graphql b/tests/_/schemas/kitchen-sink/graffle/schema.graphql similarity index 100% rename from tests/_/schemas/kitchen-sink/schema.graphql rename to tests/_/schemas/kitchen-sink/graffle/schema.graphql diff --git a/tests/_/schemas/mutation-only/graffle/_.ts b/tests/_/schemas/mutation-only/graffle/_.ts index d5cdf0031..d27e9e3d3 100644 --- a/tests/_/schemas/mutation-only/graffle/_.ts +++ b/tests/_/schemas/mutation-only/graffle/_.ts @@ -5,5 +5,6 @@ import './modules/Global.js' export { create } from './modules/Client.js' +export { schemaDrivenDataMap } from './modules/SchemaDrivenDataMap.js' export { Select } from './modules/Select.js' export * as SelectionSets from './modules/SelectionSets.js' diff --git a/tests/_/schemas/mutation-only/graffle/modules/Client.ts b/tests/_/schemas/mutation-only/graffle/modules/Client.ts index cbf44a758..5a25cf4ed 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/Client.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/Client.ts @@ -1,5 +1,6 @@ import { createPrefilled } from '../../../../../../src/entrypoints/client.js' import { defaultSchemaUrl } from './Data.js' +import { Name } from './Data.js' import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' -export const create = createPrefilled(`MutationOnly`, schemaDrivenDataMap, defaultSchemaUrl) +export const create = createPrefilled(Name, schemaDrivenDataMap, defaultSchemaUrl) diff --git a/tests/_/schemas/mutation-only/graffle/modules/Global.ts b/tests/_/schemas/mutation-only/graffle/modules/Global.ts index 28dca40ca..b054d04af 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/Global.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/Global.ts @@ -5,7 +5,7 @@ import type * as MethodsSelect from './MethodsSelect.js' import type { Index } from './SchemaIndex.js' declare global { - export namespace GraffleGlobalTypes { + export namespace GraffleGlobal { export interface Schemas { MutationOnly: { name: Data.Name diff --git a/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts b/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts index d504fd23d..872cc54b5 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts @@ -1,3 +1 @@ export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' -export * from '../../../../customScalarCodecs.js' -export {} from '../../../../customScalarCodecs.js' diff --git a/tests/_/schemas/mutation-only/graffle/modules/SchemaDrivenDataMap.ts b/tests/_/schemas/mutation-only/graffle/modules/SchemaDrivenDataMap.ts index 39fabd26d..fc088cbca 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/SchemaDrivenDataMap.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/SchemaDrivenDataMap.ts @@ -16,9 +16,13 @@ import * as $Scalar from './Scalar.js' // // +const Boolean = $Scalar.Boolean + +const Float = $Scalar.Float + const ID = $Scalar.ID -const Boolean = $Scalar.Boolean +const Int = $Scalar.Int const String = $Scalar.String @@ -194,8 +198,10 @@ const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { }, directives: {}, types: { - ID, Boolean, + Float, + ID, + Int, String, Mutation, }, diff --git a/tests/_/schemas/mutation-only/graffle/modules/SchemaIndex.ts b/tests/_/schemas/mutation-only/graffle/modules/SchemaIndex.ts index 2726c2719..4f613d852 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/SchemaIndex.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/SchemaIndex.ts @@ -20,14 +20,4 @@ export interface Index { unions: {} interfaces: {} customScalars: Utilities.SchemaIndexBase['customScalars'] - error: { - objects: {} - objectsTypename: {} - rootResultFields: { - Query: {} - - Subscription: {} - Mutation: {} - } - } } diff --git a/tests/_/schemas/mutation-only/schema.graphql b/tests/_/schemas/mutation-only/graffle/schema.graphql similarity index 100% rename from tests/_/schemas/mutation-only/schema.graphql rename to tests/_/schemas/mutation-only/graffle/schema.graphql diff --git a/tests/_/schemas/pokemon/graffle/_.ts b/tests/_/schemas/pokemon/graffle/_.ts index d5cdf0031..d27e9e3d3 100644 --- a/tests/_/schemas/pokemon/graffle/_.ts +++ b/tests/_/schemas/pokemon/graffle/_.ts @@ -5,5 +5,6 @@ import './modules/Global.js' export { create } from './modules/Client.js' +export { schemaDrivenDataMap } from './modules/SchemaDrivenDataMap.js' export { Select } from './modules/Select.js' export * as SelectionSets from './modules/SelectionSets.js' diff --git a/tests/_/schemas/pokemon/graffle/modules/Client.ts b/tests/_/schemas/pokemon/graffle/modules/Client.ts index 28a57b572..5a25cf4ed 100644 --- a/tests/_/schemas/pokemon/graffle/modules/Client.ts +++ b/tests/_/schemas/pokemon/graffle/modules/Client.ts @@ -1,5 +1,6 @@ import { createPrefilled } from '../../../../../../src/entrypoints/client.js' import { defaultSchemaUrl } from './Data.js' +import { Name } from './Data.js' import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' -export const create = createPrefilled(`Pokemon`, schemaDrivenDataMap, defaultSchemaUrl) +export const create = createPrefilled(Name, schemaDrivenDataMap, defaultSchemaUrl) diff --git a/tests/_/schemas/pokemon/graffle/modules/Global.ts b/tests/_/schemas/pokemon/graffle/modules/Global.ts index 3c1c0986e..6658c0d0a 100644 --- a/tests/_/schemas/pokemon/graffle/modules/Global.ts +++ b/tests/_/schemas/pokemon/graffle/modules/Global.ts @@ -5,7 +5,7 @@ import type * as MethodsSelect from './MethodsSelect.js' import type { Index } from './SchemaIndex.js' declare global { - export namespace GraffleGlobalTypes { + export namespace GraffleGlobal { export interface Schemas { Pokemon: { name: Data.Name diff --git a/tests/_/schemas/pokemon/graffle/modules/Scalar.ts b/tests/_/schemas/pokemon/graffle/modules/Scalar.ts index d504fd23d..872cc54b5 100644 --- a/tests/_/schemas/pokemon/graffle/modules/Scalar.ts +++ b/tests/_/schemas/pokemon/graffle/modules/Scalar.ts @@ -1,3 +1 @@ export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' -export * from '../../../../customScalarCodecs.js' -export {} from '../../../../customScalarCodecs.js' diff --git a/tests/_/schemas/pokemon/graffle/modules/SchemaDrivenDataMap.ts b/tests/_/schemas/pokemon/graffle/modules/SchemaDrivenDataMap.ts index 07177dd10..f64ea0fb7 100644 --- a/tests/_/schemas/pokemon/graffle/modules/SchemaDrivenDataMap.ts +++ b/tests/_/schemas/pokemon/graffle/modules/SchemaDrivenDataMap.ts @@ -16,15 +16,15 @@ import * as $Scalar from './Scalar.js' // // +const Boolean = $Scalar.Boolean + const Float = $Scalar.Float const ID = $Scalar.ID -const String = $Scalar.String - const Int = $Scalar.Int -const Boolean = $Scalar.Boolean +const String = $Scalar.String // // @@ -430,11 +430,11 @@ const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { }, directives: {}, types: { + Boolean, Float, ID, - String, Int, - Boolean, + String, BattleWildResult, PokemonType, TrainerClass, diff --git a/tests/_/schemas/pokemon/graffle/modules/SchemaIndex.ts b/tests/_/schemas/pokemon/graffle/modules/SchemaIndex.ts index 2fdca79c6..f92620e85 100644 --- a/tests/_/schemas/pokemon/graffle/modules/SchemaIndex.ts +++ b/tests/_/schemas/pokemon/graffle/modules/SchemaIndex.ts @@ -47,13 +47,4 @@ export interface Index { Being: Schema.Interface.Being } customScalars: Utilities.SchemaIndexBase['customScalars'] - error: { - objects: {} - objectsTypename: {} - rootResultFields: { - Subscription: {} - Mutation: {} - Query: {} - } - } } diff --git a/tests/_/schemas/pokemon/schema.graphql b/tests/_/schemas/pokemon/graffle/schema.graphql similarity index 100% rename from tests/_/schemas/pokemon/schema.graphql rename to tests/_/schemas/pokemon/graffle/schema.graphql diff --git a/tests/_/schemas/query-only/graffle/_.ts b/tests/_/schemas/query-only/graffle/_.ts index d5cdf0031..d27e9e3d3 100644 --- a/tests/_/schemas/query-only/graffle/_.ts +++ b/tests/_/schemas/query-only/graffle/_.ts @@ -5,5 +5,6 @@ import './modules/Global.js' export { create } from './modules/Client.js' +export { schemaDrivenDataMap } from './modules/SchemaDrivenDataMap.js' export { Select } from './modules/Select.js' export * as SelectionSets from './modules/SelectionSets.js' diff --git a/tests/_/schemas/query-only/graffle/modules/Client.ts b/tests/_/schemas/query-only/graffle/modules/Client.ts index a8861e0fc..5a25cf4ed 100644 --- a/tests/_/schemas/query-only/graffle/modules/Client.ts +++ b/tests/_/schemas/query-only/graffle/modules/Client.ts @@ -1,5 +1,6 @@ import { createPrefilled } from '../../../../../../src/entrypoints/client.js' import { defaultSchemaUrl } from './Data.js' +import { Name } from './Data.js' import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' -export const create = createPrefilled(`QueryOnly`, schemaDrivenDataMap, defaultSchemaUrl) +export const create = createPrefilled(Name, schemaDrivenDataMap, defaultSchemaUrl) diff --git a/tests/_/schemas/query-only/graffle/modules/Global.ts b/tests/_/schemas/query-only/graffle/modules/Global.ts index 7f3b01c8e..909da5e9c 100644 --- a/tests/_/schemas/query-only/graffle/modules/Global.ts +++ b/tests/_/schemas/query-only/graffle/modules/Global.ts @@ -5,7 +5,7 @@ import type * as MethodsSelect from './MethodsSelect.js' import type { Index } from './SchemaIndex.js' declare global { - export namespace GraffleGlobalTypes { + export namespace GraffleGlobal { export interface Schemas { QueryOnly: { name: Data.Name diff --git a/tests/_/schemas/query-only/graffle/modules/Scalar.ts b/tests/_/schemas/query-only/graffle/modules/Scalar.ts index d504fd23d..872cc54b5 100644 --- a/tests/_/schemas/query-only/graffle/modules/Scalar.ts +++ b/tests/_/schemas/query-only/graffle/modules/Scalar.ts @@ -1,3 +1 @@ export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' -export * from '../../../../customScalarCodecs.js' -export {} from '../../../../customScalarCodecs.js' diff --git a/tests/_/schemas/query-only/graffle/modules/SchemaDrivenDataMap.ts b/tests/_/schemas/query-only/graffle/modules/SchemaDrivenDataMap.ts index 3561596d6..c3810c9a0 100644 --- a/tests/_/schemas/query-only/graffle/modules/SchemaDrivenDataMap.ts +++ b/tests/_/schemas/query-only/graffle/modules/SchemaDrivenDataMap.ts @@ -16,9 +16,13 @@ import * as $Scalar from './Scalar.js' // // +const Boolean = $Scalar.Boolean + +const Float = $Scalar.Float + const ID = $Scalar.ID -const Boolean = $Scalar.Boolean +const Int = $Scalar.Int const String = $Scalar.String @@ -194,8 +198,10 @@ const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { }, directives: {}, types: { - ID, Boolean, + Float, + ID, + Int, String, Query, }, diff --git a/tests/_/schemas/query-only/graffle/modules/SchemaIndex.ts b/tests/_/schemas/query-only/graffle/modules/SchemaIndex.ts index e59534f64..623acca69 100644 --- a/tests/_/schemas/query-only/graffle/modules/SchemaIndex.ts +++ b/tests/_/schemas/query-only/graffle/modules/SchemaIndex.ts @@ -20,13 +20,4 @@ export interface Index { unions: {} interfaces: {} customScalars: Utilities.SchemaIndexBase['customScalars'] - error: { - objects: {} - objectsTypename: {} - rootResultFields: { - Mutation: {} - Subscription: {} - Query: {} - } - } } diff --git a/tests/_/schemas/query-only/schema.graphql b/tests/_/schemas/query-only/graffle/schema.graphql similarity index 100% rename from tests/_/schemas/query-only/schema.graphql rename to tests/_/schemas/query-only/graffle/schema.graphql diff --git a/website/graffle/modules/Global.ts b/website/graffle/modules/Global.ts index cc54347cb..dda7d345c 100644 --- a/website/graffle/modules/Global.ts +++ b/website/graffle/modules/Global.ts @@ -5,7 +5,7 @@ import type * as MethodsSelect from './MethodsSelect.js' import type { Index } from './SchemaIndex.js' declare global { - export namespace GraffleGlobalTypes { + export namespace GraffleGlobal { export interface Schemas { default: { name: Data.Name diff --git a/website/pokemon/modules/Global.ts b/website/pokemon/modules/Global.ts index 3c1c0986e..6658c0d0a 100644 --- a/website/pokemon/modules/Global.ts +++ b/website/pokemon/modules/Global.ts @@ -5,7 +5,7 @@ import type * as MethodsSelect from './MethodsSelect.js' import type { Index } from './SchemaIndex.js' declare global { - export namespace GraffleGlobalTypes { + export namespace GraffleGlobal { export interface Schemas { Pokemon: { name: Data.Name From 56c95603dbeef2be6df27cbbaa5b8ce5efa2df8e Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Fri, 18 Oct 2024 08:36:13 -0400 Subject: [PATCH 2/8] lint --- src/cli/generate.ts | 1 - src/extensions/SchemaErrors/generator.ts | 4 +-- .../tests/fixture/graffle.config.ts | 4 ++- src/layers/4_generator/config/config.ts | 10 ++++++- src/layers/4_generator/config/input.ts | 26 ++++++++++++++++++- src/layers/4_generator/generators/Scalar.ts | 8 +++--- 6 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/cli/generate.ts b/src/cli/generate.ts index 60eb4b58e..f5cc581fc 100755 --- a/src/cli/generate.ts +++ b/src/cli/generate.ts @@ -88,7 +88,6 @@ if (!schema) { } const currentWorkingDirectory = configModule.path ? Path.dirname(configModule.path) : process.cwd() -console.log(currentWorkingDirectory) // --- Merge Inputs --- diff --git a/src/extensions/SchemaErrors/generator.ts b/src/extensions/SchemaErrors/generator.ts index fe11eaf8a..ad9b29c5b 100644 --- a/src/extensions/SchemaErrors/generator.ts +++ b/src/extensions/SchemaErrors/generator.ts @@ -37,8 +37,6 @@ interface Input { isErrorType?: (value: Grafaid.Schema.ObjectType) => boolean } -const defaultErrorTypeNamePattern = /^Error.+/ - interface Config { isErrorType: (value: Grafaid.Schema.ObjectType) => boolean } @@ -47,6 +45,8 @@ const defaults: Config = { isErrorType: (_ => Boolean(_.name.match(defaultErrorTypeNamePattern))), } +const defaultErrorTypeNamePattern = /^Error.+/ + export const SchemaErrors = (input?: Input) => { const config = ConfigManager.mergeDefaults(defaults, input ?? {}) diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts b/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts index 68d281299..f6bbe8b53 100644 --- a/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts +++ b/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts @@ -6,7 +6,9 @@ export default Generator .create({ name: `GraffleSchemaErrors`, schema, - outputDirPath: `./graffle`, + lint: { + missingCustomScalarCodec: false, + }, libraryPaths: { client: `../../../../entrypoints/client.ts`, schema: `../../../../entrypoints/schema.ts`, diff --git a/src/layers/4_generator/config/config.ts b/src/layers/4_generator/config/config.ts index eb1e62a2b..cbe95a513 100644 --- a/src/layers/4_generator/config/config.ts +++ b/src/layers/4_generator/config/config.ts @@ -14,10 +14,11 @@ import { import type { Extension } from '../extension/types.js' import { defaultLibraryPaths } from './defaults.js' import { defaultName } from './defaults.js' -import type { Input, InputLibraryPaths } from './input.js' +import type { Input, InputLibraryPaths, InputLint } from './input.js' export interface Config { name: string + lint: Required schema: ConfigSchema runtimeFeatures: { customScalars: boolean @@ -122,6 +123,12 @@ export const createConfig = async (input: Input): Promise => { : undefined, } + // --- Lint --- + + const lint: Config['lint'] = { + missingCustomScalarCodec: input.lint?.missingCustomScalarCodec ?? true, + } + // --- Output SDL --- // dprint-ignore @@ -136,6 +143,7 @@ export const createConfig = async (input: Input): Promise => { return { extensions: input.extensions ?? [], + lint, formatter, runtimeFeatures: { customScalars: true, // todo do not assume true diff --git a/src/layers/4_generator/config/input.ts b/src/layers/4_generator/config/input.ts index db34599b2..6b48d9ddb 100644 --- a/src/layers/4_generator/config/input.ts +++ b/src/layers/4_generator/config/input.ts @@ -1,12 +1,36 @@ import type { Grafaid } from '../../../lib/grafaid/__.js' import type { Extension } from '../extension/types.js' +export interface InputLint { + /** + * Should a warning be raised if the GraphQL schema has a custom scalar defined for which your project has no corresponding custom scalar codec? + * + * @defaultValue `true` + */ + missingCustomScalarCodec?: boolean +} + export interface Input { + /** + * The name of the client. This will affect: + * + * 1. The field name the generated client is referenced under in the global registry. + * 2. The exported namespace name. + * 3. Possible use by extensions. For example the Opentelemetry extension augments span attributes with this value. + * + * By default the globally registered name is "default" and the exported namespace name is "Graffle". + * + * Tip: Typically you would only set this if you had multiple Graffle clients (for different GraphQL schemas) in your project. + */ name?: string + /** + * Control various checks that Graffle performs. For example you could disable the warning about missing custom scalar codecs. + */ + lint?: InputLint /** * The directory path which paths will be considered relative to. * - * By default, uses the process current working directory. + * By default, is the process current working directory. */ currentWorkingDirectory?: string /** diff --git a/src/layers/4_generator/generators/Scalar.ts b/src/layers/4_generator/generators/Scalar.ts index 589bf15b9..be268e4df 100644 --- a/src/layers/4_generator/generators/Scalar.ts +++ b/src/layers/4_generator/generators/Scalar.ts @@ -41,9 +41,11 @@ export const ModuleGeneratorScalar = createModuleGenerator( if (isNeedCustomScalarDefaults) { // code(`import * as ${identifiers.StandardScalar} from '${config.paths.imports.grafflePackage.scalars}'`) code() - console.log( - `WARNING: Custom scalars detected in the schema, but you have not created a custom scalars module to import implementations from.`, - ) + if (config.lint.missingCustomScalarCodec) { + console.log( + `WARNING: Custom scalars detected in the schema, but you have not created a custom scalars module to import implementations from.`, + ) + } code(`export * from '${config.paths.imports.grafflePackage.scalars}'`) code(`export {`) code( From 11940cfb017f5a4830acdc894f8a22512cd025de Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Fri, 18 Oct 2024 10:41:59 -0400 Subject: [PATCH 3/8] regen --- graffle/_.ts | 9 - graffle/__.ts | 1 - graffle/modules/Client.ts | 5 - graffle/modules/Data.ts | 4 - graffle/modules/Global.ts | 24 - graffle/modules/MethodsDocument.ts | 18 - graffle/modules/MethodsRoot.ts | 585 ----- graffle/modules/MethodsSelect.ts | 199 -- graffle/modules/Scalar.ts | 1 - graffle/modules/SchemaBuildtime.ts | 359 --- graffle/modules/SchemaDrivenDataMap.ts | 689 ------ graffle/modules/SchemaIndex.ts | 69 - graffle/modules/Select.ts | 149 -- graffle/modules/SelectionSets.ts | 2102 ----------------- package.json | 1 + src/entrypoints/utilities-for-generated.ts | 1 + src/extensions/SchemaErrors/SchemaErrors.ts | 5 +- src/extensions/SchemaErrors/generator.ts | 24 - src/extensions/SchemaErrors/global.ts | 33 + .../tests/fixture/graffle/modules/Scalar.ts | 19 +- .../tests/fixture/graffle/modules/Schema.ts | 8 +- .../fixture/graffle/modules/SchemaIndex.ts | 69 - .../fixture/graffle/modules/SelectionSets.ts | 16 +- src/layers/3_InferResult/__.test-d.ts | 2 +- src/layers/4_generator/config/config.ts | 11 +- src/layers/4_generator/config/input.ts | 6 +- src/layers/4_generator/generators/Scalar.ts | 30 +- src/layers/4_generator/generators/Schema.ts | 131 +- src/layers/4_generator/globalRegistry.ts | 18 +- src/layers/6_client/extension/extension.ts | 4 +- src/lib/config-manager/ConfigManager.ts | 4 +- src/lib/grafaid/schema/schema.ts | 4 +- tests/_/helpers.ts | 6 +- tests/_/schemas/generate.ts | 4 +- .../kitchen-sink}/customScalarCodecs.ts | 2 +- .../kitchen-sink/graffle/modules/Global.ts | 8 +- .../graffle/modules/MethodsDocument.ts | 2 +- .../graffle/modules/MethodsRoot.ts | 2 +- .../kitchen-sink/graffle/modules/Scalar.ts | 25 + .../modules/{SchemaIndex.ts => Schema.ts} | 3 +- .../graffle/modules/SchemaDrivenDataMap.ts | 126 +- .../kitchen-sink/graffle/modules/Select.ts | 2 +- .../graffle/modules/SelectionSets.ts | 17 +- .../mutation-only/graffle/modules/Global.ts | 3 +- .../graffle/modules/MethodsDocument.ts | 2 +- .../graffle/modules/MethodsRoot.ts | 2 +- .../mutation-only/graffle/modules/Scalar.ts | 2 + .../modules/{SchemaIndex.ts => Schema.ts} | 3 +- .../modules/SchemaCustomScalarIndex.ts | 0 .../graffle/modules/SchemaDrivenDataMap.ts | 2 +- .../mutation-only/graffle/modules/Select.ts | 2 +- .../schemas/pokemon/graffle/modules/Global.ts | 2 +- .../graffle/modules/MethodsDocument.ts | 2 +- .../pokemon/graffle/modules/MethodsRoot.ts | 2 +- .../schemas/pokemon/graffle/modules/Scalar.ts | 2 + .../modules/{SchemaIndex.ts => Schema.ts} | 3 +- .../graffle/modules/SchemaDrivenDataMap.ts | 48 +- .../schemas/pokemon/graffle/modules/Select.ts | 2 +- .../query-only/graffle/modules/Global.ts | 3 +- .../graffle/modules/MethodsDocument.ts | 2 +- .../query-only/graffle/modules/MethodsRoot.ts | 2 +- .../query-only/graffle/modules/Scalar.ts | 2 + .../modules/{SchemaIndex.ts => Schema.ts} | 3 +- .../modules/SchemaCustomScalarIndex.ts | 0 .../graffle/modules/SchemaDrivenDataMap.ts | 2 +- .../query-only/graffle/modules/Select.ts | 2 +- tsconfig.build.json | 2 +- website/graffle/_.ts | 1 + website/graffle/modules/Client.ts | 3 +- website/graffle/modules/Data.ts | 2 +- website/graffle/modules/Global.ts | 8 +- website/graffle/modules/MethodsDocument.ts | 2 +- website/graffle/modules/MethodsRoot.ts | 2 +- website/graffle/modules/Scalar.ts | 2 + .../modules/{SchemaIndex.ts => Schema.ts} | 12 +- .../graffle/modules/SchemaDrivenDataMap.ts | 38 +- website/graffle/modules/Select.ts | 2 +- website/package.json | 2 +- website/pokemon/_.ts | 1 + website/pokemon/modules/Client.ts | 3 +- website/pokemon/modules/Global.ts | 2 +- website/pokemon/modules/MethodsDocument.ts | 2 +- website/pokemon/modules/MethodsRoot.ts | 2 +- website/pokemon/modules/Scalar.ts | 2 + .../modules/{SchemaIndex.ts => Schema.ts} | 12 +- .../modules/SchemaCustomScalarIndex.ts | 0 .../pokemon/modules/SchemaDrivenDataMap.ts | 48 +- website/pokemon/modules/Select.ts | 2 +- 88 files changed, 473 insertions(+), 4567 deletions(-) delete mode 100644 graffle/_.ts delete mode 100644 graffle/__.ts delete mode 100644 graffle/modules/Client.ts delete mode 100644 graffle/modules/Data.ts delete mode 100644 graffle/modules/Global.ts delete mode 100644 graffle/modules/MethodsDocument.ts delete mode 100644 graffle/modules/MethodsRoot.ts delete mode 100644 graffle/modules/MethodsSelect.ts delete mode 100644 graffle/modules/Scalar.ts delete mode 100644 graffle/modules/SchemaBuildtime.ts delete mode 100644 graffle/modules/SchemaDrivenDataMap.ts delete mode 100644 graffle/modules/SchemaIndex.ts delete mode 100644 graffle/modules/Select.ts delete mode 100644 graffle/modules/SelectionSets.ts create mode 100644 src/extensions/SchemaErrors/global.ts delete mode 100644 src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaIndex.ts rename tests/_/{ => schemas/kitchen-sink}/customScalarCodecs.ts (73%) rename tests/_/schemas/kitchen-sink/graffle/modules/{SchemaIndex.ts => Schema.ts} (95%) rename tests/_/schemas/mutation-only/graffle/modules/{SchemaIndex.ts => Schema.ts} (83%) delete mode 100644 tests/_/schemas/mutation-only/graffle/modules/SchemaCustomScalarIndex.ts rename tests/_/schemas/pokemon/graffle/modules/{SchemaIndex.ts => Schema.ts} (93%) rename tests/_/schemas/query-only/graffle/modules/{SchemaIndex.ts => Schema.ts} (83%) delete mode 100644 tests/_/schemas/query-only/graffle/modules/SchemaCustomScalarIndex.ts rename website/graffle/modules/{SchemaIndex.ts => Schema.ts} (84%) rename website/pokemon/modules/{SchemaIndex.ts => Schema.ts} (90%) delete mode 100644 website/pokemon/modules/SchemaCustomScalarIndex.ts diff --git a/graffle/_.ts b/graffle/_.ts deleted file mode 100644 index d5cdf0031..000000000 --- a/graffle/_.ts +++ /dev/null @@ -1,9 +0,0 @@ -// We import the global module for good measure although it is not clear it is always needed. -// It at least helps with Twoslash wherein without this import here Twoslash will not include the global module. -// In real TypeScript projects it seems the global module is included automatically. But there could be certain tsconfig -// setups where this still indeed does help. -import './modules/Global.js' - -export { create } from './modules/Client.js' -export { Select } from './modules/Select.js' -export * as SelectionSets from './modules/SelectionSets.js' diff --git a/graffle/__.ts b/graffle/__.ts deleted file mode 100644 index 4fba9ada3..000000000 --- a/graffle/__.ts +++ /dev/null @@ -1 +0,0 @@ -export * as Graffle from './_.js' diff --git a/graffle/modules/Client.ts b/graffle/modules/Client.ts deleted file mode 100644 index f3787e620..000000000 --- a/graffle/modules/Client.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { createPrefilled } from 'graffle/client' -import { defaultSchemaUrl } from './Data.js' -import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' - -export const create = createPrefilled(`default`, schemaDrivenDataMap, defaultSchemaUrl) diff --git a/graffle/modules/Data.ts b/graffle/modules/Data.ts deleted file mode 100644 index ef2ad4cf6..000000000 --- a/graffle/modules/Data.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const Name = `default` -export type Name = 'default' - -export const defaultSchemaUrl = undefined diff --git a/graffle/modules/Global.ts b/graffle/modules/Global.ts deleted file mode 100644 index f7af69d03..000000000 --- a/graffle/modules/Global.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type * as Data from './Data.js' -import type * as MethodsDocument from './MethodsDocument.js' -import type * as MethodsRoot from './MethodsRoot.js' -import type * as MethodsSelect from './MethodsSelect.js' -import type { Index } from './SchemaIndex.js' - -declare global { - export namespace GraffleGlobal { - export interface Schemas { - default: { - name: Data.Name - index: Index - interfaces: { - MethodsSelect: MethodsSelect.$MethodsSelect - Document: MethodsDocument.BuilderMethodsDocumentFn - Root: MethodsRoot.BuilderMethodsRootFn - } - customScalars: {} - - defaultSchemaUrl: null - } - } - } -} diff --git a/graffle/modules/MethodsDocument.ts b/graffle/modules/MethodsDocument.ts deleted file mode 100644 index 9b6e948e3..000000000 --- a/graffle/modules/MethodsDocument.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type * as Utilities from 'graffle/utilities-for-generated' -import type { Index } from './SchemaIndex.js' -import type * as SelectionSets from './SelectionSets.js' - -export interface Document<$Config extends Utilities.Config> { - <$Document>(document: Utilities.ExactNonEmpty<$Document, SelectionSets.$Document>): Utilities.DocumentRunner< - $Config, - Index, - // @ts-expect-error We use Exact instead of constraint on this function. TypeScript does not see that as - // Satisfying the constraint on the DocumentRunner type. - $Document - > -} - -export interface BuilderMethodsDocumentFn extends Utilities.TypeFunction.Fn { - // @ts-expect-error parameter is Untyped. - return: Document -} diff --git a/graffle/modules/MethodsRoot.ts b/graffle/modules/MethodsRoot.ts deleted file mode 100644 index 161ed0d5f..000000000 --- a/graffle/modules/MethodsRoot.ts +++ /dev/null @@ -1,585 +0,0 @@ -import type { InferResult } from 'graffle/schema' -import type * as Utils from 'graffle/utilities-for-generated' -import { type Simplify } from 'type-fest' -import type { Index } from './SchemaIndex.js' -import type * as SelectionSet from './SelectionSets.js' - -export interface MutationMethods<$Config extends Utils.Config> { - // todo Use a static type here? - $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Mutation>) => Promise< - Simplify< - Utils.HandleOutput< - $Config, - InferResult.Mutation<$SelectionSet, Index> - > - > - > - // todo Use a static type here? - __typename: () => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - { __typename: 'Mutation' }, - '__typename' - > - > - > - id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.id>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Mutation<{ id: $SelectionSet }, Index>, - 'id' - > - > - > - idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.idNonNull>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Mutation<{ idNonNull: $SelectionSet }, Index>, - 'idNonNull' - > - > - > -} - -export interface QueryMethods<$Config extends Utils.Config> { - // todo Use a static type here? - $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query>) => Promise< - Simplify< - Utils.HandleOutput< - $Config, - InferResult.Query<$SelectionSet, Index> - > - > - > - // todo Use a static type here? - __typename: () => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - { __typename: 'Query' }, - '__typename' - > - > - > - InputObjectNested: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNested>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ InputObjectNested: $SelectionSet }, Index>, - 'InputObjectNested' - > - > - > - InputObjectNestedNonNull: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNestedNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ InputObjectNestedNonNull: $SelectionSet }, Index>, - 'InputObjectNestedNonNull' - > - > - > - /** - * Query enum field documentation. - */ - abcEnum: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.abcEnum>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ abcEnum: $SelectionSet }, Index>, - 'abcEnum' - > - > - > - argInputObjectCircular: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.argInputObjectCircular>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ argInputObjectCircular: $SelectionSet }, Index>, - 'argInputObjectCircular' - > - > - > - date: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.date>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ date: $SelectionSet }, Index>, - 'date' - > - > - > - dateArg: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArg>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateArg: $SelectionSet }, Index>, - 'dateArg' - > - > - > - dateArgInputObject: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgInputObject>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateArgInputObject: $SelectionSet }, Index>, - 'dateArgInputObject' - > - > - > - dateArgList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgList>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateArgList: $SelectionSet }, Index>, - 'dateArgList' - > - > - > - dateArgNonNull: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateArgNonNull: $SelectionSet }, Index>, - 'dateArgNonNull' - > - > - > - dateArgNonNullList: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullList>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateArgNonNullList: $SelectionSet }, Index>, - 'dateArgNonNullList' - > - > - > - dateArgNonNullListNonNull: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullListNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateArgNonNullListNonNull: $SelectionSet }, Index>, - 'dateArgNonNullListNonNull' - > - > - > - dateInterface1: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateInterface1>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateInterface1: $SelectionSet }, Index>, - 'dateInterface1' - > - > - > - dateList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateList>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateList: $SelectionSet }, Index>, - 'dateList' - > - > - > - dateListList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListList>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateListList: $SelectionSet }, Index>, - 'dateListList' - > - > - > - dateListNonNull: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateListNonNull: $SelectionSet }, Index>, - 'dateListNonNull' - > - > - > - dateNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateNonNull>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateNonNull: $SelectionSet }, Index>, - 'dateNonNull' - > - > - > - dateObject1: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateObject1>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateObject1: $SelectionSet }, Index>, - 'dateObject1' - > - > - > - dateUnion: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateUnion>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ dateUnion: $SelectionSet }, Index>, - 'dateUnion' - > - > - > - error: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.error>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ error: $SelectionSet }, Index>, - 'error' - > - > - > - id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.id>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ id: $SelectionSet }, Index>, - 'id' - > - > - > - idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.idNonNull>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ idNonNull: $SelectionSet }, Index>, - 'idNonNull' - > - > - > - interface: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$interface>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ interface: $SelectionSet }, Index>, - 'interface' - > - > - > - interfaceNonNull: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ interfaceNonNull: $SelectionSet }, Index>, - 'interfaceNonNull' - > - > - > - interfaceWithArgs: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceWithArgs>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ interfaceWithArgs: $SelectionSet }, Index>, - 'interfaceWithArgs' - > - > - > - listInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listInt>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ listInt: $SelectionSet }, Index>, - 'listInt' - > - > - > - listIntNonNull: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listIntNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ listIntNonNull: $SelectionSet }, Index>, - 'listIntNonNull' - > - > - > - listListInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListInt>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ listListInt: $SelectionSet }, Index>, - 'listListInt' - > - > - > - listListIntNonNull: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListIntNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ listListIntNonNull: $SelectionSet }, Index>, - 'listListIntNonNull' - > - > - > - lowerCaseUnion: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.lowerCaseUnion>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ lowerCaseUnion: $SelectionSet }, Index>, - 'lowerCaseUnion' - > - > - > - object: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$object>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ object: $SelectionSet }, Index>, - 'object' - > - > - > - objectList: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectList>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ objectList: $SelectionSet }, Index>, - 'objectList' - > - > - > - objectListNonNull: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectListNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ objectListNonNull: $SelectionSet }, Index>, - 'objectListNonNull' - > - > - > - objectNested: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNested>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ objectNested: $SelectionSet }, Index>, - 'objectNested' - > - > - > - objectNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNonNull>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ objectNonNull: $SelectionSet }, Index>, - 'objectNonNull' - > - > - > - objectWithArgs: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectWithArgs>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ objectWithArgs: $SelectionSet }, Index>, - 'objectWithArgs' - > - > - > - result: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.result>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ result: $SelectionSet }, Index>, - 'result' - > - > - > - resultNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.resultNonNull>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ resultNonNull: $SelectionSet }, Index>, - 'resultNonNull' - > - > - > - string: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.$string>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ string: $SelectionSet }, Index>, - 'string' - > - > - > - stringWithArgEnum: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgEnum>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ stringWithArgEnum: $SelectionSet }, Index>, - 'stringWithArgEnum' - > - > - > - stringWithArgInputObject: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObject>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ stringWithArgInputObject: $SelectionSet }, Index>, - 'stringWithArgInputObject' - > - > - > - stringWithArgInputObjectRequired: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObjectRequired>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ stringWithArgInputObjectRequired: $SelectionSet }, Index>, - 'stringWithArgInputObjectRequired' - > - > - > - /** - * The given arguments are reflected back as a JSON string. - */ - stringWithArgs: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgs>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ stringWithArgs: $SelectionSet }, Index>, - 'stringWithArgs' - > - > - > - stringWithListArg: <$SelectionSet>( - selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArg>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ stringWithListArg: $SelectionSet }, Index>, - 'stringWithListArg' - > - > - > - stringWithListArgRequired: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArgRequired>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ stringWithListArgRequired: $SelectionSet }, Index>, - 'stringWithListArgRequired' - > - > - > - stringWithRequiredArg: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithRequiredArg>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ stringWithRequiredArg: $SelectionSet }, Index>, - 'stringWithRequiredArg' - > - > - > - unionFooBar: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBar>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ unionFooBar: $SelectionSet }, Index>, - 'unionFooBar' - > - > - > - unionFooBarNonNull: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ unionFooBarNonNull: $SelectionSet }, Index>, - 'unionFooBarNonNull' - > - > - > - unionFooBarWithArgs: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarWithArgs>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ unionFooBarWithArgs: $SelectionSet }, Index>, - 'unionFooBarWithArgs' - > - > - > - unionObject: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObject>) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ unionObject: $SelectionSet }, Index>, - 'unionObject' - > - > - > - unionObjectNonNull: <$SelectionSet>( - selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObjectNonNull>, - ) => Promise< - Simplify< - Utils.HandleOutputGraffleRootField< - $Config, - InferResult.Query<{ unionObjectNonNull: $SelectionSet }, Index>, - 'unionObjectNonNull' - > - > - > -} - -export interface BuilderMethodsRoot<$Config extends Utils.Config> { - mutation: MutationMethods<$Config> - query: QueryMethods<$Config> -} - -export interface BuilderMethodsRootFn extends Utils.TypeFunction.Fn { - // @ts-expect-error parameter is Untyped. - return: BuilderMethodsRoot -} diff --git a/graffle/modules/MethodsSelect.ts b/graffle/modules/MethodsSelect.ts deleted file mode 100644 index 5dddcadb7..000000000 --- a/graffle/modules/MethodsSelect.ts +++ /dev/null @@ -1,199 +0,0 @@ -import type * as $Utilities from 'graffle/utilities-for-generated' -import type * as $SelectionSets from './SelectionSets.js' - -// -// -// -// -// -// -// ================================================================================================== -// Select Methods Interface -// ================================================================================================== -// -// -// -// -// -// - -export interface $MethodsSelect { - Mutation: Mutation - Query: Query - Bar: Bar - DateObject1: DateObject1 - DateObject2: DateObject2 - ErrorOne: ErrorOne - ErrorTwo: ErrorTwo - Foo: Foo - Object1: Object1 - Object1ImplementingInterface: Object1ImplementingInterface - Object2ImplementingInterface: Object2ImplementingInterface - ObjectNested: ObjectNested - ObjectUnion: ObjectUnion - lowerCaseObject: lowerCaseObject - lowerCaseObject2: lowerCaseObject2 - DateUnion: DateUnion - FooBarUnion: FooBarUnion - Result: Result - lowerCaseUnion: lowerCaseUnion - DateInterface1: DateInterface1 - Error: Error - Interface: Interface -} - -// -// -// -// -// -// -// ================================================================================================== -// Root -// ================================================================================================== -// -// -// -// -// -// - -export interface Mutation { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Mutation>): $SelectionSet -} - -export interface Query { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Query>): $SelectionSet -} - -// -// -// -// -// -// -// ================================================================================================== -// Object -// ================================================================================================== -// -// -// -// -// -// - -export interface Bar { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Bar>): $SelectionSet -} - -export interface DateObject1 { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateObject1>): $SelectionSet -} - -export interface DateObject2 { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateObject2>): $SelectionSet -} - -export interface ErrorOne { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ErrorOne>): $SelectionSet -} - -export interface ErrorTwo { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ErrorTwo>): $SelectionSet -} - -export interface Foo { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Foo>): $SelectionSet -} - -export interface Object1 { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Object1>): $SelectionSet -} - -export interface Object1ImplementingInterface { - <$SelectionSet>( - selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Object1ImplementingInterface>, - ): $SelectionSet -} - -export interface Object2ImplementingInterface { - <$SelectionSet>( - selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Object2ImplementingInterface>, - ): $SelectionSet -} - -export interface ObjectNested { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ObjectNested>): $SelectionSet -} - -export interface ObjectUnion { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.ObjectUnion>): $SelectionSet -} - -export interface lowerCaseObject { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.lowerCaseObject>): $SelectionSet -} - -export interface lowerCaseObject2 { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.lowerCaseObject2>): $SelectionSet -} - -// -// -// -// -// -// -// ================================================================================================== -// Union -// ================================================================================================== -// -// -// -// -// -// - -export interface DateUnion { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateUnion>): $SelectionSet -} - -export interface FooBarUnion { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.FooBarUnion>): $SelectionSet -} - -export interface Result { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Result>): $SelectionSet -} - -export interface lowerCaseUnion { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.lowerCaseUnion>): $SelectionSet -} - -// -// -// -// -// -// -// ================================================================================================== -// Interface -// ================================================================================================== -// -// -// -// -// -// - -export interface DateInterface1 { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.DateInterface1>): $SelectionSet -} - -export interface Error { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Error>): $SelectionSet -} - -export interface Interface { - <$SelectionSet>(selectionSet: $Utilities.Exact<$SelectionSet, $SelectionSets.Interface>): $SelectionSet -} diff --git a/graffle/modules/Scalar.ts b/graffle/modules/Scalar.ts deleted file mode 100644 index 5c8ae1f9f..000000000 --- a/graffle/modules/Scalar.ts +++ /dev/null @@ -1 +0,0 @@ -export * from 'graffle/schema/scalars' diff --git a/graffle/modules/SchemaBuildtime.ts b/graffle/modules/SchemaBuildtime.ts deleted file mode 100644 index 3702db8f6..000000000 --- a/graffle/modules/SchemaBuildtime.ts +++ /dev/null @@ -1,359 +0,0 @@ -import type * as $ from 'graffle/schema' -import type * as $Scalar from './Scalar.js' - -// ------------------------------------------------------------ // -// Root // -// ------------------------------------------------------------ // -export namespace Root { - export type Mutation = $.Output.ObjectMutation<{ - id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> - idNonNull: $.Field<'idNonNull', $Scalar.ID, null> - }> - - export type Query = $.Output.ObjectQuery<{ - InputObjectNested: $.Field< - 'InputObjectNested', - $.Output.Nullable<$Scalar.ID>, - $.Args<{ - input: $.Input.Field<$.Input.Nullable> - }, true> - > - InputObjectNestedNonNull: $.Field< - 'InputObjectNestedNonNull', - $.Output.Nullable<$Scalar.ID>, - $.Args<{ - input: $.Input.Field - }, false> - > - /** - * Query enum field documentation. - */ - abcEnum: $.Field<'abcEnum', $.Output.Nullable, null> - argInputObjectCircular: $.Field< - 'argInputObjectCircular', - $.Output.Nullable<$Scalar.String>, - $.Args<{ - input: $.Input.Field<$.Input.Nullable> - }, true> - > - date: $.Field<'date', $.Output.Nullable<$Scalar.Date>, null> - dateArg: $.Field< - 'dateArg', - $.Output.Nullable<$Scalar.Date>, - $.Args<{ - date: $.Input.Field<$.Input.Nullable<$Scalar.Date>> - }, true> - > - dateArgInputObject: $.Field< - 'dateArgInputObject', - $.Output.Nullable<$Scalar.Date>, - $.Args<{ - input: $.Input.Field<$.Input.Nullable> - }, true> - > - dateArgList: $.Field< - 'dateArgList', - $.Output.Nullable<$Scalar.Date>, - $.Args<{ - date: $.Input.Field<$.Input.Nullable<$.Input.List<$Scalar.Date>>> - }, true> - > - dateArgNonNull: $.Field< - 'dateArgNonNull', - $.Output.Nullable<$Scalar.Date>, - $.Args<{ - date: $.Input.Field<$Scalar.Date> - }, false> - > - dateArgNonNullList: $.Field< - 'dateArgNonNullList', - $.Output.Nullable<$Scalar.Date>, - $.Args<{ - date: $.Input.Field<$.Input.List<$.Input.Nullable<$Scalar.Date>>> - }, false> - > - dateArgNonNullListNonNull: $.Field< - 'dateArgNonNullListNonNull', - $.Output.Nullable<$Scalar.Date>, - $.Args<{ - date: $.Input.Field<$.Input.List<$Scalar.Date>> - }, false> - > - dateInterface1: $.Field<'dateInterface1', $.Output.Nullable, null> - dateList: $.Field<'dateList', $.Output.Nullable<$.Output.List<$Scalar.Date>>, null> - dateListList: $.Field<'dateListList', $.Output.Nullable<$.Output.List<$.Output.List<$Scalar.Date>>>, null> - dateListNonNull: $.Field<'dateListNonNull', $.Output.List<$Scalar.Date>, null> - dateNonNull: $.Field<'dateNonNull', $Scalar.Date, null> - dateObject1: $.Field<'dateObject1', $.Output.Nullable, null> - dateUnion: $.Field<'dateUnion', $.Output.Nullable, null> - error: $.Field< - 'error', - $.Output.Nullable<$Scalar.String>, - $.Args<{ - case: $.Input.Field<$.Input.Nullable<$Scalar.String>> - }, true> - > - id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> - idNonNull: $.Field<'idNonNull', $Scalar.ID, null> - interface: $.Field<'interface', $.Output.Nullable, null> - interfaceNonNull: $.Field<'interfaceNonNull', Interface.Interface, null> - interfaceWithArgs: $.Field< - 'interfaceWithArgs', - $.Output.Nullable, - $.Args<{ - id: $.Input.Field<$Scalar.ID> - }, false> - > - listInt: $.Field<'listInt', $.Output.Nullable<$.Output.List<$.Output.Nullable<$Scalar.Int>>>, null> - listIntNonNull: $.Field<'listIntNonNull', $.Output.List<$Scalar.Int>, null> - listListInt: $.Field< - 'listListInt', - $.Output.Nullable<$.Output.List<$.Output.Nullable<$.Output.List<$.Output.Nullable<$Scalar.Int>>>>>, - null - > - listListIntNonNull: $.Field<'listListIntNonNull', $.Output.List<$.Output.List<$Scalar.Int>>, null> - lowerCaseUnion: $.Field<'lowerCaseUnion', $.Output.Nullable, null> - object: $.Field<'object', $.Output.Nullable, null> - objectList: $.Field<'objectList', $.Output.Nullable<$.Output.List>, null> - objectListNonNull: $.Field<'objectListNonNull', $.Output.List, null> - objectNested: $.Field<'objectNested', $.Output.Nullable, null> - objectNonNull: $.Field<'objectNonNull', Object.Object1, null> - objectWithArgs: $.Field< - 'objectWithArgs', - $.Output.Nullable, - $.Args<{ - boolean: $.Input.Field<$.Input.Nullable<$Scalar.Boolean>> - float: $.Input.Field<$.Input.Nullable<$Scalar.Float>> - id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> - int: $.Input.Field<$.Input.Nullable<$Scalar.Int>> - string: $.Input.Field<$.Input.Nullable<$Scalar.String>> - }, true> - > - result: $.Field< - 'result', - $.Output.Nullable, - $.Args<{ - case: $.Input.Field - }, false> - > - resultNonNull: $.Field< - 'resultNonNull', - Union.Result, - $.Args<{ - case: $.Input.Field<$.Input.Nullable> - }, true> - > - string: $.Field<'string', $.Output.Nullable<$Scalar.String>, null> - stringWithArgEnum: $.Field< - 'stringWithArgEnum', - $.Output.Nullable<$Scalar.String>, - $.Args<{ - ABCEnum: $.Input.Field<$.Input.Nullable> - }, true> - > - stringWithArgInputObject: $.Field< - 'stringWithArgInputObject', - $.Output.Nullable<$Scalar.String>, - $.Args<{ - input: $.Input.Field<$.Input.Nullable> - }, true> - > - stringWithArgInputObjectRequired: $.Field< - 'stringWithArgInputObjectRequired', - $.Output.Nullable<$Scalar.String>, - $.Args<{ - input: $.Input.Field - }, false> - > - /** - * The given arguments are reflected back as a JSON string. - */ - stringWithArgs: $.Field< - 'stringWithArgs', - $.Output.Nullable<$Scalar.String>, - $.Args<{ - boolean: $.Input.Field<$.Input.Nullable<$Scalar.Boolean>> - float: $.Input.Field<$.Input.Nullable<$Scalar.Float>> - id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> - int: $.Input.Field<$.Input.Nullable<$Scalar.Int>> - string: $.Input.Field<$.Input.Nullable<$Scalar.String>> - }, true> - > - stringWithListArg: $.Field< - 'stringWithListArg', - $.Output.Nullable<$Scalar.String>, - $.Args<{ - ints: $.Input.Field<$.Input.Nullable<$.Input.List<$.Input.Nullable<$Scalar.Int>>>> - }, true> - > - stringWithListArgRequired: $.Field< - 'stringWithListArgRequired', - $.Output.Nullable<$Scalar.String>, - $.Args<{ - ints: $.Input.Field<$.Input.List<$Scalar.Int>> - }, false> - > - stringWithRequiredArg: $.Field< - 'stringWithRequiredArg', - $.Output.Nullable<$Scalar.String>, - $.Args<{ - string: $.Input.Field<$Scalar.String> - }, false> - > - unionFooBar: $.Field<'unionFooBar', $.Output.Nullable, null> - unionFooBarNonNull: $.Field<'unionFooBarNonNull', Union.FooBarUnion, null> - unionFooBarWithArgs: $.Field< - 'unionFooBarWithArgs', - $.Output.Nullable, - $.Args<{ - id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> - }, true> - > - unionObject: $.Field<'unionObject', $.Output.Nullable, null> - unionObjectNonNull: $.Field<'unionObjectNonNull', Object.ObjectUnion, null> - }> -} -// ------------------------------------------------------------ // -// Enum // -// ------------------------------------------------------------ // -export namespace Enum { - /** - * Enum documentation. - * - * Members - * "A" - (DEPRECATED: Enum value A is deprecated.) - * "B" - Enum B member documentation. - * "C" - (DEPRECATED: Enum value C is deprecated.) - */ - export type ABCEnum = $.Enum<'ABCEnum', ['A', 'B', 'C']> - - export type Case = $.Enum<'Case', ['ErrorOne', 'ErrorTwo', 'Object1']> -} -// ------------------------------------------------------------ // -// InputObject // -// ------------------------------------------------------------ // -export namespace InputObject { - export type InputObject = $.InputObject<'InputObject', { - date: $.Input.Field<$.Input.Nullable<$Scalar.Date>> - dateRequired: $.Input.Field<$Scalar.Date> - id: $.Input.Field<$.Input.Nullable<$Scalar.ID>> - idRequired: $.Input.Field<$Scalar.ID> - }, true> - - export type InputObjectCircular = $.InputObject<'InputObjectCircular', { - circular: $.Input.Field<$.Input.Nullable> - date: $.Input.Field<$.Input.Nullable<$Scalar.Date>> - }, true> - - export type InputObjectNested = $.InputObject<'InputObjectNested', { - InputObject: $.Input.Field<$.Input.Nullable> - }, true> - - export type InputObjectNestedNonNull = $.InputObject<'InputObjectNestedNonNull', { - InputObject: $.Input.Field - }, false> -} -// ------------------------------------------------------------ // -// Interface // -// ------------------------------------------------------------ // -export namespace Interface { - export type DateInterface1 = $.Interface<'DateInterface1', { - date1: $.Field<'date1', $.Output.Nullable<$Scalar.Date>, null> - }, [Object.DateObject1]> - - export type Error = $.Interface<'Error', { - message: $.Field<'message', $Scalar.String, null> - }, [Object.ErrorOne, Object.ErrorTwo]> - - export type Interface = $.Interface<'Interface', { - id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> - }, [Object.Object1ImplementingInterface, Object.Object2ImplementingInterface]> -} -// ------------------------------------------------------------ // -// Object // -// ------------------------------------------------------------ // -export namespace Object { - export type Bar = $.Object$2<'Bar', { - int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> - }> - - export type DateObject1 = $.Object$2<'DateObject1', { - date1: $.Field<'date1', $.Output.Nullable<$Scalar.Date>, null> - }> - - export type DateObject2 = $.Object$2<'DateObject2', { - date2: $.Field<'date2', $.Output.Nullable<$Scalar.Date>, null> - }> - - export type ErrorOne = $.Object$2<'ErrorOne', { - infoId: $.Field<'infoId', $.Output.Nullable<$Scalar.ID>, null> - message: $.Field<'message', $Scalar.String, null> - }> - - export type ErrorTwo = $.Object$2<'ErrorTwo', { - infoInt: $.Field<'infoInt', $.Output.Nullable<$Scalar.Int>, null> - message: $.Field<'message', $Scalar.String, null> - }> - - /** - * Object documentation. - */ - export type Foo = $.Object$2<'Foo', { - /** - * Field documentation. - * - * @deprecated Field a is deprecated. - */ - id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> - }> - - export type Object1 = $.Object$2<'Object1', { - boolean: $.Field<'boolean', $.Output.Nullable<$Scalar.Boolean>, null> - float: $.Field<'float', $.Output.Nullable<$Scalar.Float>, null> - id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> - int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> - string: $.Field<'string', $.Output.Nullable<$Scalar.String>, null> - }> - - export type Object1ImplementingInterface = $.Object$2<'Object1ImplementingInterface', { - id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> - int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> - }> - - export type Object2ImplementingInterface = $.Object$2<'Object2ImplementingInterface', { - boolean: $.Field<'boolean', $.Output.Nullable<$Scalar.Boolean>, null> - id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> - }> - - export type ObjectNested = $.Object$2<'ObjectNested', { - id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> - object: $.Field<'object', $.Output.Nullable, null> - }> - - export type ObjectUnion = $.Object$2<'ObjectUnion', { - fooBarUnion: $.Field<'fooBarUnion', $.Output.Nullable, null> - }> - - export type lowerCaseObject = $.Object$2<'lowerCaseObject', { - id: $.Field<'id', $.Output.Nullable<$Scalar.ID>, null> - }> - - export type lowerCaseObject2 = $.Object$2<'lowerCaseObject2', { - int: $.Field<'int', $.Output.Nullable<$Scalar.Int>, null> - }> -} -// ------------------------------------------------------------ // -// Union // -// ------------------------------------------------------------ // -export namespace Union { - export type DateUnion = $.Union<'DateUnion', [Object.DateObject1, Object.DateObject2]> - - /** - * Union documentation. - */ - export type FooBarUnion = $.Union<'FooBarUnion', [Object.Bar, Object.Foo]> - - export type Result = $.Union<'Result', [Object.ErrorOne, Object.ErrorTwo, Object.Object1]> - - export type lowerCaseUnion = $.Union<'lowerCaseUnion', [Object.lowerCaseObject, Object.lowerCaseObject2]> -} diff --git a/graffle/modules/SchemaDrivenDataMap.ts b/graffle/modules/SchemaDrivenDataMap.ts deleted file mode 100644 index 144d43e33..000000000 --- a/graffle/modules/SchemaDrivenDataMap.ts +++ /dev/null @@ -1,689 +0,0 @@ -import type * as $Utilities from 'graffle/utilities-for-generated' -import * as $Scalar from './Scalar.js' -// -// -// -// -// -// -// ================================================================================================== -// GraphQLScalarType -// ================================================================================================== -// -// -// -// -// -// - -const Boolean = $Scalar.Boolean - -const Date = $Scalar.Date - -const Float = $Scalar.Float - -const ID = $Scalar.ID - -const Int = $Scalar.Int - -const String = $Scalar.String - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLScalarTypeCustom -// ================================================================================================== -// -// -// -// -// -// - -// None of your GraphQLScalarTypeCustoms have custom scalars. - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLEnumType -// ================================================================================================== -// -// -// -// -// -// - -const ABCEnum: $Utilities.SchemaDrivenDataMap.Enum = { - k: 'enum', - n: 'ABCEnum', -} - -const Case: $Utilities.SchemaDrivenDataMap.Enum = { - k: 'enum', - n: 'Case', -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLInputObjectType -// ================================================================================================== -// -// -// -// -// -// - -const InputObject: $Utilities.SchemaDrivenDataMap.InputObject = { - n: 'InputObject', - f: { - date: {}, - dateRequired: {}, - id: {}, - idRequired: {}, - }, -} - -const InputObjectCircular: $Utilities.SchemaDrivenDataMap.InputObject = { - n: 'InputObjectCircular', - f: { - circular: {}, - date: {}, - }, -} - -const InputObjectNested: $Utilities.SchemaDrivenDataMap.InputObject = { - n: 'InputObjectNested', - f: { - InputObject: {}, - }, -} - -const InputObjectNestedNonNull: $Utilities.SchemaDrivenDataMap.InputObject = { - n: 'InputObjectNestedNonNull', - f: { - InputObject: {}, - }, -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLObjectType -// ================================================================================================== -// -// -// -// -// -// - -const Bar: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - int: {}, - }, -} - -const DateObject1: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - date1: {}, - }, -} - -const DateObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - date2: {}, - }, -} - -const ErrorOne: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - infoId: {}, - message: {}, - }, -} - -const ErrorTwo: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - infoInt: {}, - message: {}, - }, -} - -const Foo: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - id: {}, - }, -} - -const Object1: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - boolean: {}, - float: {}, - id: {}, - int: {}, - string: {}, - }, -} - -const Object1ImplementingInterface: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - id: {}, - int: {}, - }, -} - -const Object2ImplementingInterface: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - boolean: {}, - id: {}, - }, -} - -const ObjectNested: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - id: {}, - object: { - // nt: Object1, <-- Assigned later to avoid potential circular dependency. - }, - }, -} - -const ObjectUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - fooBarUnion: { - // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. - }, - }, -} - -const lowerCaseObject: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - id: {}, - }, -} - -const lowerCaseObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - int: {}, - }, -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLInterfaceType -// ================================================================================================== -// -// -// -// -// -// - -const DateInterface1: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: {}, -} - -const Error: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: {}, -} - -const Interface: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: {}, -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLUnionType -// ================================================================================================== -// -// -// -// -// -// - -const DateUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: {}, -} - -const FooBarUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: {}, -} - -const Result: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: {}, -} - -const lowerCaseUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: {}, -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLRootType -// ================================================================================================== -// -// -// -// -// -// - -const Mutation: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - id: {}, - idNonNull: {}, - }, -} - -const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: { - InputObjectNested: { - a: { - input: { - nt: InputObjectNested, - it: [0], - }, - }, - }, - InputObjectNestedNonNull: { - a: { - input: { - nt: InputObjectNestedNonNull, - it: [1], - }, - }, - }, - abcEnum: {}, - argInputObjectCircular: { - a: { - input: { - nt: InputObjectCircular, - it: [0], - }, - }, - }, - date: {}, - dateArg: { - a: { - date: { - nt: Date, - it: [0], - }, - }, - }, - dateArgInputObject: { - a: { - input: { - nt: InputObject, - it: [0], - }, - }, - }, - dateArgList: { - a: { - date: { - nt: Date, - it: [0, [1]], - }, - }, - }, - dateArgNonNull: { - a: { - date: { - nt: Date, - it: [1], - }, - }, - }, - dateArgNonNullList: { - a: { - date: { - nt: Date, - it: [1, [0]], - }, - }, - }, - dateArgNonNullListNonNull: { - a: { - date: { - nt: Date, - it: [1, [1]], - }, - }, - }, - dateInterface1: { - // nt: DateInterface1, <-- Assigned later to avoid potential circular dependency. - }, - dateList: {}, - dateListList: {}, - dateListNonNull: {}, - dateNonNull: {}, - dateObject1: { - // nt: DateObject1, <-- Assigned later to avoid potential circular dependency. - }, - dateUnion: { - // nt: DateUnion, <-- Assigned later to avoid potential circular dependency. - }, - error: { - a: { - case: { - nt: String, - it: [0], - }, - }, - }, - id: {}, - idNonNull: {}, - interface: { - // nt: Interface, <-- Assigned later to avoid potential circular dependency. - }, - interfaceNonNull: { - // nt: Interface, <-- Assigned later to avoid potential circular dependency. - }, - interfaceWithArgs: { - a: { - id: { - nt: ID, - it: [1], - }, - }, - // nt: Interface, <-- Assigned later to avoid potential circular dependency. - }, - listInt: {}, - listIntNonNull: {}, - listListInt: {}, - listListIntNonNull: {}, - lowerCaseUnion: { - // nt: lowerCaseUnion, <-- Assigned later to avoid potential circular dependency. - }, - object: { - // nt: Object1, <-- Assigned later to avoid potential circular dependency. - }, - objectList: { - // nt: Object1, <-- Assigned later to avoid potential circular dependency. - }, - objectListNonNull: { - // nt: Object1, <-- Assigned later to avoid potential circular dependency. - }, - objectNested: { - // nt: ObjectNested, <-- Assigned later to avoid potential circular dependency. - }, - objectNonNull: { - // nt: Object1, <-- Assigned later to avoid potential circular dependency. - }, - objectWithArgs: { - a: { - boolean: { - nt: Boolean, - it: [0], - }, - float: { - nt: Float, - it: [0], - }, - id: { - nt: ID, - it: [0], - }, - int: { - nt: Int, - it: [0], - }, - string: { - nt: String, - it: [0], - }, - }, - // nt: Object1, <-- Assigned later to avoid potential circular dependency. - }, - result: { - a: { - case: { - nt: Case, - it: [1], - }, - }, - // nt: Result, <-- Assigned later to avoid potential circular dependency. - }, - resultNonNull: { - a: { - case: { - nt: Case, - it: [0], - }, - }, - // nt: Result, <-- Assigned later to avoid potential circular dependency. - }, - string: {}, - stringWithArgEnum: { - a: { - ABCEnum: { - nt: ABCEnum, - it: [0], - }, - }, - }, - stringWithArgInputObject: { - a: { - input: { - nt: InputObject, - it: [0], - }, - }, - }, - stringWithArgInputObjectRequired: { - a: { - input: { - nt: InputObject, - it: [1], - }, - }, - }, - stringWithArgs: { - a: { - boolean: { - nt: Boolean, - it: [0], - }, - float: { - nt: Float, - it: [0], - }, - id: { - nt: ID, - it: [0], - }, - int: { - nt: Int, - it: [0], - }, - string: { - nt: String, - it: [0], - }, - }, - }, - stringWithListArg: { - a: { - ints: { - nt: Int, - it: [0, [0]], - }, - }, - }, - stringWithListArgRequired: { - a: { - ints: { - nt: Int, - it: [1, [1]], - }, - }, - }, - stringWithRequiredArg: { - a: { - string: { - nt: String, - it: [1], - }, - }, - }, - unionFooBar: { - // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. - }, - unionFooBarNonNull: { - // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. - }, - unionFooBarWithArgs: { - a: { - id: { - nt: ID, - it: [0], - }, - }, - // nt: FooBarUnion, <-- Assigned later to avoid potential circular dependency. - }, - unionObject: { - // nt: ObjectUnion, <-- Assigned later to avoid potential circular dependency. - }, - unionObjectNonNull: { - // nt: ObjectUnion, <-- Assigned later to avoid potential circular dependency. - }, - }, -} - -// -// -// -// -// -// -// ================================================================================================== -// Reference Assignments -// (avoids circular assignment issues) -// ================================================================================================== -// -// -// -// -// -// - -ObjectNested.f['object']!.nt = Object1 -ObjectUnion.f['fooBarUnion']!.nt = FooBarUnion -Query.f['dateInterface1']!.nt = DateInterface1 -Query.f['dateObject1']!.nt = DateObject1 -Query.f['dateUnion']!.nt = DateUnion -Query.f['interface']!.nt = Interface -Query.f['interfaceNonNull']!.nt = Interface -Query.f['interfaceWithArgs']!.nt = Interface -Query.f['lowerCaseUnion']!.nt = lowerCaseUnion -Query.f['object']!.nt = Object1 -Query.f['objectList']!.nt = Object1 -Query.f['objectListNonNull']!.nt = Object1 -Query.f['objectNested']!.nt = ObjectNested -Query.f['objectNonNull']!.nt = Object1 -Query.f['objectWithArgs']!.nt = Object1 -Query.f['result']!.nt = Result -Query.f['resultNonNull']!.nt = Result -Query.f['unionFooBar']!.nt = FooBarUnion -Query.f['unionFooBarNonNull']!.nt = FooBarUnion -Query.f['unionFooBarWithArgs']!.nt = FooBarUnion -Query.f['unionObject']!.nt = ObjectUnion -Query.f['unionObjectNonNull']!.nt = ObjectUnion - -// -// -// -// -// -// -// ================================================================================================== -// Index -// ================================================================================================== -// -// -// -// -// -// - -const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { - roots: { - Mutation, - Query, - }, - directives: {}, - types: { - Boolean, - Date, - Float, - ID, - Int, - String, - ABCEnum, - Case, - InputObject, - InputObjectCircular, - InputObjectNested, - InputObjectNestedNonNull, - Bar, - DateObject1, - DateObject2, - ErrorOne, - ErrorTwo, - Foo, - Object1, - Object1ImplementingInterface, - Object2ImplementingInterface, - ObjectNested, - ObjectUnion, - lowerCaseObject, - lowerCaseObject2, - DateInterface1, - Error, - Interface, - DateUnion, - FooBarUnion, - Result, - lowerCaseUnion, - Mutation, - Query, - }, -} - -export { $schemaDrivenDataMap as schemaDrivenDataMap } diff --git a/graffle/modules/SchemaIndex.ts b/graffle/modules/SchemaIndex.ts deleted file mode 100644 index fff1a1977..000000000 --- a/graffle/modules/SchemaIndex.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* eslint-disable */ -import type * as Utilities from 'graffle/utilities-for-generated' -import type * as Data from './Data.js' -import type * as MethodsRoot from './MethodsRoot.js' -import type * as Schema from './SchemaBuildtime.js' - -export interface Index { - name: Data.Name - RootTypesPresent: ['Mutation', 'Query'] - RootUnion: Schema.Root.Mutation | Schema.Root.Query - Root: { - Query: Schema.Root.Query - Mutation: Schema.Root.Mutation - Subscription: null - } - allTypes: { - Mutation: Schema.Root.Mutation - Query: Schema.Root.Query - ABCEnum: Schema.Enum.ABCEnum - Case: Schema.Enum.Case - Bar: Schema.Object.Bar - DateObject1: Schema.Object.DateObject1 - DateObject2: Schema.Object.DateObject2 - ErrorOne: Schema.Object.ErrorOne - ErrorTwo: Schema.Object.ErrorTwo - Foo: Schema.Object.Foo - Object1: Schema.Object.Object1 - Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface - Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface - ObjectNested: Schema.Object.ObjectNested - ObjectUnion: Schema.Object.ObjectUnion - lowerCaseObject: Schema.Object.lowerCaseObject - lowerCaseObject2: Schema.Object.lowerCaseObject2 - DateUnion: Schema.Union.DateUnion - FooBarUnion: Schema.Union.FooBarUnion - Result: Schema.Union.Result - lowerCaseUnion: Schema.Union.lowerCaseUnion - DateInterface1: Schema.Interface.DateInterface1 - Error: Schema.Interface.Error - Interface: Schema.Interface.Interface - } - objects: { - Bar: Schema.Object.Bar - DateObject1: Schema.Object.DateObject1 - DateObject2: Schema.Object.DateObject2 - ErrorOne: Schema.Object.ErrorOne - ErrorTwo: Schema.Object.ErrorTwo - Foo: Schema.Object.Foo - Object1: Schema.Object.Object1 - Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface - Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface - ObjectNested: Schema.Object.ObjectNested - ObjectUnion: Schema.Object.ObjectUnion - lowerCaseObject: Schema.Object.lowerCaseObject - lowerCaseObject2: Schema.Object.lowerCaseObject2 - } - unions: { - DateUnion: Schema.Union.DateUnion - FooBarUnion: Schema.Union.FooBarUnion - Result: Schema.Union.Result - lowerCaseUnion: Schema.Union.lowerCaseUnion - } - interfaces: { - DateInterface1: Schema.Interface.DateInterface1 - Error: Schema.Interface.Error - Interface: Schema.Interface.Interface - } - customScalars: Utilities.SchemaIndexBase['customScalars'] -} diff --git a/graffle/modules/Select.ts b/graffle/modules/Select.ts deleted file mode 100644 index 9b9820d4e..000000000 --- a/graffle/modules/Select.ts +++ /dev/null @@ -1,149 +0,0 @@ -import type { InferResult } from 'graffle/schema' -import * as Data from './Data.js' -import type { Index } from './SchemaIndex.js' -import type * as SelectionSets from './SelectionSets.js' - -// -// -// -// -// -// -// ================================================================================================== -// Runtime -// ================================================================================================== -// -// -// -// -// -// -import { createSelect } from 'graffle/client' -export const Select = createSelect(Data.Name) - -// -// -// -// -// -// -// ================================================================================================== -// Buildtime -// ================================================================================================== -// -// -// -// -// -// - -export namespace Select { - // Root Types - // ---------- - export type Mutation<$SelectionSet extends SelectionSets.Mutation> = InferResult.Root< - $SelectionSet, - Index, - 'Mutation' - > - export type Query<$SelectionSet extends SelectionSets.Query> = InferResult.Root<$SelectionSet, Index, 'Query'> - // Object Types - // ------------ - export type Bar<$SelectionSet extends SelectionSets.Bar> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['Bar'] - > - export type DateObject1<$SelectionSet extends SelectionSets.DateObject1> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['DateObject1'] - > - export type DateObject2<$SelectionSet extends SelectionSets.DateObject2> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['DateObject2'] - > - export type ErrorOne<$SelectionSet extends SelectionSets.ErrorOne> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['ErrorOne'] - > - export type ErrorTwo<$SelectionSet extends SelectionSets.ErrorTwo> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['ErrorTwo'] - > - export type Foo<$SelectionSet extends SelectionSets.Foo> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['Foo'] - > - export type Object1<$SelectionSet extends SelectionSets.Object1> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['Object1'] - > - export type Object1ImplementingInterface<$SelectionSet extends SelectionSets.Object1ImplementingInterface> = - InferResult.Object<$SelectionSet, Index, Index['allTypes']['Object1ImplementingInterface']> - export type Object2ImplementingInterface<$SelectionSet extends SelectionSets.Object2ImplementingInterface> = - InferResult.Object<$SelectionSet, Index, Index['allTypes']['Object2ImplementingInterface']> - export type ObjectNested<$SelectionSet extends SelectionSets.ObjectNested> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['ObjectNested'] - > - export type ObjectUnion<$SelectionSet extends SelectionSets.ObjectUnion> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['ObjectUnion'] - > - export type lowerCaseObject<$SelectionSet extends SelectionSets.lowerCaseObject> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['lowerCaseObject'] - > - export type lowerCaseObject2<$SelectionSet extends SelectionSets.lowerCaseObject2> = InferResult.Object< - $SelectionSet, - Index, - Index['allTypes']['lowerCaseObject2'] - > - // Union Types - // ----------- - export type DateUnion<$SelectionSet extends SelectionSets.DateUnion> = InferResult.Union< - $SelectionSet, - Index, - Index['allTypes']['DateUnion'] - > - export type FooBarUnion<$SelectionSet extends SelectionSets.FooBarUnion> = InferResult.Union< - $SelectionSet, - Index, - Index['allTypes']['FooBarUnion'] - > - export type Result<$SelectionSet extends SelectionSets.Result> = InferResult.Union< - $SelectionSet, - Index, - Index['allTypes']['Result'] - > - export type lowerCaseUnion<$SelectionSet extends SelectionSets.lowerCaseUnion> = InferResult.Union< - $SelectionSet, - Index, - Index['allTypes']['lowerCaseUnion'] - > - // Interface Types - // --------------- - export type DateInterface1<$SelectionSet extends SelectionSets.DateInterface1> = InferResult.Interface< - $SelectionSet, - Index, - Index['allTypes']['DateInterface1'] - > - export type Error<$SelectionSet extends SelectionSets.Error> = InferResult.Interface< - $SelectionSet, - Index, - Index['allTypes']['Error'] - > - export type Interface<$SelectionSet extends SelectionSets.Interface> = InferResult.Interface< - $SelectionSet, - Index, - Index['allTypes']['Interface'] - > -} diff --git a/graffle/modules/SelectionSets.ts b/graffle/modules/SelectionSets.ts deleted file mode 100644 index 68d1599a5..000000000 --- a/graffle/modules/SelectionSets.ts +++ /dev/null @@ -1,2102 +0,0 @@ -import type { Select as $Select } from 'graffle/schema' -import type * as $Utilities from 'graffle/utilities-for-generated' - -// -// -// -// -// -// -// ================================================================================================== -// Document -// ================================================================================================== -// -// -// -// -// -// - -// Prefix with $ because this is not a schema type. A user could have a schema type named "Document" that this would conflict with. -export interface $Document { - query?: Record - mutation?: Record -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLObjectType Types -// ================================================================================================== -// -// -// -// -// -// - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// Mutation -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface Mutation { - /** - * Select the `id` field on the `Mutation` object. Its type is `ID` (a `Scalar`). - */ - id?: Mutation.id$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `idNonNull` field on the `Mutation` object. Its type is `ID` (a `Scalar`). - */ - idNonNull?: Mutation.idNonNull$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Mutation$FragmentInline | Mutation$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface Mutation$FragmentInline extends Mutation, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace Mutation { - /** - * This is the "expanded" version of the `id` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type id = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `idNonNull` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type idNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type idNonNull = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// Query -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface Query { - /** - * Select the `InputObjectNested` field on the `Query` object. Its type is `ID` (a `Scalar`). - */ - InputObjectNested?: Query.InputObjectNested$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `InputObjectNestedNonNull` field on the `Query` object. Its type is `ID` (a `Scalar`). - */ - InputObjectNestedNonNull?: - | Query.InputObjectNestedNonNull - | $Select.SelectAlias.SelectAlias - /** - * Select the `abcEnum` field on the `Query` object. Its type is Enum. - */ - abcEnum?: Query.abcEnum$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `argInputObjectCircular` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - argInputObjectCircular?: - | Query.argInputObjectCircular$Expanded - | $Select.SelectAlias.SelectAlias - /** - * Select the `date` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - date?: Query.date$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateArg` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateArg?: Query.dateArg$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateArgInputObject` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateArgInputObject?: Query.dateArgInputObject$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateArgList` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateArgList?: Query.dateArgList$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateArgNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateArgNonNull?: Query.dateArgNonNull | $Select.SelectAlias.SelectAlias - /** - * Select the `dateArgNonNullList` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateArgNonNullList?: Query.dateArgNonNullList | $Select.SelectAlias.SelectAlias - /** - * Select the `dateArgNonNullListNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateArgNonNullListNonNull?: - | Query.dateArgNonNullListNonNull - | $Select.SelectAlias.SelectAlias - /** - * Select the `dateInterface1` field on the `Query` object. Its type is Interface. - */ - dateInterface1?: Query.dateInterface1$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateList` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateList?: Query.dateList$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateListList` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateListList?: Query.dateListList$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateListNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateListNonNull?: Query.dateListNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateNonNull` field on the `Query` object. Its type is `Date` (a `Scalar`). - */ - dateNonNull?: Query.dateNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateObject1` field on the `Query` object. Its type is Object. - */ - dateObject1?: Query.dateObject1$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `dateUnion` field on the `Query` object. Its type is Union. - */ - dateUnion?: Query.dateUnion$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `error` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - error?: Query.error$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `id` field on the `Query` object. Its type is `ID` (a `Scalar`). - */ - id?: Query.id$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `idNonNull` field on the `Query` object. Its type is `ID` (a `Scalar`). - */ - idNonNull?: Query.idNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `interface` field on the `Query` object. Its type is Interface. - */ - interface?: Query.$interface$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `interfaceNonNull` field on the `Query` object. Its type is Interface. - */ - interfaceNonNull?: Query.interfaceNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `interfaceWithArgs` field on the `Query` object. Its type is Interface. - */ - interfaceWithArgs?: Query.interfaceWithArgs | $Select.SelectAlias.SelectAlias - /** - * Select the `listInt` field on the `Query` object. Its type is `Int` (a `Scalar`). - */ - listInt?: Query.listInt$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `listIntNonNull` field on the `Query` object. Its type is `Int` (a `Scalar`). - */ - listIntNonNull?: Query.listIntNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `listListInt` field on the `Query` object. Its type is `Int` (a `Scalar`). - */ - listListInt?: Query.listListInt$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `listListIntNonNull` field on the `Query` object. Its type is `Int` (a `Scalar`). - */ - listListIntNonNull?: Query.listListIntNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `lowerCaseUnion` field on the `Query` object. Its type is Union. - */ - lowerCaseUnion?: Query.lowerCaseUnion$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `object` field on the `Query` object. Its type is Object. - */ - object?: Query.$object$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `objectList` field on the `Query` object. Its type is Object. - */ - objectList?: Query.objectList$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `objectListNonNull` field on the `Query` object. Its type is Object. - */ - objectListNonNull?: Query.objectListNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `objectNested` field on the `Query` object. Its type is Object. - */ - objectNested?: Query.objectNested$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `objectNonNull` field on the `Query` object. Its type is Object. - */ - objectNonNull?: Query.objectNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `objectWithArgs` field on the `Query` object. Its type is Object. - */ - objectWithArgs?: Query.objectWithArgs$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `result` field on the `Query` object. Its type is Union. - */ - result?: Query.result | $Select.SelectAlias.SelectAlias - /** - * Select the `resultNonNull` field on the `Query` object. Its type is Union. - */ - resultNonNull?: Query.resultNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `string` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - string?: Query.$string$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `stringWithArgEnum` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - stringWithArgEnum?: Query.stringWithArgEnum$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `stringWithArgInputObject` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - stringWithArgInputObject?: - | Query.stringWithArgInputObject$Expanded - | $Select.SelectAlias.SelectAlias - /** - * Select the `stringWithArgInputObjectRequired` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - stringWithArgInputObjectRequired?: - | Query.stringWithArgInputObjectRequired - | $Select.SelectAlias.SelectAlias - /** - * Select the `stringWithArgs` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - stringWithArgs?: Query.stringWithArgs$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `stringWithListArg` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - stringWithListArg?: Query.stringWithListArg$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `stringWithListArgRequired` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - stringWithListArgRequired?: - | Query.stringWithListArgRequired - | $Select.SelectAlias.SelectAlias - /** - * Select the `stringWithRequiredArg` field on the `Query` object. Its type is `String` (a `Scalar`). - */ - stringWithRequiredArg?: Query.stringWithRequiredArg | $Select.SelectAlias.SelectAlias - /** - * Select the `unionFooBar` field on the `Query` object. Its type is Union. - */ - unionFooBar?: Query.unionFooBar$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `unionFooBarNonNull` field on the `Query` object. Its type is Union. - */ - unionFooBarNonNull?: Query.unionFooBarNonNull$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `unionFooBarWithArgs` field on the `Query` object. Its type is Union. - */ - unionFooBarWithArgs?: Query.unionFooBarWithArgs$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `unionObject` field on the `Query` object. Its type is Object. - */ - unionObject?: Query.unionObject$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `unionObjectNonNull` field on the `Query` object. Its type is Object. - */ - unionObjectNonNull?: Query.unionObjectNonNull$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Query$FragmentInline | Query$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface Query$FragmentInline extends Query, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace Query { - export type InputObjectNested$SelectionSetArguments = { - input?: _RefDefs._InputObjectNested | undefined | null - } - export type InputObjectNested$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `InputObjectNested` field. - * No arguments are required so you may omit this. - */ - $?: InputObjectNested$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `InputObjectNested` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type InputObjectNested$Expanded = $Utilities.UnionExpanded< - $Select.Indicator.Indicator | InputObjectNested$SelectionSet - > - - export type InputObjectNested = $Select.Indicator.Indicator | InputObjectNested$SelectionSet - - export type InputObjectNestedNonNull$SelectionSetArguments = { - input: _RefDefs._InputObjectNestedNonNull - } - export interface InputObjectNestedNonNull extends $Select.Bases.Base { - /** - * Arguments for `InputObjectNestedNonNull` field. - * All arguments are required so you must include this. - */ - $: InputObjectNestedNonNull$SelectionSetArguments - } - - /** - * This is the "expanded" version of the `abcEnum` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type abcEnum$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type abcEnum = $Select.Indicator.NoArgsIndicator - - export type argInputObjectCircular$SelectionSetArguments = { - input?: _RefDefs._InputObjectCircular | undefined | null - } - export type argInputObjectCircular$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `argInputObjectCircular` field. - * No arguments are required so you may omit this. - */ - $?: argInputObjectCircular$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `argInputObjectCircular` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type argInputObjectCircular$Expanded = $Utilities.UnionExpanded< - $Select.Indicator.Indicator | argInputObjectCircular$SelectionSet - > - - export type argInputObjectCircular = $Select.Indicator.Indicator | argInputObjectCircular$SelectionSet - - /** - * This is the "expanded" version of the `date` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type date$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type date = $Select.Indicator.NoArgsIndicator - - export type dateArg$SelectionSetArguments = { - date?: undefined | undefined | null - } - export type dateArg$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `dateArg` field. - * No arguments are required so you may omit this. - */ - $?: dateArg$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `dateArg` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type dateArg$Expanded = $Utilities.UnionExpanded<$Select.Indicator.Indicator | dateArg$SelectionSet> - - export type dateArg = $Select.Indicator.Indicator | dateArg$SelectionSet - - export type dateArgInputObject$SelectionSetArguments = { - input?: _RefDefs._InputObject | undefined | null - } - export type dateArgInputObject$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `dateArgInputObject` field. - * No arguments are required so you may omit this. - */ - $?: dateArgInputObject$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `dateArgInputObject` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type dateArgInputObject$Expanded = $Utilities.UnionExpanded< - $Select.Indicator.Indicator | dateArgInputObject$SelectionSet - > - - export type dateArgInputObject = $Select.Indicator.Indicator | dateArgInputObject$SelectionSet - - export type dateArgList$SelectionSetArguments = { - date?: Array | undefined | null - } - export type dateArgList$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `dateArgList` field. - * No arguments are required so you may omit this. - */ - $?: dateArgList$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `dateArgList` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type dateArgList$Expanded = $Utilities.UnionExpanded<$Select.Indicator.Indicator | dateArgList$SelectionSet> - - export type dateArgList = $Select.Indicator.Indicator | dateArgList$SelectionSet - - export type dateArgNonNull$SelectionSetArguments = { - date: undefined - } - export interface dateArgNonNull extends $Select.Bases.Base { - /** - * Arguments for `dateArgNonNull` field. - * All arguments are required so you must include this. - */ - $: dateArgNonNull$SelectionSetArguments - } - - export type dateArgNonNullList$SelectionSetArguments = { - date: Array - } - export interface dateArgNonNullList extends $Select.Bases.Base { - /** - * Arguments for `dateArgNonNullList` field. - * All arguments are required so you must include this. - */ - $: dateArgNonNullList$SelectionSetArguments - } - - export type dateArgNonNullListNonNull$SelectionSetArguments = { - date: Array - } - export interface dateArgNonNullListNonNull extends $Select.Bases.Base { - /** - * Arguments for `dateArgNonNullListNonNull` field. - * All arguments are required so you must include this. - */ - $: dateArgNonNullListNonNull$SelectionSetArguments - } - - export interface dateInterface1 extends _RefDefs._DateInterface1 {} - export type dateInterface1$Expanded = dateInterface1 - /** - * This is the "expanded" version of the `dateList` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type dateList$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type dateList = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `dateListList` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type dateListList$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type dateListList = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `dateListNonNull` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type dateListNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type dateListNonNull = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `dateNonNull` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type dateNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type dateNonNull = $Select.Indicator.NoArgsIndicator - - export interface dateObject1 extends _RefDefs._DateObject1 {} - export type dateObject1$Expanded = dateObject1 - export interface dateUnion extends _RefDefs._DateUnion {} - export type dateUnion$Expanded = dateUnion - export type error$SelectionSetArguments = { - case?: string | undefined | null - } - export type error$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `error` field. - * No arguments are required so you may omit this. - */ - $?: error$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `error` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type error$Expanded = $Utilities.UnionExpanded<$Select.Indicator.Indicator | error$SelectionSet> - - export type error = $Select.Indicator.Indicator | error$SelectionSet - - /** - * This is the "expanded" version of the `id` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type id = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `idNonNull` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type idNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type idNonNull = $Select.Indicator.NoArgsIndicator - - export interface $interface extends _RefDefs._Interface {} - export type $interface$Expanded = $interface - export interface interfaceNonNull extends _RefDefs._Interface {} - export type interfaceNonNull$Expanded = interfaceNonNull - export interface interfaceWithArgs extends _RefDefs._Interface { - /** - * Arguments for `interfaceWithArgs` field. - * All arguments are required so you must include this. - */ - $: { - id: string - } - } - export type interfaceWithArgs$Expanded = interfaceWithArgs - /** - * This is the "expanded" version of the `listInt` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type listInt$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type listInt = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `listIntNonNull` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type listIntNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type listIntNonNull = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `listListInt` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type listListInt$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type listListInt = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `listListIntNonNull` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type listListIntNonNull$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type listListIntNonNull = $Select.Indicator.NoArgsIndicator - - export interface lowerCaseUnion extends _RefDefs._lowerCaseUnion {} - export type lowerCaseUnion$Expanded = lowerCaseUnion - export interface $object extends _RefDefs._Object1 {} - export type $object$Expanded = $object - export interface objectList extends _RefDefs._Object1 {} - export type objectList$Expanded = objectList - export interface objectListNonNull extends _RefDefs._Object1 {} - export type objectListNonNull$Expanded = objectListNonNull - export interface objectNested extends _RefDefs._ObjectNested {} - export type objectNested$Expanded = objectNested - export interface objectNonNull extends _RefDefs._Object1 {} - export type objectNonNull$Expanded = objectNonNull - export interface objectWithArgs extends _RefDefs._Object1 { - /** - * Arguments for `objectWithArgs` field. - * No arguments are required so you may omit this. - */ - $?: { - boolean?: boolean | undefined | null - float?: number | undefined | null - id?: string | undefined | null - int?: number | undefined | null - string?: string | undefined | null - } - } - export type objectWithArgs$Expanded = objectWithArgs - export interface result extends _RefDefs._Result { - /** - * Arguments for `result` field. - * All arguments are required so you must include this. - */ - $: { - $case: _RefDefs._Case - } - } - export type result$Expanded = result - export interface resultNonNull extends _RefDefs._Result { - /** - * Arguments for `resultNonNull` field. - * No arguments are required so you may omit this. - */ - $?: { - $case?: _RefDefs._Case | undefined | null - } - } - export type resultNonNull$Expanded = resultNonNull - /** - * This is the "expanded" version of the `$string` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type $string$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type $string = $Select.Indicator.NoArgsIndicator - - export type stringWithArgEnum$SelectionSetArguments = { - $ABCEnum?: _RefDefs._ABCEnum | undefined | null - } - export type stringWithArgEnum$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `stringWithArgEnum` field. - * No arguments are required so you may omit this. - */ - $?: stringWithArgEnum$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `stringWithArgEnum` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type stringWithArgEnum$Expanded = $Utilities.UnionExpanded< - $Select.Indicator.Indicator | stringWithArgEnum$SelectionSet - > - - export type stringWithArgEnum = $Select.Indicator.Indicator | stringWithArgEnum$SelectionSet - - export type stringWithArgInputObject$SelectionSetArguments = { - input?: _RefDefs._InputObject | undefined | null - } - export type stringWithArgInputObject$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `stringWithArgInputObject` field. - * No arguments are required so you may omit this. - */ - $?: stringWithArgInputObject$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `stringWithArgInputObject` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type stringWithArgInputObject$Expanded = $Utilities.UnionExpanded< - $Select.Indicator.Indicator | stringWithArgInputObject$SelectionSet - > - - export type stringWithArgInputObject = $Select.Indicator.Indicator | stringWithArgInputObject$SelectionSet - - export type stringWithArgInputObjectRequired$SelectionSetArguments = { - input: _RefDefs._InputObject - } - export interface stringWithArgInputObjectRequired extends $Select.Bases.Base { - /** - * Arguments for `stringWithArgInputObjectRequired` field. - * All arguments are required so you must include this. - */ - $: stringWithArgInputObjectRequired$SelectionSetArguments - } - - export type stringWithArgs$SelectionSetArguments = { - boolean?: boolean | undefined | null - float?: number | undefined | null - id?: string | undefined | null - int?: number | undefined | null - string?: string | undefined | null - } - export type stringWithArgs$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `stringWithArgs` field. - * No arguments are required so you may omit this. - */ - $?: stringWithArgs$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `stringWithArgs` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type stringWithArgs$Expanded = $Utilities.UnionExpanded< - $Select.Indicator.Indicator | stringWithArgs$SelectionSet - > - - export type stringWithArgs = $Select.Indicator.Indicator | stringWithArgs$SelectionSet - - export type stringWithListArg$SelectionSetArguments = { - ints?: Array | undefined | null - } - export type stringWithListArg$SelectionSet = $Utilities.Simplify< - $Select.Bases.Base & { - /** - * Arguments for `stringWithListArg` field. - * No arguments are required so you may omit this. - */ - $?: stringWithListArg$SelectionSetArguments - } - > - - /** - * This is the "expanded" version of the `stringWithListArg` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type stringWithListArg$Expanded = $Utilities.UnionExpanded< - $Select.Indicator.Indicator | stringWithListArg$SelectionSet - > - - export type stringWithListArg = $Select.Indicator.Indicator | stringWithListArg$SelectionSet - - export type stringWithListArgRequired$SelectionSetArguments = { - ints: Array - } - export interface stringWithListArgRequired extends $Select.Bases.Base { - /** - * Arguments for `stringWithListArgRequired` field. - * All arguments are required so you must include this. - */ - $: stringWithListArgRequired$SelectionSetArguments - } - - export type stringWithRequiredArg$SelectionSetArguments = { - string: string - } - export interface stringWithRequiredArg extends $Select.Bases.Base { - /** - * Arguments for `stringWithRequiredArg` field. - * All arguments are required so you must include this. - */ - $: stringWithRequiredArg$SelectionSetArguments - } - - export interface unionFooBar extends _RefDefs._FooBarUnion {} - export type unionFooBar$Expanded = unionFooBar - export interface unionFooBarNonNull extends _RefDefs._FooBarUnion {} - export type unionFooBarNonNull$Expanded = unionFooBarNonNull - export interface unionFooBarWithArgs extends _RefDefs._FooBarUnion { - /** - * Arguments for `unionFooBarWithArgs` field. - * No arguments are required so you may omit this. - */ - $?: { - id?: string | undefined | null - } - } - export type unionFooBarWithArgs$Expanded = unionFooBarWithArgs - export interface unionObject extends _RefDefs._ObjectUnion {} - export type unionObject$Expanded = unionObject - export interface unionObjectNonNull extends _RefDefs._ObjectUnion {} - export type unionObjectNonNull$Expanded = unionObjectNonNull -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLEnumType Types -// ================================================================================================== -// -// -// -// -// -// - -/** - * Enum documentation. - * - * Members - * "A" - (DEPRECATED: Enum value A is deprecated.) - * "B" - Enum B member documentation. - * "C" - (DEPRECATED: Enum value C is deprecated.) - */ -export type ABCEnum = 'A' | 'B' | 'C' - -export type Case = 'ErrorOne' | 'ErrorTwo' | 'Object1' - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLInputObjectType Types -// ================================================================================================== -// -// -// -// -// -// - -export interface InputObject { - date?: undefined | undefined | null - dateRequired: undefined - id?: string | undefined | null - idRequired: string -} - -export interface InputObjectCircular { - circular?: _RefDefs._InputObjectCircular | undefined | null - date?: undefined | undefined | null -} - -export interface InputObjectNested { - InputObject?: _RefDefs._InputObject | undefined | null -} - -export interface InputObjectNestedNonNull { - InputObject: _RefDefs._InputObject -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLInterfaceType Types -// ================================================================================================== -// -// -// -// -// -// - -// -------------- -// Interface Type DateInterface1 -// -------------- - -export interface DateInterface1 extends $Select.Bases.ObjectLike { - date1?: DateInterface1.date1 - ___on_DateObject1?: DateObject1 - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: DateInterface1$FragmentInline | DateInterface1$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. Since this is a interface type and thus polymorphic, - * the name is one of the implementor type names, whichever is ultimately returned at runtime. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface DateInterface1$FragmentInline - extends DateInterface1, $Select.Directive.$Groups.InlineFragment.Fields -{} - -export namespace DateInterface1 { - /** - * This is the "expanded" version of the `date1` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type date1$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type date1 = $Select.Indicator.NoArgsIndicator -} - -// -------------- -// Interface Type Error -// -------------- - -export interface Error extends $Select.Bases.ObjectLike { - message?: Error.message - ___on_ErrorOne?: ErrorOne - ___on_ErrorTwo?: ErrorTwo - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Error$FragmentInline | Error$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. Since this is a interface type and thus polymorphic, - * the name is one of the implementor type names, whichever is ultimately returned at runtime. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface Error$FragmentInline extends Error, $Select.Directive.$Groups.InlineFragment.Fields {} - -export namespace Error { - /** - * This is the "expanded" version of the `message` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type message$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type message = $Select.Indicator.NoArgsIndicator -} - -// -------------- -// Interface Type Interface -// -------------- - -export interface Interface extends $Select.Bases.ObjectLike { - id?: Interface.id - ___on_Object1ImplementingInterface?: Object1ImplementingInterface - ___on_Object2ImplementingInterface?: Object2ImplementingInterface - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Interface$FragmentInline | Interface$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. Since this is a interface type and thus polymorphic, - * the name is one of the implementor type names, whichever is ultimately returned at runtime. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface Interface$FragmentInline extends Interface, $Select.Directive.$Groups.InlineFragment.Fields {} - -export namespace Interface { - /** - * This is the "expanded" version of the `id` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type id = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLObjectType Types -// ================================================================================================== -// -// -// -// -// -// - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// Bar -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface Bar extends $Select.Bases.ObjectLike { - /** - * Select the `int` field on the `Bar` object. Its type is `Int` (a `Scalar`). - */ - int?: Bar.int$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Bar$FragmentInline | Bar$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface Bar$FragmentInline extends Bar, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace Bar { - /** - * This is the "expanded" version of the `int` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type int = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// DateObject1 -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface DateObject1 extends $Select.Bases.ObjectLike { - /** - * Select the `date1` field on the `DateObject1` object. Its type is `Date` (a `Scalar`). - */ - date1?: DateObject1.date1$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: DateObject1$FragmentInline | DateObject1$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface DateObject1$FragmentInline extends DateObject1, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace DateObject1 { - /** - * This is the "expanded" version of the `date1` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type date1$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type date1 = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// DateObject2 -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface DateObject2 extends $Select.Bases.ObjectLike { - /** - * Select the `date2` field on the `DateObject2` object. Its type is `Date` (a `Scalar`). - */ - date2?: DateObject2.date2$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: DateObject2$FragmentInline | DateObject2$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface DateObject2$FragmentInline extends DateObject2, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace DateObject2 { - /** - * This is the "expanded" version of the `date2` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type date2$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type date2 = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// ErrorOne -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface ErrorOne extends $Select.Bases.ObjectLike { - /** - * Select the `infoId` field on the `ErrorOne` object. Its type is `ID` (a `Scalar`). - */ - infoId?: ErrorOne.infoId$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `message` field on the `ErrorOne` object. Its type is `String` (a `Scalar`). - */ - message?: ErrorOne.message$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: ErrorOne$FragmentInline | ErrorOne$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface ErrorOne$FragmentInline extends ErrorOne, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace ErrorOne { - /** - * This is the "expanded" version of the `infoId` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type infoId$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type infoId = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `message` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type message$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type message = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// ErrorTwo -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface ErrorTwo extends $Select.Bases.ObjectLike { - /** - * Select the `infoInt` field on the `ErrorTwo` object. Its type is `Int` (a `Scalar`). - */ - infoInt?: ErrorTwo.infoInt$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `message` field on the `ErrorTwo` object. Its type is `String` (a `Scalar`). - */ - message?: ErrorTwo.message$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: ErrorTwo$FragmentInline | ErrorTwo$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface ErrorTwo$FragmentInline extends ErrorTwo, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace ErrorTwo { - /** - * This is the "expanded" version of the `infoInt` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type infoInt$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type infoInt = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `message` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type message$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type message = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// Foo -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -/** - * Object documentation. - */ -export interface Foo extends $Select.Bases.ObjectLike { - /** - * Select the `id` field on the `Foo` object. Its type is `ID` (a `Scalar`). - */ - id?: Foo.id$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Foo$FragmentInline | Foo$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface Foo$FragmentInline extends Foo, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace Foo { - /** - * This is the "expanded" version of the `id` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type id = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// Object1 -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface Object1 extends $Select.Bases.ObjectLike { - /** - * Select the `boolean` field on the `Object1` object. Its type is `Boolean` (a `Scalar`). - */ - boolean?: Object1.$boolean$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `float` field on the `Object1` object. Its type is `Float` (a `Scalar`). - */ - float?: Object1.float$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `id` field on the `Object1` object. Its type is `ID` (a `Scalar`). - */ - id?: Object1.id$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `int` field on the `Object1` object. Its type is `Int` (a `Scalar`). - */ - int?: Object1.int$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `string` field on the `Object1` object. Its type is `String` (a `Scalar`). - */ - string?: Object1.$string$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Object1$FragmentInline | Object1$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface Object1$FragmentInline extends Object1, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace Object1 { - /** - * This is the "expanded" version of the `$boolean` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type $boolean$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type $boolean = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `float` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type float$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type float = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `id` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type id = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `int` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type int = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `$string` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type $string$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type $string = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// Object1ImplementingInterface -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface Object1ImplementingInterface extends $Select.Bases.ObjectLike { - /** - * Select the `id` field on the `Object1ImplementingInterface` object. Its type is `ID` (a `Scalar`). - */ - id?: Object1ImplementingInterface.id$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `int` field on the `Object1ImplementingInterface` object. Its type is `Int` (a `Scalar`). - */ - int?: Object1ImplementingInterface.int$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Object1ImplementingInterface$FragmentInline | Object1ImplementingInterface$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface Object1ImplementingInterface$FragmentInline - extends Object1ImplementingInterface, $Select.Directive.$Groups.InlineFragment.Fields -{} - -// ----------------------------------------| Fields Interfaces | - -export namespace Object1ImplementingInterface { - /** - * This is the "expanded" version of the `id` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type id = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `int` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type int = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// Object2ImplementingInterface -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface Object2ImplementingInterface extends $Select.Bases.ObjectLike { - /** - * Select the `boolean` field on the `Object2ImplementingInterface` object. Its type is `Boolean` (a `Scalar`). - */ - boolean?: - | Object2ImplementingInterface.$boolean$Expanded - | $Select.SelectAlias.SelectAlias - /** - * Select the `id` field on the `Object2ImplementingInterface` object. Its type is `ID` (a `Scalar`). - */ - id?: Object2ImplementingInterface.id$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Object2ImplementingInterface$FragmentInline | Object2ImplementingInterface$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface Object2ImplementingInterface$FragmentInline - extends Object2ImplementingInterface, $Select.Directive.$Groups.InlineFragment.Fields -{} - -// ----------------------------------------| Fields Interfaces | - -export namespace Object2ImplementingInterface { - /** - * This is the "expanded" version of the `$boolean` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type $boolean$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type $boolean = $Select.Indicator.NoArgsIndicator - - /** - * This is the "expanded" version of the `id` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type id = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// ObjectNested -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface ObjectNested extends $Select.Bases.ObjectLike { - /** - * Select the `id` field on the `ObjectNested` object. Its type is `ID` (a `Scalar`). - */ - id?: ObjectNested.id$Expanded | $Select.SelectAlias.SelectAlias - /** - * Select the `object` field on the `ObjectNested` object. Its type is Object. - */ - object?: ObjectNested.$object$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: ObjectNested$FragmentInline | ObjectNested$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface ObjectNested$FragmentInline extends ObjectNested, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace ObjectNested { - /** - * This is the "expanded" version of the `id` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type id = $Select.Indicator.NoArgsIndicator - - export interface $object extends _RefDefs._Object1 {} - export type $object$Expanded = $object -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// ObjectUnion -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface ObjectUnion extends $Select.Bases.ObjectLike { - /** - * Select the `fooBarUnion` field on the `ObjectUnion` object. Its type is Union. - */ - fooBarUnion?: ObjectUnion.fooBarUnion$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: ObjectUnion$FragmentInline | ObjectUnion$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface ObjectUnion$FragmentInline extends ObjectUnion, $Select.Directive.$Groups.InlineFragment.Fields {} - -// ----------------------------------------| Fields Interfaces | - -export namespace ObjectUnion { - export interface fooBarUnion extends _RefDefs._FooBarUnion {} - export type fooBarUnion$Expanded = fooBarUnion -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// lowerCaseObject -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface lowerCaseObject extends $Select.Bases.ObjectLike { - /** - * Select the `id` field on the `lowerCaseObject` object. Its type is `ID` (a `Scalar`). - */ - id?: lowerCaseObject.id$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: lowerCaseObject$FragmentInline | lowerCaseObject$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface lowerCaseObject$FragmentInline - extends lowerCaseObject, $Select.Directive.$Groups.InlineFragment.Fields -{} - -// ----------------------------------------| Fields Interfaces | - -export namespace lowerCaseObject { - /** - * This is the "expanded" version of the `id` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type id$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type id = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// GRAPHQL SELECTION SET -// OBJECT -// -------------------------------------------------------------------------------------------------- -// lowerCaseObject2 -// -------------------------------------------------------------------------------------------------- -// -// - -// ----------------------------------------| Entrypoint Interface | - -export interface lowerCaseObject2 extends $Select.Bases.ObjectLike { - /** - * Select the `int` field on the `lowerCaseObject2` object. Its type is `Int` (a `Scalar`). - */ - int?: lowerCaseObject2.int$Expanded | $Select.SelectAlias.SelectAlias - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: lowerCaseObject2$FragmentInline | lowerCaseObject2$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} - -export interface lowerCaseObject2$FragmentInline - extends lowerCaseObject2, $Select.Directive.$Groups.InlineFragment.Fields -{} - -// ----------------------------------------| Fields Interfaces | - -export namespace lowerCaseObject2 { - /** - * This is the "expanded" version of the `int` type. It is identical except for the fact - * that IDEs will display its contents (a union type) directly, rather than the name of this type. - * In some cases, this is a preferable DX, making the types easier to read for users. - */ - export type int$Expanded = $Select.Indicator.NoArgsIndicator$Expanded - - export type int = $Select.Indicator.NoArgsIndicator -} - -// -// -// -// -// -// -// ================================================================================================== -// GraphQLUnionType Types -// ================================================================================================== -// -// -// -// -// -// - -export interface DateUnion { - ___on_DateObject1?: DateObject1 - ___on_DateObject2?: DateObject2 - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: DateUnion$FragmentInline | DateUnion$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, - * the name is one of the member type names, whichever is ultimately returned at runtime. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} -export interface DateUnion$FragmentInline extends DateUnion, $Select.Directive.$Groups.InlineFragment.Fields {} - -/** - * Union documentation. - */ -export interface FooBarUnion { - ___on_Bar?: Bar - ___on_Foo?: Foo - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: FooBarUnion$FragmentInline | FooBarUnion$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, - * the name is one of the member type names, whichever is ultimately returned at runtime. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} -export interface FooBarUnion$FragmentInline extends FooBarUnion, $Select.Directive.$Groups.InlineFragment.Fields {} - -export interface Result { - ___on_ErrorOne?: ErrorOne - ___on_ErrorTwo?: ErrorTwo - ___on_Object1?: Object1 - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: Result$FragmentInline | Result$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, - * the name is one of the member type names, whichever is ultimately returned at runtime. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} -export interface Result$FragmentInline extends Result, $Select.Directive.$Groups.InlineFragment.Fields {} - -export interface lowerCaseUnion { - ___on_lowerCaseObject?: lowerCaseObject - ___on_lowerCaseObject2?: lowerCaseObject2 - - /** - * Inline fragments for field groups. - * - * Generally a niche feature. This can be useful for example to apply an `@include` directive to a subset of the - * selection set in turn allowing you to pass a variable to opt in/out of that selection during execution on the server. - * - * @see https://spec.graphql.org/draft/#sec-Inline-Fragments - */ - ___?: lowerCaseUnion$FragmentInline | lowerCaseUnion$FragmentInline[] - - /** - * A meta field. Is the name of the type being selected. Since this is a union type and thus polymorphic, - * the name is one of the member type names, whichever is ultimately returned at runtime. - * - * @see https://graphql.org/learn/queries/#meta-fields - */ - __typename?: - | $Select.Indicator.NoArgsIndicator$Expanded - | $Select.SelectAlias.SelectAlias<$Select.Indicator.NoArgsIndicator> -} -export interface lowerCaseUnion$FragmentInline - extends lowerCaseUnion, $Select.Directive.$Groups.InlineFragment.Fields -{} - -/** - * [1] These definitions serve to allow field selection interfaces to extend their respective object type without - * name clashing between the field name and the object name. - * - * For example imagine `Query.Foo` field with type also called `Foo`. Our generated interfaces for each field - * would end up with an error of `export interface Foo extends Foo ...` - */ -export namespace _RefDefs { - export type _Mutation = Mutation - export type _Query = Query - export type _ABCEnum = ABCEnum - export type _Case = Case - export type _InputObject = InputObject - export type _InputObjectCircular = InputObjectCircular - export type _InputObjectNested = InputObjectNested - export type _InputObjectNestedNonNull = InputObjectNestedNonNull - export type _DateInterface1 = DateInterface1 - export type _Error = Error - export type _Interface = Interface - export type _Bar = Bar - export type _DateObject1 = DateObject1 - export type _DateObject2 = DateObject2 - export type _ErrorOne = ErrorOne - export type _ErrorTwo = ErrorTwo - export type _Foo = Foo - export type _Object1 = Object1 - export type _Object1ImplementingInterface = Object1ImplementingInterface - export type _Object2ImplementingInterface = Object2ImplementingInterface - export type _ObjectNested = ObjectNested - export type _ObjectUnion = ObjectUnion - export type _lowerCaseObject = lowerCaseObject - export type _lowerCaseObject2 = lowerCaseObject2 - export type _DateUnion = DateUnion - export type _FooBarUnion = FooBarUnion - export type _Result = Result - export type _lowerCaseUnion = lowerCaseUnion -} diff --git a/package.json b/package.json index 4094c583e..1e65fac8d 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "serve:pokemon": "tsx tests/_/services/pokemonManual.ts", "gen:graffle": "pnpm gen:graffle:tests && pnpm build && cd website && pnpm gen:graffle", "gen:graffle:tests": "tsx tests/_/schemas/generate.ts && pnpm graffle --project src/extensions/SchemaErrors/tests/fixture", + "gen:graffle:tests2": "tsx tests/_/schemas/generate.ts", "graffle": "tsx ./src/cli/generate.ts", "gen:examples": "tsx scripts/generate-examples-derivatives/generate.ts && pnpm format", "dev": "rm -rf dist && tsc --watch", diff --git a/src/entrypoints/utilities-for-generated.ts b/src/entrypoints/utilities-for-generated.ts index daddf0396..4e3712e4f 100644 --- a/src/entrypoints/utilities-for-generated.ts +++ b/src/entrypoints/utilities-for-generated.ts @@ -2,6 +2,7 @@ export { type Simplify } from 'type-fest' export { type SchemaDrivenDataMap } from '../extensions/CustomScalars/schemaDrivenDataMap/__.js' export * from '../layers/2_Select/__.js' export { type Schema as SchemaIndexBase } from '../layers/4_generator/generators/Schema.js' +export { type GlobalRegistry } from '../layers/4_generator/globalRegistry.js' export type { ConfigGetOutputError, HandleOutput, diff --git a/src/extensions/SchemaErrors/SchemaErrors.ts b/src/extensions/SchemaErrors/SchemaErrors.ts index dcb3bb0b7..2c6cdc054 100644 --- a/src/extensions/SchemaErrors/SchemaErrors.ts +++ b/src/extensions/SchemaErrors/SchemaErrors.ts @@ -4,6 +4,7 @@ import { normalizeRequestToNode } from '../../lib/grafaid/request.js' import { type ExcludeNullAndUndefined, isString } from '../../lib/prelude.js' import { isRecordLikeObject } from '../../lib/prelude.js' import { SchemaDrivenDataMap } from '../CustomScalars/schemaDrivenDataMap/__.js' +import type { GeneratedExtensions } from './global.js' import { injectTypenameOnRootResultFields } from './injectTypenameOnRootResultFields.js' export const SchemaErrors = () => { @@ -78,7 +79,7 @@ type OnRequestDocumentRootType<$Params extends Extension.Hooks.OnRequestDocument $Params['selectionRootType'] // dprint-ignore -type OnRequestResult<$Params extends Extension.Hooks.OnRequestResult.Params> = +interface OnRequestResult<$Params extends Extension.Hooks.OnRequestResult.Params> { result: { data?: @@ -87,7 +88,7 @@ type OnRequestResult<$Params extends Extension.Hooks.OnRequestResult.Params> = [$Key in keyof ExcludeNullAndUndefined<$Params['result']['data']>]: Exclude< ExcludeNullAndUndefined<$Params['result']['data']>[$Key], - { __typename: $Params['registeredSchema']['index']['SchemaErrors']['objectNames'] } + { __typename: $Params['registeredSchema']['index']['extensions']['SchemaErrors']['objectNames'] } > } } & Omit<$Params['result'], 'data'> diff --git a/src/extensions/SchemaErrors/generator.ts b/src/extensions/SchemaErrors/generator.ts index ad9b29c5b..517a86a7e 100644 --- a/src/extensions/SchemaErrors/generator.ts +++ b/src/extensions/SchemaErrors/generator.ts @@ -4,30 +4,6 @@ import { Code } from '../../lib/Code.js' import { ConfigManager } from '../../lib/config-manager/__.js' import { Grafaid } from '../../lib/grafaid/__.js' -declare global { - namespace GraffleGlobal { - interface Schema { - SchemaErrors: { - objectNames: string - } - } - namespace SchemaDrivenDataMap { - interface OutputObject { - /** - * Is this output object an error object? - */ - e?: 1 - } - interface OutputField { - /** - * Is this output field a result field? - */ - r?: 1 - } - } - } -} - const propertyNames = { r: `r`, e: `e`, diff --git a/src/extensions/SchemaErrors/global.ts b/src/extensions/SchemaErrors/global.ts new file mode 100644 index 000000000..9209a7bb9 --- /dev/null +++ b/src/extensions/SchemaErrors/global.ts @@ -0,0 +1,33 @@ +import type { GlobalRegistry } from '../../layers/4_generator/globalRegistry.js' + +declare global { + namespace GraffleGlobal { + // interface Schema { + // SchemaErrors: { + // objectNames: string + // } + // } + namespace SchemaDrivenDataMap { + interface OutputObject { + /** + * Is this output object an error object? + */ + e?: 1 + } + interface OutputField { + /** + * Is this output field a result field? + */ + r?: 1 + } + } + } +} + +export type GeneratedExtensions = GlobalRegistry.Extensions<{ + Schema: { + SchemaErrors: { + objectNames: string + } + } +}> diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts index 046000857..52ae32101 100644 --- a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts @@ -1,2 +1,19 @@ -export * from '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' +import type { SchemaKit } from '../../../../../../entrypoints/schema.js' + +// +// +// +// +// CUSTOM SCALAR TYPE +// DATE +// -------------------------------------------------------------------------------------------------- +// Date +// -------------------------------------------------------------------------------------------------- +// +// + +export type DateDecoded = SchemaKit.Scalar.GetDecoded +export type DateEncoded = SchemaKit.Scalar.GetEncoded + export { String as Date } from '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' +export * from '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts index e973e4e97..10cd94f49 100644 --- a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts @@ -4,7 +4,7 @@ import type * as Data from './Data.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as Schema from './SchemaBuildtime.js' -export interface Index { +export interface Index extends Utilities.SchemaIndexBase { name: Data.Name RootTypesPresent: ['Mutation', 'Query'] RootUnion: Schema.Root.Mutation | Schema.Root.Query @@ -66,7 +66,9 @@ export interface Index { Interface: Schema.Interface.Interface } customScalars: Utilities.SchemaIndexBase['customScalars'] - SchemaErrors: { - objectNames: 'ErrorOne' | 'ErrorTwo' + extensions: { + SchemaErrors: { + objectNames: 'ErrorOne' | 'ErrorTwo' + } } } diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaIndex.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaIndex.ts deleted file mode 100644 index aaa42cbef..000000000 --- a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SchemaIndex.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* eslint-disable */ -import type * as Utilities from '../../../../../../entrypoints/utilities-for-generated.js' -import type * as Data from './Data.js' -import type * as MethodsRoot from './MethodsRoot.js' -import type * as Schema from './SchemaBuildtime.js' - -export interface Index { - name: Data.Name - RootTypesPresent: ['Mutation', 'Query'] - RootUnion: Schema.Root.Mutation | Schema.Root.Query - Root: { - Query: Schema.Root.Query - Mutation: Schema.Root.Mutation - Subscription: null - } - allTypes: { - Mutation: Schema.Root.Mutation - Query: Schema.Root.Query - ABCEnum: Schema.Enum.ABCEnum - Case: Schema.Enum.Case - Bar: Schema.Object.Bar - DateObject1: Schema.Object.DateObject1 - DateObject2: Schema.Object.DateObject2 - ErrorOne: Schema.Object.ErrorOne - ErrorTwo: Schema.Object.ErrorTwo - Foo: Schema.Object.Foo - Object1: Schema.Object.Object1 - Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface - Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface - ObjectNested: Schema.Object.ObjectNested - ObjectUnion: Schema.Object.ObjectUnion - lowerCaseObject: Schema.Object.lowerCaseObject - lowerCaseObject2: Schema.Object.lowerCaseObject2 - DateUnion: Schema.Union.DateUnion - FooBarUnion: Schema.Union.FooBarUnion - Result: Schema.Union.Result - lowerCaseUnion: Schema.Union.lowerCaseUnion - DateInterface1: Schema.Interface.DateInterface1 - Error: Schema.Interface.Error - Interface: Schema.Interface.Interface - } - objects: { - Bar: Schema.Object.Bar - DateObject1: Schema.Object.DateObject1 - DateObject2: Schema.Object.DateObject2 - ErrorOne: Schema.Object.ErrorOne - ErrorTwo: Schema.Object.ErrorTwo - Foo: Schema.Object.Foo - Object1: Schema.Object.Object1 - Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface - Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface - ObjectNested: Schema.Object.ObjectNested - ObjectUnion: Schema.Object.ObjectUnion - lowerCaseObject: Schema.Object.lowerCaseObject - lowerCaseObject2: Schema.Object.lowerCaseObject2 - } - unions: { - DateUnion: Schema.Union.DateUnion - FooBarUnion: Schema.Union.FooBarUnion - Result: Schema.Union.Result - lowerCaseUnion: Schema.Union.lowerCaseUnion - } - interfaces: { - DateInterface1: Schema.Interface.DateInterface1 - Error: Schema.Interface.Error - Interface: Schema.Interface.Interface - } - customScalars: Utilities.SchemaIndexBase['customScalars'] -} diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SelectionSets.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SelectionSets.ts index 51b17ad31..eeeb317c7 100644 --- a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SelectionSets.ts +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/SelectionSets.ts @@ -439,7 +439,7 @@ export namespace Query { export type date = $Select.Indicator.NoArgsIndicator export type dateArg$SelectionSetArguments = { - date?: undefined | undefined | null + date?: $Scalar.DateDecoded | undefined | null } export type dateArg$SelectionSet = $Utilities.Simplify< $Select.Bases.Base & { @@ -485,7 +485,7 @@ export namespace Query { export type dateArgInputObject = $Select.Indicator.Indicator | dateArgInputObject$SelectionSet export type dateArgList$SelectionSetArguments = { - date?: Array | undefined | null + date?: Array<$Scalar.DateDecoded | undefined | null> | undefined | null } export type dateArgList$SelectionSet = $Utilities.Simplify< $Select.Bases.Base & { @@ -507,7 +507,7 @@ export namespace Query { export type dateArgList = $Select.Indicator.Indicator | dateArgList$SelectionSet export type dateArgNonNull$SelectionSetArguments = { - date: undefined + date: $Scalar.DateDecoded } export interface dateArgNonNull extends $Select.Bases.Base { /** @@ -518,7 +518,7 @@ export namespace Query { } export type dateArgNonNullList$SelectionSetArguments = { - date: Array + date: Array<$Scalar.DateDecoded | undefined | null> } export interface dateArgNonNullList extends $Select.Bases.Base { /** @@ -529,7 +529,7 @@ export namespace Query { } export type dateArgNonNullListNonNull$SelectionSetArguments = { - date: Array + date: Array<$Scalar.DateDecoded | undefined | null> } export interface dateArgNonNullListNonNull extends $Select.Bases.Base { /** @@ -924,15 +924,15 @@ export type Case = 'ErrorOne' | 'ErrorTwo' | 'Object1' // export interface InputObject { - date?: undefined | undefined | null - dateRequired: undefined + date?: $Scalar.DateDecoded | undefined | null + dateRequired: $Scalar.DateDecoded id?: string | undefined | null idRequired: string } export interface InputObjectCircular { circular?: _RefDefs._InputObjectCircular | undefined | null - date?: undefined | undefined | null + date?: $Scalar.DateDecoded | undefined | null } export interface InputObjectNested { diff --git a/src/layers/3_InferResult/__.test-d.ts b/src/layers/3_InferResult/__.test-d.ts index 13878fe7b..a310ca921 100644 --- a/src/layers/3_InferResult/__.test-d.ts +++ b/src/layers/3_InferResult/__.test-d.ts @@ -1,5 +1,5 @@ +import type { Index } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/Schema.js' import type * as Schema from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SchemaBuildtime.js' -import type { Index } from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SchemaIndex.js' import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js' import { assertEqual } from '../../lib/assert-equal.js' import type { InferResult } from './__.js' diff --git a/src/layers/4_generator/config/config.ts b/src/layers/4_generator/config/config.ts index cbe95a513..0f60dddcb 100644 --- a/src/layers/4_generator/config/config.ts +++ b/src/layers/4_generator/config/config.ts @@ -75,11 +75,18 @@ export const createConfig = async (input: Input): Promise => { const outputDirPathModules = Path.join(outputDirPathRoot, `/modules`) - const inputPathCustomScalarCodecs = input.sourceCustomScalarCodecsFilePath - ? toAbsolutePath(cwd, input.sourceCustomScalarCodecsFilePath) + const inputPathCustomScalarCodecs = input.customScalarCodecs + ? toAbsolutePath(cwd, input.customScalarCodecs) : Path.join(sourceDirPath, `customScalarCodecs.ts`) const customScalarCodecsPathExists = await fileExists(inputPathCustomScalarCodecs) + if (!customScalarCodecsPathExists && input.customScalarCodecs) { + throw new Error( + `Custom scalar codecs file not found. Given path: ${ + String(input.customScalarCodecs) + }. Resolved to and looked at: ${inputPathCustomScalarCodecs}`, + ) + } const customScalarCodecsImportPath = Path.relative( outputDirPathModules, diff --git a/src/layers/4_generator/config/input.ts b/src/layers/4_generator/config/input.ts index 6b48d9ddb..8481ef366 100644 --- a/src/layers/4_generator/config/input.ts +++ b/src/layers/4_generator/config/input.ts @@ -92,9 +92,11 @@ export interface Input { */ sourceDirPath?: string /** - * todo + * File path to your custom scalar codecs module. + * + * If not set, Graffle will look for a file called `customScalarCodecs.ts` in the project directory. */ - sourceCustomScalarCodecsFilePath?: string + customScalarCodecs?: string /** * Override import paths to graffle package within the generated code. * Used by Graffle test suite to have generated clients point to source diff --git a/src/layers/4_generator/generators/Scalar.ts b/src/layers/4_generator/generators/Scalar.ts index be268e4df..60d122ebf 100644 --- a/src/layers/4_generator/generators/Scalar.ts +++ b/src/layers/4_generator/generators/Scalar.ts @@ -14,44 +14,52 @@ export const ModuleGeneratorScalar = createModuleGenerator( const isNeedCustomScalarDefaults = Grafaid.Schema.KindMap.hasCustomScalars(config.schema.kindMap) && !config.options.customScalars + code(`import type { SchemaKit } from '${config.paths.imports.grafflePackage.schema}'`) + code() + if (Grafaid.Schema.KindMap.hasCustomScalars(config.schema.kindMap) && config.options.customScalars) { - code(`import type { Schema } from '${config.paths.imports.grafflePackage.schema}'`) code(`import * as ${identifiers.CustomScalars} from '${config.paths.imports.customScalarCodecs}'`) code() - code(`export * from '${config.paths.imports.grafflePackage.scalars}'`) code(`export * from '${config.paths.imports.customScalarCodecs}'`) const names = config.schema.kindMap.GraphQLScalarTypeCustom.map((scalar) => scalar.name).join(`, `) code(`export { ${names} } from '${config.paths.imports.customScalarCodecs}'`) - for (const scalar of config.schema.kindMap.GraphQLScalarTypeCustom) { code(typeTitle2(`custom scalar type`)(scalar)) code() code(`export type ${scalar.name} = typeof ${identifiers.CustomScalars}.${scalar.name}`) - code( - `// Without this we get error: - // "Exported type alias 'DateDecoded' has or is using private name 'Date'."`, - ) + code(` + // Without this we get error: + // "Exported type alias 'DateDecoded' has or is using private name 'Date'." + `) code(`type ${scalar.name}_ = typeof ${identifiers.CustomScalars}.${scalar.name}`) - code(`export type ${scalar.name}Decoded = Schema.Scalar.GetDecoded<${scalar.name}_>`) - code(`export type ${scalar.name}Encoded = Schema.Scalar.GetEncoded<${scalar.name}_>`) + code(`export type ${scalar.name}Decoded = SchemaKit.Scalar.GetDecoded<${scalar.name}_>`) + code(`export type ${scalar.name}Encoded = SchemaKit.Scalar.GetEncoded<${scalar.name}_>`) + code() + } + } else { + for (const scalar of config.schema.kindMap.GraphQLScalarTypeCustom) { + code(typeTitle2(`custom scalar type`)(scalar)) + code() + code(`export type ${scalar.name}Decoded = SchemaKit.Scalar.GetDecoded<${scalar.name}>`) + code(`export type ${scalar.name}Encoded = SchemaKit.Scalar.GetEncoded<${scalar.name}>`) code() } } if (isNeedCustomScalarDefaults) { - // code(`import * as ${identifiers.StandardScalar} from '${config.paths.imports.grafflePackage.scalars}'`) code() if (config.lint.missingCustomScalarCodec) { console.log( `WARNING: Custom scalars detected in the schema, but you have not created a custom scalars module to import implementations from.`, ) } - code(`export * from '${config.paths.imports.grafflePackage.scalars}'`) code(`export {`) code( config.schema.kindMap.GraphQLScalarTypeCustom.map((_) => `String as ${_.name}`).join(`,`), ) code(`} from '${config.paths.imports.grafflePackage.scalars}'`) } + + code(`export * from '${config.paths.imports.grafflePackage.scalars}'`) }, ) diff --git a/src/layers/4_generator/generators/Schema.ts b/src/layers/4_generator/generators/Schema.ts index 69f8bd7c6..68206a9f7 100644 --- a/src/layers/4_generator/generators/Schema.ts +++ b/src/layers/4_generator/generators/Schema.ts @@ -8,42 +8,81 @@ import { ModuleGeneratorData } from './Data.js' import { ModuleGeneratorMethodsRoot } from './MethodsRoot.js' import { ModuleGeneratorSchemaBuildtime } from './SchemaBuildtime.js' -declare global { - namespace GraffleGlobal { - /** - * A generic schema index type. Any particular schema index will be a subtype of this, with - * additional specificity such as on objects where here `Record` is used. - */ - export interface Schema { - name: GlobalRegistry.SchemaNames - RootTypesPresent: ('Query' | 'Mutation' | 'Subscription')[] - RootUnion: SchemaKit.Output.RootType - Root: { - Query: null | SchemaKit.Output.ObjectQuery - Mutation: null | SchemaKit.Output.ObjectMutation - Subscription: null | SchemaKit.Output.ObjectSubscription - } - allTypes: Record< - string, - | SchemaKit.Hybrid.Enum - | SchemaKit.Output.ObjectQuery - | SchemaKit.Output.ObjectMutation - | SchemaKit.Output.Object$2 - | SchemaKit.Output.Union - | SchemaKit.Output.Interface - > - objects: Record - unions: Record - interfaces: Record - customScalars: { - input: SchemaDrivenDataMap - } - } +// todo: consider removing global approach since it doesn't play well with multiple schemas +// declare global { +// namespace GraffleGlobal { +// /** +// * A generic schema index type. Any particular schema index will be a subtype of this, with +// * additional specificity such as on objects where here `Record` is used. +// */ +// export interface Schema< +// $Extensions extends GlobalRegistry.TypeExtensions = GlobalRegistry.TypeExtensions, +// > { +// name: GlobalRegistry.SchemaNames +// RootTypesPresent: ('Query' | 'Mutation' | 'Subscription')[] +// RootUnion: SchemaKit.Output.RootType +// Root: { +// Query: null | SchemaKit.Output.ObjectQuery +// Mutation: null | SchemaKit.Output.ObjectMutation +// Subscription: null | SchemaKit.Output.ObjectSubscription +// } +// allTypes: Record< +// string, +// | SchemaKit.Hybrid.Enum +// | SchemaKit.Output.ObjectQuery +// | SchemaKit.Output.ObjectMutation +// | SchemaKit.Output.Object$2 +// | SchemaKit.Output.Union +// | SchemaKit.Output.Interface +// > +// objects: Record +// unions: Record +// interfaces: Record +// customScalars: { +// input: SchemaDrivenDataMap +// } +// extensions: $Extensions +// } +// } +// } + +// export type Schema< +// $Extensions extends GlobalRegistry.TypeExtensions = GlobalRegistry.TypeExtensions, +// > = GraffleGlobal.Schema<$Extensions> + +/** + * A generic schema type. Any particular schema will be a subtype of this, with + * additional specificity such as on objects where here `Record` is used. + */ +export interface Schema< + $Extensions extends GlobalRegistry.TypeExtensions = GlobalRegistry.TypeExtensions, +> { + name: GlobalRegistry.SchemaNames + RootTypesPresent: ('Query' | 'Mutation' | 'Subscription')[] + RootUnion: SchemaKit.Output.RootType + Root: { + Query: null | SchemaKit.Output.ObjectQuery + Mutation: null | SchemaKit.Output.ObjectMutation + Subscription: null | SchemaKit.Output.ObjectSubscription } + allTypes: Record< + string, + | SchemaKit.Hybrid.Enum + | SchemaKit.Output.ObjectQuery + | SchemaKit.Output.ObjectMutation + | SchemaKit.Output.Object$2 + | SchemaKit.Output.Union + | SchemaKit.Output.Interface + > + objects: Record + unions: Record + interfaces: Record + customScalars: { + input: SchemaDrivenDataMap + } + extensions: $Extensions } -export type Schema = GraffleGlobal.Schema - const identifiers = { Utilities: `Utilities`, } @@ -103,20 +142,36 @@ export const ModuleGeneratorSchema = createModuleGenerator( ...interfaces, ]), objects: Code.objectFromEntries(objects), - // schemaIndex: identifiers.customScalarsIndex, unions: Code.objectFromEntries(unions), interfaces: Code.objectFromEntries(interfaces), customScalars: `${identifiers.Utilities}.SchemaIndexBase['customScalars']`, + extensions: `Utilities.GlobalRegistry.TypeExtensions`, } + // --- Extensions --- + // If the extensions object is populated it will override the default generic type. + + const extensions: Code.TermObject = {} + config.extensions.forEach(_ => { - _.onSchema?.({ config, schema }) + _.onSchema?.({ config, schema: extensions }) }) + if (!isObjectEmpty(extensions)) { + schema[`extensions`] = extensions + } + + // --- - code(Code.export$( - Code.interface$(`Index`, Code.termObject(schema)), - )) + code( + `export interface Index extends Utilities.SchemaIndexBase + ${Code.termObject(schema)} + `, + ) return code }, ) + +const isObjectEmpty = (object: Record) => { + return Object.keys(object).length === 0 +} diff --git a/src/layers/4_generator/globalRegistry.ts b/src/layers/4_generator/globalRegistry.ts index 28c8bc953..49bc77a12 100644 --- a/src/layers/4_generator/globalRegistry.ts +++ b/src/layers/4_generator/globalRegistry.ts @@ -1,5 +1,6 @@ import type { TypeFunction } from '../../entrypoints/utilities-for-generated.js' -import type { Values } from '../../lib/prelude.js' +import type { ConfigManager } from '../../lib/config-manager/__.js' +import type { ExcludeUndefined, GetKeyOr, Values } from '../../lib/prelude.js' import type { TSErrorDescriptive } from '../../lib/ts-error.js' import type { Schema } from './generators/Schema.js' @@ -24,10 +25,19 @@ type ZeroSchema = { export type GlobalRegistry = Record export namespace GlobalRegistry { - export interface RegisteredSchema { + export type TypeExtensions = Record> + + export type Extensions< + $Extensions extends { Schema?: TypeExtensions } = { + Schema: TypeExtensions + }, + > = { + Schema: ConfigManager.OrDefault<$Extensions['Schema'], TypeExtensions> + } + + export interface RegisteredSchema<$Extensions extends Extensions = Extensions> { name: string - index: Schema - // featureOptions: {} + index: Schema<$Extensions['Schema']> interfaces: { Root: TypeFunction.Fn Document: TypeFunction.Fn diff --git a/src/layers/6_client/extension/extension.ts b/src/layers/6_client/extension/extension.ts index 8b92b52ab..ee2254eb6 100644 --- a/src/layers/6_client/extension/extension.ts +++ b/src/layers/6_client/extension/extension.ts @@ -59,9 +59,9 @@ export namespace Extension { } export interface OnRequestResult extends Fn {} export namespace OnRequestResult { - export interface Params { + export interface Params<$Extensions extends GlobalRegistry.Extensions = GlobalRegistry.Extensions> { result: GraffleExecutionResultEnvelope - registeredSchema: GlobalRegistry.RegisteredSchema + registeredSchema: GlobalRegistry.RegisteredSchema<$Extensions> } } } diff --git a/src/lib/config-manager/ConfigManager.ts b/src/lib/config-manager/ConfigManager.ts index f0fb98f97..1fcd89f38 100644 --- a/src/lib/config-manager/ConfigManager.ts +++ b/src/lib/config-manager/ConfigManager.ts @@ -91,7 +91,9 @@ const mergeDefaults_: MergeDefaultsInnerFn = ( type Path = [...string[]] -export type ReadOrDefault<$Obj, $Path extends Path, $Default> = OrDefault, $Default> +// dprint-ignore +export type ReadOrDefault<$Obj, $Path extends Path, $Default> = + OrDefault, $Default> // dprint-ignore export type OrDefault<$Value, $Default> = diff --git a/src/lib/grafaid/schema/schema.ts b/src/lib/grafaid/schema/schema.ts index f2fdf4d65..270afdde6 100644 --- a/src/lib/grafaid/schema/schema.ts +++ b/src/lib/grafaid/schema/schema.ts @@ -106,7 +106,7 @@ export const isGraphQLField = (value: object): value is GraphQLField = } export const isScalarTypeCustom = (node: GraphQLScalarType): boolean => { - return node.astNode !== undefined + return !(node.name in standardScalarTypeNames) } export const standardScalarTypeNames = { @@ -118,7 +118,7 @@ export const standardScalarTypeNames = { } export const isScalarTypeAndCustom = (node: unknown): node is GraphQLScalarType => { - return isScalarType(node) && !(node.name in standardScalarTypeNames) + return isScalarType(node) && isScalarTypeCustom(node) } export const isAllInputObjectFieldsNullable = (node: GraphQLInputObjectType) => { diff --git a/tests/_/helpers.ts b/tests/_/helpers.ts index 38085cebe..3e2b957ea 100644 --- a/tests/_/helpers.ts +++ b/tests/_/helpers.ts @@ -7,7 +7,7 @@ import { CONTENT_TYPE_REC } from '../../src/lib/grafaid/http/http.js' import { type SchemaService, serveSchema } from './lib/serveSchema.js' import { db } from './schemas/db.js' import { Graffle as KitchenSink } from './schemas/kitchen-sink/graffle/__.js' -import { type Index as KitchenSinkSchemaIndex } from './schemas/kitchen-sink/graffle/modules/SchemaIndex.js' +import { type Index as KitchenSinkSchema } from './schemas/kitchen-sink/graffle/modules/Schema.js' import { schema as kitchenSinkSchema } from './schemas/kitchen-sink/schema.js' import { schema } from './schemas/pokemon/schema.js' @@ -20,8 +20,8 @@ interface Fixtures { fetch: Mock<(request: Request) => Promise> pokemonService: SchemaService graffle: Client<{ config: Config; schemaIndex: null }> - kitchenSink: Client<{ config: Config & { name: 'default' }; schemaIndex: KitchenSinkSchemaIndex }> - kitchenSinkHttp: Client<{ config: Config & { name: 'default' }; schemaIndex: KitchenSinkSchemaIndex }> + kitchenSink: Client<{ config: Config & { name: 'default' }; schemaIndex: KitchenSinkSchema }> + kitchenSinkHttp: Client<{ config: Config & { name: 'default' }; schemaIndex: KitchenSinkSchema }> kitchenSinkData: typeof db } diff --git a/tests/_/schemas/generate.ts b/tests/_/schemas/generate.ts index 4e7b3add8..8b7a348a0 100644 --- a/tests/_/schemas/generate.ts +++ b/tests/_/schemas/generate.ts @@ -21,7 +21,6 @@ const generate = async ( // todo funky between this and passing path to sdl sourceDirPath: inputPathRootDir, outputSDL: true, - sourceCustomScalarCodecsFilePath: join(`./tests/_/customScalarCodecs.ts`), outputDirPath: join(input.dirName, `graffle`), libraryPaths: { client: `../../../src/entrypoints/client.ts`, @@ -59,4 +58,7 @@ await generate({ await generate({ dirName: `kitchen-sink`, + input: { + customScalarCodecs: `./kitchen-sink/customScalarCodecs.ts`, + }, }) diff --git a/tests/_/customScalarCodecs.ts b/tests/_/schemas/kitchen-sink/customScalarCodecs.ts similarity index 73% rename from tests/_/customScalarCodecs.ts rename to tests/_/schemas/kitchen-sink/customScalarCodecs.ts index 2207ebd6c..7dc741db7 100644 --- a/tests/_/customScalarCodecs.ts +++ b/tests/_/schemas/kitchen-sink/customScalarCodecs.ts @@ -1,4 +1,4 @@ -import { Graffle } from '../../src/entrypoints/main.js' +import { Graffle } from '../../../../src/entrypoints/main.js' export const Date = Graffle.Scalars.create(`Date`, { encode: (value: globalThis.Date) => value.toISOString(), diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/Global.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Global.ts index f7af69d03..3238c78c5 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/Global.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Global.ts @@ -2,7 +2,8 @@ import type * as Data from './Data.js' import type * as MethodsDocument from './MethodsDocument.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as MethodsSelect from './MethodsSelect.js' -import type { Index } from './SchemaIndex.js' +import type * as Scalar from './Scalar.js' +import type { Index } from './Schema.js' declare global { export namespace GraffleGlobal { @@ -15,8 +16,9 @@ declare global { Document: MethodsDocument.BuilderMethodsDocumentFn Root: MethodsRoot.BuilderMethodsRootFn } - customScalars: {} - + customScalars: { + Date: Scalar.Date + } defaultSchemaUrl: null } } diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/MethodsDocument.ts b/tests/_/schemas/kitchen-sink/graffle/modules/MethodsDocument.ts index 8843f754d..0a5043616 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/MethodsDocument.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/MethodsDocument.ts @@ -1,5 +1,5 @@ import type * as Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' export interface Document<$Config extends Utilities.Config> { diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/MethodsRoot.ts b/tests/_/schemas/kitchen-sink/graffle/modules/MethodsRoot.ts index 7e0066d8a..c75de072c 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/MethodsRoot.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/MethodsRoot.ts @@ -1,7 +1,7 @@ import { type Simplify } from 'type-fest' import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import type * as Utils from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSet from './SelectionSets.js' export interface MutationMethods<$Config extends Utils.Config> { diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts index 872cc54b5..8d0fd17a0 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts @@ -1 +1,26 @@ +import type { SchemaKit } from '../../../../../../src/entrypoints/schema.js' + +import * as CustomScalars from '../../customScalarCodecs.js' + +export * from '../../customScalarCodecs.js' +export { Date } from '../../customScalarCodecs.js' +// +// +// +// +// CUSTOM SCALAR TYPE +// DATE +// -------------------------------------------------------------------------------------------------- +// Date +// -------------------------------------------------------------------------------------------------- +// +// + +export type Date = typeof CustomScalars.Date +// Without this we get error: +// "Exported type alias 'DateDecoded' has or is using private name 'Date'." +type Date_ = typeof CustomScalars.Date +export type DateDecoded = SchemaKit.Scalar.GetDecoded +export type DateEncoded = SchemaKit.Scalar.GetEncoded + export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/SchemaIndex.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts similarity index 95% rename from tests/_/schemas/kitchen-sink/graffle/modules/SchemaIndex.ts rename to tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts index 07026e1de..771d31930 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/SchemaIndex.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts @@ -4,7 +4,7 @@ import type * as Data from './Data.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as Schema from './SchemaBuildtime.js' -export interface Index { +export interface Index extends Utilities.SchemaIndexBase { name: Data.Name RootTypesPresent: ['Mutation', 'Query'] RootUnion: Schema.Root.Mutation | Schema.Root.Query @@ -66,4 +66,5 @@ export interface Index { Interface: Schema.Interface.Interface } customScalars: Utilities.SchemaIndexBase['customScalars'] + extensions: Utilities.GlobalRegistry.TypeExtensions } diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.ts b/tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.ts index bdeec40c7..7b2c3e5c5 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/SchemaDrivenDataMap.ts @@ -7,7 +7,7 @@ import * as $Scalar from './Scalar.js' // // // ================================================================================================== -// GraphQLScalarType +// GraphQLScalarTypeStandard // ================================================================================================== // // @@ -18,8 +18,6 @@ import * as $Scalar from './Scalar.js' const Boolean = $Scalar.Boolean -const Date = $Scalar.Date - const Float = $Scalar.Float const ID = $Scalar.ID @@ -44,7 +42,7 @@ const String = $Scalar.String // // -// None of your GraphQLScalarTypeCustoms have custom scalars. +const Date = $Scalar.Date // // @@ -90,9 +88,14 @@ const Case: $Utilities.SchemaDrivenDataMap.Enum = { const InputObject: $Utilities.SchemaDrivenDataMap.InputObject = { n: 'InputObject', + fcs: ['date', 'dateRequired'], f: { - date: {}, - dateRequired: {}, + date: { + nt: Date, + }, + dateRequired: { + nt: Date, + }, id: {}, idRequired: {}, }, @@ -100,23 +103,34 @@ const InputObject: $Utilities.SchemaDrivenDataMap.InputObject = { const InputObjectCircular: $Utilities.SchemaDrivenDataMap.InputObject = { n: 'InputObjectCircular', + fcs: ['circular', 'date'], f: { - circular: {}, - date: {}, + circular: { + // nt: InputObjectCircular, <-- Assigned later to avoid potential circular dependency. + }, + date: { + nt: Date, + }, }, } const InputObjectNested: $Utilities.SchemaDrivenDataMap.InputObject = { n: 'InputObjectNested', + fcs: ['InputObject'], f: { - InputObject: {}, + InputObject: { + // nt: InputObject, <-- Assigned later to avoid potential circular dependency. + }, }, } const InputObjectNestedNonNull: $Utilities.SchemaDrivenDataMap.InputObject = { n: 'InputObjectNestedNonNull', + fcs: ['InputObject'], f: { - InputObject: {}, + InputObject: { + // nt: InputObject, <-- Assigned later to avoid potential circular dependency. + }, }, } @@ -144,13 +158,17 @@ const Bar: $Utilities.SchemaDrivenDataMap.OutputObject = { const DateObject1: $Utilities.SchemaDrivenDataMap.OutputObject = { f: { - date1: {}, + date1: { + nt: Date, + }, }, } const DateObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { f: { - date2: {}, + date2: { + nt: Date, + }, }, } @@ -244,7 +262,9 @@ const lowerCaseObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { // const DateInterface1: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: {}, + f: { + ...DateObject1.f, + }, } const Error: $Utilities.SchemaDrivenDataMap.OutputObject = { @@ -272,7 +292,10 @@ const Interface: $Utilities.SchemaDrivenDataMap.OutputObject = { // const DateUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { - f: {}, + f: { + ...DateObject1.f, + ...DateObject2.f, + }, } const FooBarUnion: $Utilities.SchemaDrivenDataMap.OutputObject = { @@ -337,7 +360,9 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { }, }, }, - date: {}, + date: { + nt: Date, + }, dateArg: { a: { date: { @@ -345,6 +370,7 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [0], }, }, + nt: Date, }, dateArgInputObject: { a: { @@ -353,6 +379,7 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [0], }, }, + nt: Date, }, dateArgList: { a: { @@ -361,6 +388,7 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [0, [1]], }, }, + nt: Date, }, dateArgNonNull: { a: { @@ -369,6 +397,7 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [1], }, }, + nt: Date, }, dateArgNonNullList: { a: { @@ -377,6 +406,7 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [1, [0]], }, }, + nt: Date, }, dateArgNonNullListNonNull: { a: { @@ -385,14 +415,23 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [1, [1]], }, }, + nt: Date, }, dateInterface1: { // nt: DateInterface1, <-- Assigned later to avoid potential circular dependency. }, - dateList: {}, - dateListList: {}, - dateListNonNull: {}, - dateNonNull: {}, + dateList: { + nt: Date, + }, + dateListList: { + nt: Date, + }, + dateListNonNull: { + nt: Date, + }, + dateNonNull: { + nt: Date, + }, dateObject1: { // nt: DateObject1, <-- Assigned later to avoid potential circular dependency. }, @@ -603,28 +642,31 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { // // -ObjectNested.f['object']!.nt = Object1 -ObjectUnion.f['fooBarUnion']!.nt = FooBarUnion -Query.f['dateInterface1']!.nt = DateInterface1 -Query.f['dateObject1']!.nt = DateObject1 -Query.f['dateUnion']!.nt = DateUnion -Query.f['interface']!.nt = Interface -Query.f['interfaceNonNull']!.nt = Interface -Query.f['interfaceWithArgs']!.nt = Interface -Query.f['lowerCaseUnion']!.nt = lowerCaseUnion -Query.f['object']!.nt = Object1 -Query.f['objectList']!.nt = Object1 -Query.f['objectListNonNull']!.nt = Object1 -Query.f['objectNested']!.nt = ObjectNested -Query.f['objectNonNull']!.nt = Object1 -Query.f['objectWithArgs']!.nt = Object1 -Query.f['result']!.nt = Result -Query.f['resultNonNull']!.nt = Result -Query.f['unionFooBar']!.nt = FooBarUnion -Query.f['unionFooBarNonNull']!.nt = FooBarUnion -Query.f['unionFooBarWithArgs']!.nt = FooBarUnion -Query.f['unionObject']!.nt = ObjectUnion -Query.f['unionObjectNonNull']!.nt = ObjectUnion +InputObjectCircular.f![`circular`]!.nt = InputObjectCircular +InputObjectNested.f![`InputObject`]!.nt = InputObject +InputObjectNestedNonNull.f![`InputObject`]!.nt = InputObject +ObjectNested.f[`object`]!.nt = Object1 +ObjectUnion.f[`fooBarUnion`]!.nt = FooBarUnion +Query.f[`dateInterface1`]!.nt = DateInterface1 +Query.f[`dateObject1`]!.nt = DateObject1 +Query.f[`dateUnion`]!.nt = DateUnion +Query.f[`interface`]!.nt = Interface +Query.f[`interfaceNonNull`]!.nt = Interface +Query.f[`interfaceWithArgs`]!.nt = Interface +Query.f[`lowerCaseUnion`]!.nt = lowerCaseUnion +Query.f[`object`]!.nt = Object1 +Query.f[`objectList`]!.nt = Object1 +Query.f[`objectListNonNull`]!.nt = Object1 +Query.f[`objectNested`]!.nt = ObjectNested +Query.f[`objectNonNull`]!.nt = Object1 +Query.f[`objectWithArgs`]!.nt = Object1 +Query.f[`result`]!.nt = Result +Query.f[`resultNonNull`]!.nt = Result +Query.f[`unionFooBar`]!.nt = FooBarUnion +Query.f[`unionFooBarNonNull`]!.nt = FooBarUnion +Query.f[`unionFooBarWithArgs`]!.nt = FooBarUnion +Query.f[`unionObject`]!.nt = ObjectUnion +Query.f[`unionObjectNonNull`]!.nt = ObjectUnion // // @@ -650,11 +692,11 @@ const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { directives: {}, types: { Boolean, - Date, Float, ID, Int, String, + Date, ABCEnum, Case, InputObject, diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/Select.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Select.ts index 247d0ff88..ae7bab31e 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/Select.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Select.ts @@ -1,6 +1,6 @@ import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import * as Data from './Data.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' // diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.ts b/tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.ts index c8b8c60ab..4632a1147 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.ts @@ -1,5 +1,6 @@ import type { Select as $Select } from '../../../../../../src/entrypoints/schema.js' import type * as $Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' +import type * as $Scalar from './Scalar.js' // // @@ -438,7 +439,7 @@ export namespace Query { export type date = $Select.Indicator.NoArgsIndicator export type dateArg$SelectionSetArguments = { - date?: undefined | undefined | null + date?: $Scalar.DateDecoded | undefined | null } export type dateArg$SelectionSet = $Utilities.Simplify< $Select.Bases.Base & { @@ -484,7 +485,7 @@ export namespace Query { export type dateArgInputObject = $Select.Indicator.Indicator | dateArgInputObject$SelectionSet export type dateArgList$SelectionSetArguments = { - date?: Array | undefined | null + date?: Array<$Scalar.DateDecoded | undefined | null> | undefined | null } export type dateArgList$SelectionSet = $Utilities.Simplify< $Select.Bases.Base & { @@ -506,7 +507,7 @@ export namespace Query { export type dateArgList = $Select.Indicator.Indicator | dateArgList$SelectionSet export type dateArgNonNull$SelectionSetArguments = { - date: undefined + date: $Scalar.DateDecoded } export interface dateArgNonNull extends $Select.Bases.Base { /** @@ -517,7 +518,7 @@ export namespace Query { } export type dateArgNonNullList$SelectionSetArguments = { - date: Array + date: Array<$Scalar.DateDecoded | undefined | null> } export interface dateArgNonNullList extends $Select.Bases.Base { /** @@ -528,7 +529,7 @@ export namespace Query { } export type dateArgNonNullListNonNull$SelectionSetArguments = { - date: Array + date: Array<$Scalar.DateDecoded | undefined | null> } export interface dateArgNonNullListNonNull extends $Select.Bases.Base { /** @@ -923,15 +924,15 @@ export type Case = 'ErrorOne' | 'ErrorTwo' | 'Object1' // export interface InputObject { - date?: undefined | undefined | null - dateRequired: undefined + date?: $Scalar.DateDecoded | undefined | null + dateRequired: $Scalar.DateDecoded id?: string | undefined | null idRequired: string } export interface InputObjectCircular { circular?: _RefDefs._InputObjectCircular | undefined | null - date?: undefined | undefined | null + date?: $Scalar.DateDecoded | undefined | null } export interface InputObjectNested { diff --git a/tests/_/schemas/mutation-only/graffle/modules/Global.ts b/tests/_/schemas/mutation-only/graffle/modules/Global.ts index b054d04af..004b80917 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/Global.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/Global.ts @@ -2,7 +2,7 @@ import type * as Data from './Data.js' import type * as MethodsDocument from './MethodsDocument.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as MethodsSelect from './MethodsSelect.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' declare global { export namespace GraffleGlobal { @@ -16,7 +16,6 @@ declare global { Root: MethodsRoot.BuilderMethodsRootFn } customScalars: {} - defaultSchemaUrl: null } } diff --git a/tests/_/schemas/mutation-only/graffle/modules/MethodsDocument.ts b/tests/_/schemas/mutation-only/graffle/modules/MethodsDocument.ts index 8843f754d..0a5043616 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/MethodsDocument.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/MethodsDocument.ts @@ -1,5 +1,5 @@ import type * as Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' export interface Document<$Config extends Utilities.Config> { diff --git a/tests/_/schemas/mutation-only/graffle/modules/MethodsRoot.ts b/tests/_/schemas/mutation-only/graffle/modules/MethodsRoot.ts index 63741f4a8..2ae77f7d7 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/MethodsRoot.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/MethodsRoot.ts @@ -1,7 +1,7 @@ import { type Simplify } from 'type-fest' import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import type * as Utils from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSet from './SelectionSets.js' export interface MutationMethods<$Config extends Utils.Config> { diff --git a/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts b/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts index 872cc54b5..026aa6405 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts @@ -1 +1,3 @@ +import type { SchemaKit } from '../../../../../../src/entrypoints/schema.js' + export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' diff --git a/tests/_/schemas/mutation-only/graffle/modules/SchemaIndex.ts b/tests/_/schemas/mutation-only/graffle/modules/Schema.ts similarity index 83% rename from tests/_/schemas/mutation-only/graffle/modules/SchemaIndex.ts rename to tests/_/schemas/mutation-only/graffle/modules/Schema.ts index 4f613d852..1f2a58047 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/SchemaIndex.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/Schema.ts @@ -4,7 +4,7 @@ import type * as Data from './Data.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as Schema from './SchemaBuildtime.js' -export interface Index { +export interface Index extends Utilities.SchemaIndexBase { name: Data.Name RootTypesPresent: ['Mutation'] RootUnion: Schema.Root.Mutation @@ -20,4 +20,5 @@ export interface Index { unions: {} interfaces: {} customScalars: Utilities.SchemaIndexBase['customScalars'] + extensions: Utilities.GlobalRegistry.TypeExtensions } diff --git a/tests/_/schemas/mutation-only/graffle/modules/SchemaCustomScalarIndex.ts b/tests/_/schemas/mutation-only/graffle/modules/SchemaCustomScalarIndex.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/_/schemas/mutation-only/graffle/modules/SchemaDrivenDataMap.ts b/tests/_/schemas/mutation-only/graffle/modules/SchemaDrivenDataMap.ts index fc088cbca..498788118 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/SchemaDrivenDataMap.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/SchemaDrivenDataMap.ts @@ -7,7 +7,7 @@ import * as $Scalar from './Scalar.js' // // // ================================================================================================== -// GraphQLScalarType +// GraphQLScalarTypeStandard // ================================================================================================== // // diff --git a/tests/_/schemas/mutation-only/graffle/modules/Select.ts b/tests/_/schemas/mutation-only/graffle/modules/Select.ts index 7928402a5..d7c192524 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/Select.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/Select.ts @@ -1,6 +1,6 @@ import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import * as Data from './Data.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' // diff --git a/tests/_/schemas/pokemon/graffle/modules/Global.ts b/tests/_/schemas/pokemon/graffle/modules/Global.ts index 6658c0d0a..96ba14cda 100644 --- a/tests/_/schemas/pokemon/graffle/modules/Global.ts +++ b/tests/_/schemas/pokemon/graffle/modules/Global.ts @@ -2,7 +2,7 @@ import type * as Data from './Data.js' import type * as MethodsDocument from './MethodsDocument.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as MethodsSelect from './MethodsSelect.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' declare global { export namespace GraffleGlobal { diff --git a/tests/_/schemas/pokemon/graffle/modules/MethodsDocument.ts b/tests/_/schemas/pokemon/graffle/modules/MethodsDocument.ts index 8843f754d..0a5043616 100644 --- a/tests/_/schemas/pokemon/graffle/modules/MethodsDocument.ts +++ b/tests/_/schemas/pokemon/graffle/modules/MethodsDocument.ts @@ -1,5 +1,5 @@ import type * as Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' export interface Document<$Config extends Utilities.Config> { diff --git a/tests/_/schemas/pokemon/graffle/modules/MethodsRoot.ts b/tests/_/schemas/pokemon/graffle/modules/MethodsRoot.ts index 426c01850..03563db57 100644 --- a/tests/_/schemas/pokemon/graffle/modules/MethodsRoot.ts +++ b/tests/_/schemas/pokemon/graffle/modules/MethodsRoot.ts @@ -1,7 +1,7 @@ import { type Simplify } from 'type-fest' import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import type * as Utils from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSet from './SelectionSets.js' export interface MutationMethods<$Config extends Utils.Config> { diff --git a/tests/_/schemas/pokemon/graffle/modules/Scalar.ts b/tests/_/schemas/pokemon/graffle/modules/Scalar.ts index 872cc54b5..026aa6405 100644 --- a/tests/_/schemas/pokemon/graffle/modules/Scalar.ts +++ b/tests/_/schemas/pokemon/graffle/modules/Scalar.ts @@ -1 +1,3 @@ +import type { SchemaKit } from '../../../../../../src/entrypoints/schema.js' + export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' diff --git a/tests/_/schemas/pokemon/graffle/modules/SchemaIndex.ts b/tests/_/schemas/pokemon/graffle/modules/Schema.ts similarity index 93% rename from tests/_/schemas/pokemon/graffle/modules/SchemaIndex.ts rename to tests/_/schemas/pokemon/graffle/modules/Schema.ts index f92620e85..d9f6a5fae 100644 --- a/tests/_/schemas/pokemon/graffle/modules/SchemaIndex.ts +++ b/tests/_/schemas/pokemon/graffle/modules/Schema.ts @@ -4,7 +4,7 @@ import type * as Data from './Data.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as Schema from './SchemaBuildtime.js' -export interface Index { +export interface Index extends Utilities.SchemaIndexBase { name: Data.Name RootTypesPresent: ['Mutation', 'Query'] RootUnion: Schema.Root.Mutation | Schema.Root.Query @@ -47,4 +47,5 @@ export interface Index { Being: Schema.Interface.Being } customScalars: Utilities.SchemaIndexBase['customScalars'] + extensions: Utilities.GlobalRegistry.TypeExtensions } diff --git a/tests/_/schemas/pokemon/graffle/modules/SchemaDrivenDataMap.ts b/tests/_/schemas/pokemon/graffle/modules/SchemaDrivenDataMap.ts index f64ea0fb7..f630ce24c 100644 --- a/tests/_/schemas/pokemon/graffle/modules/SchemaDrivenDataMap.ts +++ b/tests/_/schemas/pokemon/graffle/modules/SchemaDrivenDataMap.ts @@ -7,7 +7,7 @@ import * as $Scalar from './Scalar.js' // // // ================================================================================================== -// GraphQLScalarType +// GraphQLScalarTypeStandard // ================================================================================================== // // @@ -383,29 +383,29 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { // // -BattleRoyale.f['combatants']!.nt = CombatantMultiPokemon -BattleRoyale.f['winner']!.nt = Trainer -BattleTrainer.f['combatant1']!.nt = CombatantSinglePokemon -BattleTrainer.f['combatant2']!.nt = CombatantSinglePokemon -BattleTrainer.f['winner']!.nt = Trainer -BattleWild.f['pokemon']!.nt = Pokemon -BattleWild.f['trainer']!.nt = Trainer -BattleWild.f['wildPokemons']!.nt = Pokemon -CombatantMultiPokemon.f['pokemons']!.nt = Pokemon -CombatantMultiPokemon.f['trainer']!.nt = Trainer -CombatantSinglePokemon.f['pokemon']!.nt = Pokemon -CombatantSinglePokemon.f['trainer']!.nt = Trainer -Pokemon.f['trainer']!.nt = Trainer -Trainer.f['fans']!.nt = Patron -Trainer.f['pokemon']!.nt = Pokemon -Mutation.f['addPokemon']!.nt = Pokemon -Query.f['battles']!.nt = Battle -Query.f['beings']!.nt = Being -Query.f['pokemon']!.nt = Pokemon -Query.f['pokemonByName']!.nt = Pokemon -Query.f['pokemons']!.nt = Pokemon -Query.f['trainerByName']!.nt = Trainer -Query.f['trainers']!.nt = Trainer +BattleRoyale.f[`combatants`]!.nt = CombatantMultiPokemon +BattleRoyale.f[`winner`]!.nt = Trainer +BattleTrainer.f[`combatant1`]!.nt = CombatantSinglePokemon +BattleTrainer.f[`combatant2`]!.nt = CombatantSinglePokemon +BattleTrainer.f[`winner`]!.nt = Trainer +BattleWild.f[`pokemon`]!.nt = Pokemon +BattleWild.f[`trainer`]!.nt = Trainer +BattleWild.f[`wildPokemons`]!.nt = Pokemon +CombatantMultiPokemon.f[`pokemons`]!.nt = Pokemon +CombatantMultiPokemon.f[`trainer`]!.nt = Trainer +CombatantSinglePokemon.f[`pokemon`]!.nt = Pokemon +CombatantSinglePokemon.f[`trainer`]!.nt = Trainer +Pokemon.f[`trainer`]!.nt = Trainer +Trainer.f[`fans`]!.nt = Patron +Trainer.f[`pokemon`]!.nt = Pokemon +Mutation.f[`addPokemon`]!.nt = Pokemon +Query.f[`battles`]!.nt = Battle +Query.f[`beings`]!.nt = Being +Query.f[`pokemon`]!.nt = Pokemon +Query.f[`pokemonByName`]!.nt = Pokemon +Query.f[`pokemons`]!.nt = Pokemon +Query.f[`trainerByName`]!.nt = Trainer +Query.f[`trainers`]!.nt = Trainer // // diff --git a/tests/_/schemas/pokemon/graffle/modules/Select.ts b/tests/_/schemas/pokemon/graffle/modules/Select.ts index 003cccd98..9edf50469 100644 --- a/tests/_/schemas/pokemon/graffle/modules/Select.ts +++ b/tests/_/schemas/pokemon/graffle/modules/Select.ts @@ -1,6 +1,6 @@ import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import * as Data from './Data.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' // diff --git a/tests/_/schemas/query-only/graffle/modules/Global.ts b/tests/_/schemas/query-only/graffle/modules/Global.ts index 909da5e9c..1d1911178 100644 --- a/tests/_/schemas/query-only/graffle/modules/Global.ts +++ b/tests/_/schemas/query-only/graffle/modules/Global.ts @@ -2,7 +2,7 @@ import type * as Data from './Data.js' import type * as MethodsDocument from './MethodsDocument.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as MethodsSelect from './MethodsSelect.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' declare global { export namespace GraffleGlobal { @@ -16,7 +16,6 @@ declare global { Root: MethodsRoot.BuilderMethodsRootFn } customScalars: {} - defaultSchemaUrl: null } } diff --git a/tests/_/schemas/query-only/graffle/modules/MethodsDocument.ts b/tests/_/schemas/query-only/graffle/modules/MethodsDocument.ts index 8843f754d..0a5043616 100644 --- a/tests/_/schemas/query-only/graffle/modules/MethodsDocument.ts +++ b/tests/_/schemas/query-only/graffle/modules/MethodsDocument.ts @@ -1,5 +1,5 @@ import type * as Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' export interface Document<$Config extends Utilities.Config> { diff --git a/tests/_/schemas/query-only/graffle/modules/MethodsRoot.ts b/tests/_/schemas/query-only/graffle/modules/MethodsRoot.ts index c66883b51..5d5f42c16 100644 --- a/tests/_/schemas/query-only/graffle/modules/MethodsRoot.ts +++ b/tests/_/schemas/query-only/graffle/modules/MethodsRoot.ts @@ -1,7 +1,7 @@ import { type Simplify } from 'type-fest' import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import type * as Utils from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSet from './SelectionSets.js' export interface QueryMethods<$Config extends Utils.Config> { diff --git a/tests/_/schemas/query-only/graffle/modules/Scalar.ts b/tests/_/schemas/query-only/graffle/modules/Scalar.ts index 872cc54b5..026aa6405 100644 --- a/tests/_/schemas/query-only/graffle/modules/Scalar.ts +++ b/tests/_/schemas/query-only/graffle/modules/Scalar.ts @@ -1 +1,3 @@ +import type { SchemaKit } from '../../../../../../src/entrypoints/schema.js' + export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' diff --git a/tests/_/schemas/query-only/graffle/modules/SchemaIndex.ts b/tests/_/schemas/query-only/graffle/modules/Schema.ts similarity index 83% rename from tests/_/schemas/query-only/graffle/modules/SchemaIndex.ts rename to tests/_/schemas/query-only/graffle/modules/Schema.ts index 623acca69..faa849533 100644 --- a/tests/_/schemas/query-only/graffle/modules/SchemaIndex.ts +++ b/tests/_/schemas/query-only/graffle/modules/Schema.ts @@ -4,7 +4,7 @@ import type * as Data from './Data.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as Schema from './SchemaBuildtime.js' -export interface Index { +export interface Index extends Utilities.SchemaIndexBase { name: Data.Name RootTypesPresent: ['Query'] RootUnion: Schema.Root.Query @@ -20,4 +20,5 @@ export interface Index { unions: {} interfaces: {} customScalars: Utilities.SchemaIndexBase['customScalars'] + extensions: Utilities.GlobalRegistry.TypeExtensions } diff --git a/tests/_/schemas/query-only/graffle/modules/SchemaCustomScalarIndex.ts b/tests/_/schemas/query-only/graffle/modules/SchemaCustomScalarIndex.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/_/schemas/query-only/graffle/modules/SchemaDrivenDataMap.ts b/tests/_/schemas/query-only/graffle/modules/SchemaDrivenDataMap.ts index c3810c9a0..e4677d2d6 100644 --- a/tests/_/schemas/query-only/graffle/modules/SchemaDrivenDataMap.ts +++ b/tests/_/schemas/query-only/graffle/modules/SchemaDrivenDataMap.ts @@ -7,7 +7,7 @@ import * as $Scalar from './Scalar.js' // // // ================================================================================================== -// GraphQLScalarType +// GraphQLScalarTypeStandard // ================================================================================================== // // diff --git a/tests/_/schemas/query-only/graffle/modules/Select.ts b/tests/_/schemas/query-only/graffle/modules/Select.ts index fc58b655f..c6b3eb59c 100644 --- a/tests/_/schemas/query-only/graffle/modules/Select.ts +++ b/tests/_/schemas/query-only/graffle/modules/Select.ts @@ -1,6 +1,6 @@ import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import * as Data from './Data.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' // diff --git a/tsconfig.build.json b/tsconfig.build.json index 321b962af..edd539dad 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -5,5 +5,5 @@ "rootDir": "src" }, "include": ["src"], - "exclude": ["**/*.test.*", "**/*.spec.*", "**/*.test-d.ts"] + "exclude": ["**/*.test.*", "**/*.spec.*", "**/*.test-d.ts", "**/tests/**/*"] } diff --git a/website/graffle/_.ts b/website/graffle/_.ts index d5cdf0031..d27e9e3d3 100644 --- a/website/graffle/_.ts +++ b/website/graffle/_.ts @@ -5,5 +5,6 @@ import './modules/Global.js' export { create } from './modules/Client.js' +export { schemaDrivenDataMap } from './modules/SchemaDrivenDataMap.js' export { Select } from './modules/Select.js' export * as SelectionSets from './modules/SelectionSets.js' diff --git a/website/graffle/modules/Client.ts b/website/graffle/modules/Client.ts index f3787e620..d6d0b8bf6 100644 --- a/website/graffle/modules/Client.ts +++ b/website/graffle/modules/Client.ts @@ -1,5 +1,6 @@ import { createPrefilled } from 'graffle/client' import { defaultSchemaUrl } from './Data.js' +import { Name } from './Data.js' import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' -export const create = createPrefilled(`default`, schemaDrivenDataMap, defaultSchemaUrl) +export const create = createPrefilled(Name, schemaDrivenDataMap, defaultSchemaUrl) diff --git a/website/graffle/modules/Data.ts b/website/graffle/modules/Data.ts index b5ecc3ae6..ef2ad4cf6 100644 --- a/website/graffle/modules/Data.ts +++ b/website/graffle/modules/Data.ts @@ -1,4 +1,4 @@ export const Name = `default` export type Name = 'default' -export const defaultSchemaUrl = new URL('https://countries.trevorblades.com/graphql') +export const defaultSchemaUrl = undefined diff --git a/website/graffle/modules/Global.ts b/website/graffle/modules/Global.ts index dda7d345c..3eb2458de 100644 --- a/website/graffle/modules/Global.ts +++ b/website/graffle/modules/Global.ts @@ -2,7 +2,7 @@ import type * as Data from './Data.js' import type * as MethodsDocument from './MethodsDocument.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as MethodsSelect from './MethodsSelect.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' declare global { export namespace GraffleGlobal { @@ -16,11 +16,7 @@ declare global { Root: MethodsRoot.BuilderMethodsRootFn } customScalars: {} - - /** - * https://countries.trevorblades.com/graphql - */ - defaultSchemaUrl: string + defaultSchemaUrl: null } } } diff --git a/website/graffle/modules/MethodsDocument.ts b/website/graffle/modules/MethodsDocument.ts index 9b6e948e3..bf98b2fcc 100644 --- a/website/graffle/modules/MethodsDocument.ts +++ b/website/graffle/modules/MethodsDocument.ts @@ -1,5 +1,5 @@ import type * as Utilities from 'graffle/utilities-for-generated' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' export interface Document<$Config extends Utilities.Config> { diff --git a/website/graffle/modules/MethodsRoot.ts b/website/graffle/modules/MethodsRoot.ts index 18bdf6c29..869467d93 100644 --- a/website/graffle/modules/MethodsRoot.ts +++ b/website/graffle/modules/MethodsRoot.ts @@ -1,7 +1,7 @@ import type { InferResult } from 'graffle/schema' import type * as Utils from 'graffle/utilities-for-generated' import { type Simplify } from 'type-fest' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSet from './SelectionSets.js' export interface QueryMethods<$Config extends Utils.Config> { diff --git a/website/graffle/modules/Scalar.ts b/website/graffle/modules/Scalar.ts index 5c8ae1f9f..0e97de641 100644 --- a/website/graffle/modules/Scalar.ts +++ b/website/graffle/modules/Scalar.ts @@ -1 +1,3 @@ +import type { SchemaKit } from 'graffle/schema' + export * from 'graffle/schema/scalars' diff --git a/website/graffle/modules/SchemaIndex.ts b/website/graffle/modules/Schema.ts similarity index 84% rename from website/graffle/modules/SchemaIndex.ts rename to website/graffle/modules/Schema.ts index 7698bf60a..f1aebf196 100644 --- a/website/graffle/modules/SchemaIndex.ts +++ b/website/graffle/modules/Schema.ts @@ -4,7 +4,7 @@ import type * as Data from './Data.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as Schema from './SchemaBuildtime.js' -export interface Index { +export interface Index extends Utilities.SchemaIndexBase { name: Data.Name RootTypesPresent: ['Query'] RootUnion: Schema.Root.Query @@ -31,13 +31,5 @@ export interface Index { unions: {} interfaces: {} customScalars: Utilities.SchemaIndexBase['customScalars'] - error: { - objects: {} - objectsTypename: {} - rootResultFields: { - Mutation: {} - Subscription: {} - Query: {} - } - } + extensions: Utilities.GlobalRegistry.TypeExtensions } diff --git a/website/graffle/modules/SchemaDrivenDataMap.ts b/website/graffle/modules/SchemaDrivenDataMap.ts index e74ea7a38..510e94d9c 100644 --- a/website/graffle/modules/SchemaDrivenDataMap.ts +++ b/website/graffle/modules/SchemaDrivenDataMap.ts @@ -7,7 +7,7 @@ import * as $Scalar from './Scalar.js' // // // ================================================================================================== -// GraphQLScalarType +// GraphQLScalarTypeStandard // ================================================================================================== // // @@ -16,11 +16,15 @@ import * as $Scalar from './Scalar.js' // // +const Boolean = $Scalar.Boolean + +const Float = $Scalar.Float + const ID = $Scalar.ID -const String = $Scalar.String +const Int = $Scalar.Int -const Boolean = $Scalar.Boolean +const String = $Scalar.String // // @@ -325,18 +329,18 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { // // -Continent.f['countries']!.nt = Country -Country.f['continent']!.nt = Continent -Country.f['languages']!.nt = Language -Country.f['states']!.nt = State -Country.f['subdivisions']!.nt = Subdivision -State.f['country']!.nt = Country -Query.f['continent']!.nt = Continent -Query.f['continents']!.nt = Continent -Query.f['countries']!.nt = Country -Query.f['country']!.nt = Country -Query.f['language']!.nt = Language -Query.f['languages']!.nt = Language +Continent.f[`countries`]!.nt = Country +Country.f[`continent`]!.nt = Continent +Country.f[`languages`]!.nt = Language +Country.f[`states`]!.nt = State +Country.f[`subdivisions`]!.nt = Subdivision +State.f[`country`]!.nt = Country +Query.f[`continent`]!.nt = Continent +Query.f[`continents`]!.nt = Continent +Query.f[`countries`]!.nt = Country +Query.f[`country`]!.nt = Country +Query.f[`language`]!.nt = Language +Query.f[`languages`]!.nt = Language // // @@ -360,9 +364,11 @@ const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { }, directives: {}, types: { + Boolean, + Float, ID, + Int, String, - Boolean, ContinentFilterInput, CountryFilterInput, LanguageFilterInput, diff --git a/website/graffle/modules/Select.ts b/website/graffle/modules/Select.ts index 07fffdbe0..c389f1eed 100644 --- a/website/graffle/modules/Select.ts +++ b/website/graffle/modules/Select.ts @@ -1,6 +1,6 @@ import type { InferResult } from 'graffle/schema' import * as Data from './Data.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' // diff --git a/website/package.json b/website/package.json index 3b6c3fc9f..53b9fbae8 100644 --- a/website/package.json +++ b/website/package.json @@ -4,7 +4,7 @@ "dev": "vitepress dev", "build": "vitepress build", "preview": "vitepress preview", - "gen:graffle": "graffle --schema https://countries.trevorblades.com/graphql && graffle --defaultSchemaUrl http://localhost:3000/graphql --schema ../tests/_/schemas/pokemon/schema.graphql --name Pokemon --output ./pokemon" + "gen:graffle": "graffle --schema https://countries.trevorblades.com/graphql && graffle --defaultSchemaUrl http://localhost:3000/graphql --schema ../tests/_/schemas/pokemon/graffle/schema.graphql --name Pokemon --output ./pokemon" }, "devDependencies": { "vitepress": "^1.3.4" diff --git a/website/pokemon/_.ts b/website/pokemon/_.ts index d5cdf0031..d27e9e3d3 100644 --- a/website/pokemon/_.ts +++ b/website/pokemon/_.ts @@ -5,5 +5,6 @@ import './modules/Global.js' export { create } from './modules/Client.js' +export { schemaDrivenDataMap } from './modules/SchemaDrivenDataMap.js' export { Select } from './modules/Select.js' export * as SelectionSets from './modules/SelectionSets.js' diff --git a/website/pokemon/modules/Client.ts b/website/pokemon/modules/Client.ts index f7ddfba99..d6d0b8bf6 100644 --- a/website/pokemon/modules/Client.ts +++ b/website/pokemon/modules/Client.ts @@ -1,5 +1,6 @@ import { createPrefilled } from 'graffle/client' import { defaultSchemaUrl } from './Data.js' +import { Name } from './Data.js' import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' -export const create = createPrefilled(`Pokemon`, schemaDrivenDataMap, defaultSchemaUrl) +export const create = createPrefilled(Name, schemaDrivenDataMap, defaultSchemaUrl) diff --git a/website/pokemon/modules/Global.ts b/website/pokemon/modules/Global.ts index 6658c0d0a..96ba14cda 100644 --- a/website/pokemon/modules/Global.ts +++ b/website/pokemon/modules/Global.ts @@ -2,7 +2,7 @@ import type * as Data from './Data.js' import type * as MethodsDocument from './MethodsDocument.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as MethodsSelect from './MethodsSelect.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' declare global { export namespace GraffleGlobal { diff --git a/website/pokemon/modules/MethodsDocument.ts b/website/pokemon/modules/MethodsDocument.ts index 9b6e948e3..bf98b2fcc 100644 --- a/website/pokemon/modules/MethodsDocument.ts +++ b/website/pokemon/modules/MethodsDocument.ts @@ -1,5 +1,5 @@ import type * as Utilities from 'graffle/utilities-for-generated' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' export interface Document<$Config extends Utilities.Config> { diff --git a/website/pokemon/modules/MethodsRoot.ts b/website/pokemon/modules/MethodsRoot.ts index 8f74eae95..9ded9e54b 100644 --- a/website/pokemon/modules/MethodsRoot.ts +++ b/website/pokemon/modules/MethodsRoot.ts @@ -1,7 +1,7 @@ import type { InferResult } from 'graffle/schema' import type * as Utils from 'graffle/utilities-for-generated' import { type Simplify } from 'type-fest' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSet from './SelectionSets.js' export interface MutationMethods<$Config extends Utils.Config> { diff --git a/website/pokemon/modules/Scalar.ts b/website/pokemon/modules/Scalar.ts index 5c8ae1f9f..0e97de641 100644 --- a/website/pokemon/modules/Scalar.ts +++ b/website/pokemon/modules/Scalar.ts @@ -1 +1,3 @@ +import type { SchemaKit } from 'graffle/schema' + export * from 'graffle/schema/scalars' diff --git a/website/pokemon/modules/SchemaIndex.ts b/website/pokemon/modules/Schema.ts similarity index 90% rename from website/pokemon/modules/SchemaIndex.ts rename to website/pokemon/modules/Schema.ts index df7d5b1c3..8e261fd92 100644 --- a/website/pokemon/modules/SchemaIndex.ts +++ b/website/pokemon/modules/Schema.ts @@ -4,7 +4,7 @@ import type * as Data from './Data.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as Schema from './SchemaBuildtime.js' -export interface Index { +export interface Index extends Utilities.SchemaIndexBase { name: Data.Name RootTypesPresent: ['Mutation', 'Query'] RootUnion: Schema.Root.Mutation | Schema.Root.Query @@ -47,13 +47,5 @@ export interface Index { Being: Schema.Interface.Being } customScalars: Utilities.SchemaIndexBase['customScalars'] - error: { - objects: {} - objectsTypename: {} - rootResultFields: { - Subscription: {} - Mutation: {} - Query: {} - } - } + extensions: Utilities.GlobalRegistry.TypeExtensions } diff --git a/website/pokemon/modules/SchemaCustomScalarIndex.ts b/website/pokemon/modules/SchemaCustomScalarIndex.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/website/pokemon/modules/SchemaDrivenDataMap.ts b/website/pokemon/modules/SchemaDrivenDataMap.ts index 68e3ac4ae..497855dea 100644 --- a/website/pokemon/modules/SchemaDrivenDataMap.ts +++ b/website/pokemon/modules/SchemaDrivenDataMap.ts @@ -7,7 +7,7 @@ import * as $Scalar from './Scalar.js' // // // ================================================================================================== -// GraphQLScalarType +// GraphQLScalarTypeStandard // ================================================================================================== // // @@ -383,29 +383,29 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { // // -BattleRoyale.f['combatants']!.nt = CombatantMultiPokemon -BattleRoyale.f['winner']!.nt = Trainer -BattleTrainer.f['combatant1']!.nt = CombatantSinglePokemon -BattleTrainer.f['combatant2']!.nt = CombatantSinglePokemon -BattleTrainer.f['winner']!.nt = Trainer -BattleWild.f['pokemon']!.nt = Pokemon -BattleWild.f['trainer']!.nt = Trainer -BattleWild.f['wildPokemons']!.nt = Pokemon -CombatantMultiPokemon.f['pokemons']!.nt = Pokemon -CombatantMultiPokemon.f['trainer']!.nt = Trainer -CombatantSinglePokemon.f['pokemon']!.nt = Pokemon -CombatantSinglePokemon.f['trainer']!.nt = Trainer -Pokemon.f['trainer']!.nt = Trainer -Trainer.f['fans']!.nt = Patron -Trainer.f['pokemon']!.nt = Pokemon -Mutation.f['addPokemon']!.nt = Pokemon -Query.f['battles']!.nt = Battle -Query.f['beings']!.nt = Being -Query.f['pokemon']!.nt = Pokemon -Query.f['pokemonByName']!.nt = Pokemon -Query.f['pokemons']!.nt = Pokemon -Query.f['trainerByName']!.nt = Trainer -Query.f['trainers']!.nt = Trainer +BattleRoyale.f[`combatants`]!.nt = CombatantMultiPokemon +BattleRoyale.f[`winner`]!.nt = Trainer +BattleTrainer.f[`combatant1`]!.nt = CombatantSinglePokemon +BattleTrainer.f[`combatant2`]!.nt = CombatantSinglePokemon +BattleTrainer.f[`winner`]!.nt = Trainer +BattleWild.f[`pokemon`]!.nt = Pokemon +BattleWild.f[`trainer`]!.nt = Trainer +BattleWild.f[`wildPokemons`]!.nt = Pokemon +CombatantMultiPokemon.f[`pokemons`]!.nt = Pokemon +CombatantMultiPokemon.f[`trainer`]!.nt = Trainer +CombatantSinglePokemon.f[`pokemon`]!.nt = Pokemon +CombatantSinglePokemon.f[`trainer`]!.nt = Trainer +Pokemon.f[`trainer`]!.nt = Trainer +Trainer.f[`fans`]!.nt = Patron +Trainer.f[`pokemon`]!.nt = Pokemon +Mutation.f[`addPokemon`]!.nt = Pokemon +Query.f[`battles`]!.nt = Battle +Query.f[`beings`]!.nt = Being +Query.f[`pokemon`]!.nt = Pokemon +Query.f[`pokemonByName`]!.nt = Pokemon +Query.f[`pokemons`]!.nt = Pokemon +Query.f[`trainerByName`]!.nt = Trainer +Query.f[`trainers`]!.nt = Trainer // // diff --git a/website/pokemon/modules/Select.ts b/website/pokemon/modules/Select.ts index a62459532..b1730a60e 100644 --- a/website/pokemon/modules/Select.ts +++ b/website/pokemon/modules/Select.ts @@ -1,6 +1,6 @@ import type { InferResult } from 'graffle/schema' import * as Data from './Data.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' // From bd10b762714fbd3e6780ffdae820e25ec0a08139 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Fri, 18 Oct 2024 10:45:56 -0400 Subject: [PATCH 4/8] unit tests --- src/layers/4_generator/config/config.test.ts | 4 +- .../__snapshots__/generate.test.ts.snap | 265 ++++++++---------- 2 files changed, 125 insertions(+), 144 deletions(-) diff --git a/src/layers/4_generator/config/config.test.ts b/src/layers/4_generator/config/config.test.ts index 0274433d2..dea1b0564 100644 --- a/src/layers/4_generator/config/config.test.ts +++ b/src/layers/4_generator/config/config.test.ts @@ -6,7 +6,7 @@ test(`can load schema from custom path`, async () => { const customPathFile = `./tests/_/fixtures/custom.graphql` const config = await createConfig({ schema: { type: `sdl`, dirOrFilePath: customPathFile } }) const field = config.schema.instance.getQueryType()?.getFields()[`customNamedSchemaFile`] - expect(config.paths.project.inputs.schema).toEqual(customPathFile) + expect(config.paths.project.inputs.schema).match(new RegExp(customPathFile + `$`)) expect(config.schema.sdl).toMatchSnapshot() expect(field).toBeDefined() }) @@ -15,7 +15,7 @@ test(`can load schema from custom dir using default file name`, async () => { const customPathDir = `tests/_/fixtures` const config = await createConfig({ schema: { type: `sdl`, dirOrFilePath: customPathDir } }) const field = config.schema.instance.getQueryType()?.getFields()[`defaultNamedSchemaFile`] - expect(config.paths.project.inputs.schema).toEqual(customPathDir + `/schema.graphql`) + expect(config.paths.project.inputs.schema).match(new RegExp(customPathDir + `/schema.graphql$`)) expect(config.schema.sdl).toMatchSnapshot() expect(field).toBeDefined() }) diff --git a/src/layers/4_generator/generator/__snapshots__/generate.test.ts.snap b/src/layers/4_generator/generator/__snapshots__/generate.test.ts.snap index 28b56aa2c..bd35a2396 100644 --- a/src/layers/4_generator/generator/__snapshots__/generate.test.ts.snap +++ b/src/layers/4_generator/generator/__snapshots__/generate.test.ts.snap @@ -8,6 +8,7 @@ exports[`kitchen-sink generated modules > _.ts 1`] = ` import './modules/Global.js' export { create } from './modules/Client.js' +export { schemaDrivenDataMap } from './modules/SchemaDrivenDataMap.js' export { Select } from './modules/Select.js' export * as SelectionSets from './modules/SelectionSets.js' " @@ -21,9 +22,10 @@ exports[`kitchen-sink generated modules > __.ts 1`] = ` exports[`kitchen-sink generated modules > modules/Client.ts 1`] = ` "import { createPrefilled } from '../../../../../../src/entrypoints/client.js' import { defaultSchemaUrl } from './Data.js' +import { Name } from './Data.js' import { schemaDrivenDataMap } from './SchemaDrivenDataMap.js' -export const create = createPrefilled(\`default\`, schemaDrivenDataMap, defaultSchemaUrl) +export const create = createPrefilled(Name, schemaDrivenDataMap, defaultSchemaUrl) " `; @@ -41,10 +43,10 @@ import type * as MethodsDocument from './MethodsDocument.js' import type * as MethodsRoot from './MethodsRoot.js' import type * as MethodsSelect from './MethodsSelect.js' import type * as Scalar from './Scalar.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' declare global { - export namespace GraffleGlobalTypes { + export namespace GraffleGlobal { export interface Schemas { default: { name: Data.Name @@ -57,7 +59,6 @@ declare global { customScalars: { Date: Scalar.Date } - defaultSchemaUrl: null } } @@ -68,7 +69,7 @@ declare global { exports[`kitchen-sink generated modules > modules/MethodsDocument.ts 1`] = ` "import type * as Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' export interface Document<$Config extends Utilities.Config> { @@ -92,7 +93,7 @@ exports[`kitchen-sink generated modules > modules/MethodsRoot.ts 1`] = ` "import { type Simplify } from 'type-fest' import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import type * as Utils from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSet from './SelectionSets.js' export interface MutationMethods<$Config extends Utils.Config> { @@ -881,13 +882,12 @@ export interface Interface { `; exports[`kitchen-sink generated modules > modules/Scalar.ts 1`] = ` -"import type { Schema } from '../../../../../../src/entrypoints/schema.js' -import * as CustomScalars from '../../../../customScalarCodecs.js' +"import type { SchemaKit } from '../../../../../../src/entrypoints/schema.js' -export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' -export * from '../../../../customScalarCodecs.js' -export { Date } from '../../../../customScalarCodecs.js' +import * as CustomScalars from '../../customScalarCodecs.js' +export * from '../../customScalarCodecs.js' +export { Date } from '../../customScalarCodecs.js' // // // @@ -904,8 +904,84 @@ export type Date = typeof CustomScalars.Date // Without this we get error: // "Exported type alias 'DateDecoded' has or is using private name 'Date'." type Date_ = typeof CustomScalars.Date -export type DateDecoded = Schema.Scalar.GetDecoded -export type DateEncoded = Schema.Scalar.GetEncoded +export type DateDecoded = SchemaKit.Scalar.GetDecoded +export type DateEncoded = SchemaKit.Scalar.GetEncoded + +export * from '../../../../../../src/layers/1_Schema/Hybrid/types/Scalar/Scalar.js' +" +`; + +exports[`kitchen-sink generated modules > modules/Schema.ts 1`] = ` +"/* eslint-disable */ +import type * as Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' +import type * as Data from './Data.js' +import type * as MethodsRoot from './MethodsRoot.js' +import type * as Schema from './SchemaBuildtime.js' + +export interface Index extends Utilities.SchemaIndexBase { + name: Data.Name + RootTypesPresent: ['Mutation', 'Query'] + RootUnion: Schema.Root.Mutation | Schema.Root.Query + Root: { + Query: Schema.Root.Query + Mutation: Schema.Root.Mutation + Subscription: null + } + allTypes: { + Mutation: Schema.Root.Mutation + Query: Schema.Root.Query + ABCEnum: Schema.Enum.ABCEnum + Case: Schema.Enum.Case + Bar: Schema.Object.Bar + DateObject1: Schema.Object.DateObject1 + DateObject2: Schema.Object.DateObject2 + ErrorOne: Schema.Object.ErrorOne + ErrorTwo: Schema.Object.ErrorTwo + Foo: Schema.Object.Foo + Object1: Schema.Object.Object1 + Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface + Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface + ObjectNested: Schema.Object.ObjectNested + ObjectUnion: Schema.Object.ObjectUnion + lowerCaseObject: Schema.Object.lowerCaseObject + lowerCaseObject2: Schema.Object.lowerCaseObject2 + DateUnion: Schema.Union.DateUnion + FooBarUnion: Schema.Union.FooBarUnion + Result: Schema.Union.Result + lowerCaseUnion: Schema.Union.lowerCaseUnion + DateInterface1: Schema.Interface.DateInterface1 + Error: Schema.Interface.Error + Interface: Schema.Interface.Interface + } + objects: { + Bar: Schema.Object.Bar + DateObject1: Schema.Object.DateObject1 + DateObject2: Schema.Object.DateObject2 + ErrorOne: Schema.Object.ErrorOne + ErrorTwo: Schema.Object.ErrorTwo + Foo: Schema.Object.Foo + Object1: Schema.Object.Object1 + Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface + Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface + ObjectNested: Schema.Object.ObjectNested + ObjectUnion: Schema.Object.ObjectUnion + lowerCaseObject: Schema.Object.lowerCaseObject + lowerCaseObject2: Schema.Object.lowerCaseObject2 + } + unions: { + DateUnion: Schema.Union.DateUnion + FooBarUnion: Schema.Union.FooBarUnion + Result: Schema.Union.Result + lowerCaseUnion: Schema.Union.lowerCaseUnion + } + interfaces: { + DateInterface1: Schema.Interface.DateInterface1 + Error: Schema.Interface.Error + Interface: Schema.Interface.Interface + } + customScalars: Utilities.SchemaIndexBase['customScalars'] + extensions: Utilities.GlobalRegistry.TypeExtensions +} " `; @@ -1282,7 +1358,7 @@ import * as $Scalar from './Scalar.js' // // // ================================================================================================== -// GraphQLScalarType +// GraphQLScalarTypeStandard // ================================================================================================== // // @@ -1291,15 +1367,15 @@ import * as $Scalar from './Scalar.js' // // -const Int = $Scalar.Int +const Boolean = $Scalar.Boolean -const String = $Scalar.String +const Float = $Scalar.Float const ID = $Scalar.ID -const Boolean = $Scalar.Boolean +const Int = $Scalar.Int -const Float = $Scalar.Float +const String = $Scalar.String // // @@ -1448,7 +1524,6 @@ const DateObject2: $Utilities.SchemaDrivenDataMap.OutputObject = { } const ErrorOne: $Utilities.SchemaDrivenDataMap.OutputObject = { - e: 1, f: { infoId: {}, message: {}, @@ -1456,7 +1531,6 @@ const ErrorOne: $Utilities.SchemaDrivenDataMap.OutputObject = { } const ErrorTwo: $Utilities.SchemaDrivenDataMap.OutputObject = { - e: 1, f: { infoInt: {}, message: {}, @@ -1794,7 +1868,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [1], }, }, - r: 1, // nt: Result, <-- Assigned later to avoid potential circular dependency. }, resultNonNull: { @@ -1804,7 +1877,6 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { it: [0], }, }, - r: 1, // nt: Result, <-- Assigned later to avoid potential circular dependency. }, string: {}, @@ -1921,31 +1993,31 @@ const Query: $Utilities.SchemaDrivenDataMap.OutputObject = { // // -InputObjectCircular.f!['circular']!.nt = InputObjectCircular -InputObjectNested.f!['InputObject']!.nt = InputObject -InputObjectNestedNonNull.f!['InputObject']!.nt = InputObject -ObjectNested.f['object']!.nt = Object1 -ObjectUnion.f['fooBarUnion']!.nt = FooBarUnion -Query.f['dateInterface1']!.nt = DateInterface1 -Query.f['dateObject1']!.nt = DateObject1 -Query.f['dateUnion']!.nt = DateUnion -Query.f['interface']!.nt = Interface -Query.f['interfaceNonNull']!.nt = Interface -Query.f['interfaceWithArgs']!.nt = Interface -Query.f['lowerCaseUnion']!.nt = lowerCaseUnion -Query.f['object']!.nt = Object1 -Query.f['objectList']!.nt = Object1 -Query.f['objectListNonNull']!.nt = Object1 -Query.f['objectNested']!.nt = ObjectNested -Query.f['objectNonNull']!.nt = Object1 -Query.f['objectWithArgs']!.nt = Object1 -Query.f['result']!.nt = Result -Query.f['resultNonNull']!.nt = Result -Query.f['unionFooBar']!.nt = FooBarUnion -Query.f['unionFooBarNonNull']!.nt = FooBarUnion -Query.f['unionFooBarWithArgs']!.nt = FooBarUnion -Query.f['unionObject']!.nt = ObjectUnion -Query.f['unionObjectNonNull']!.nt = ObjectUnion +InputObjectCircular.f![\`circular\`]!.nt = InputObjectCircular +InputObjectNested.f![\`InputObject\`]!.nt = InputObject +InputObjectNestedNonNull.f![\`InputObject\`]!.nt = InputObject +ObjectNested.f[\`object\`]!.nt = Object1 +ObjectUnion.f[\`fooBarUnion\`]!.nt = FooBarUnion +Query.f[\`dateInterface1\`]!.nt = DateInterface1 +Query.f[\`dateObject1\`]!.nt = DateObject1 +Query.f[\`dateUnion\`]!.nt = DateUnion +Query.f[\`interface\`]!.nt = Interface +Query.f[\`interfaceNonNull\`]!.nt = Interface +Query.f[\`interfaceWithArgs\`]!.nt = Interface +Query.f[\`lowerCaseUnion\`]!.nt = lowerCaseUnion +Query.f[\`object\`]!.nt = Object1 +Query.f[\`objectList\`]!.nt = Object1 +Query.f[\`objectListNonNull\`]!.nt = Object1 +Query.f[\`objectNested\`]!.nt = ObjectNested +Query.f[\`objectNonNull\`]!.nt = Object1 +Query.f[\`objectWithArgs\`]!.nt = Object1 +Query.f[\`result\`]!.nt = Result +Query.f[\`resultNonNull\`]!.nt = Result +Query.f[\`unionFooBar\`]!.nt = FooBarUnion +Query.f[\`unionFooBarNonNull\`]!.nt = FooBarUnion +Query.f[\`unionFooBarWithArgs\`]!.nt = FooBarUnion +Query.f[\`unionObject\`]!.nt = ObjectUnion +Query.f[\`unionObjectNonNull\`]!.nt = ObjectUnion // // @@ -1970,11 +2042,11 @@ const $schemaDrivenDataMap: $Utilities.SchemaDrivenDataMap = { }, directives: {}, types: { - Int, - String, - ID, Boolean, Float, + ID, + Int, + String, Date, ABCEnum, Case, @@ -2011,101 +2083,10 @@ export { $schemaDrivenDataMap as schemaDrivenDataMap } " `; -exports[`kitchen-sink generated modules > modules/SchemaIndex.ts 1`] = ` -"/* eslint-disable */ -import type * as Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -import type * as Data from './Data.js' -import type * as MethodsRoot from './MethodsRoot.js' -import type * as Schema from './SchemaBuildtime.js' - -export interface Index { - name: Data.Name - RootTypesPresent: ['Mutation', 'Query'] - RootUnion: Schema.Root.Mutation | Schema.Root.Query - Root: { - Query: Schema.Root.Query - Mutation: Schema.Root.Mutation - Subscription: null - } - allTypes: { - Mutation: Schema.Root.Mutation - Query: Schema.Root.Query - ABCEnum: Schema.Enum.ABCEnum - Case: Schema.Enum.Case - Bar: Schema.Object.Bar - DateObject1: Schema.Object.DateObject1 - DateObject2: Schema.Object.DateObject2 - ErrorOne: Schema.Object.ErrorOne - ErrorTwo: Schema.Object.ErrorTwo - Foo: Schema.Object.Foo - Object1: Schema.Object.Object1 - Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface - Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface - ObjectNested: Schema.Object.ObjectNested - ObjectUnion: Schema.Object.ObjectUnion - lowerCaseObject: Schema.Object.lowerCaseObject - lowerCaseObject2: Schema.Object.lowerCaseObject2 - DateUnion: Schema.Union.DateUnion - FooBarUnion: Schema.Union.FooBarUnion - Result: Schema.Union.Result - lowerCaseUnion: Schema.Union.lowerCaseUnion - DateInterface1: Schema.Interface.DateInterface1 - Error: Schema.Interface.Error - Interface: Schema.Interface.Interface - } - objects: { - Bar: Schema.Object.Bar - DateObject1: Schema.Object.DateObject1 - DateObject2: Schema.Object.DateObject2 - ErrorOne: Schema.Object.ErrorOne - ErrorTwo: Schema.Object.ErrorTwo - Foo: Schema.Object.Foo - Object1: Schema.Object.Object1 - Object1ImplementingInterface: Schema.Object.Object1ImplementingInterface - Object2ImplementingInterface: Schema.Object.Object2ImplementingInterface - ObjectNested: Schema.Object.ObjectNested - ObjectUnion: Schema.Object.ObjectUnion - lowerCaseObject: Schema.Object.lowerCaseObject - lowerCaseObject2: Schema.Object.lowerCaseObject2 - } - unions: { - DateUnion: Schema.Union.DateUnion - FooBarUnion: Schema.Union.FooBarUnion - Result: Schema.Union.Result - lowerCaseUnion: Schema.Union.lowerCaseUnion - } - interfaces: { - DateInterface1: Schema.Interface.DateInterface1 - Error: Schema.Interface.Error - Interface: Schema.Interface.Interface - } - customScalars: Utilities.SchemaIndexBase['customScalars'] - error: { - objects: { - ErrorOne: Schema.Object.ErrorOne - ErrorTwo: Schema.Object.ErrorTwo - } - objectsTypename: { - ErrorOne: { __typename: 'ErrorOne' } - ErrorTwo: { __typename: 'ErrorTwo' } - } - rootResultFields: { - Subscription: {} - Mutation: {} - Query: { - result: 'result' - resultNonNull: 'resultNonNull' - } - } - } -} -" -`; - exports[`kitchen-sink generated modules > modules/Select.ts 1`] = ` "import type { InferResult } from '../../../../../../src/entrypoints/schema.js' import * as Data from './Data.js' -import type { Index } from './SchemaIndex.js' +import type { Index } from './Schema.js' import type * as SelectionSets from './SelectionSets.js' // From 7ff9b2aad4b38009c203cb38f370df6410fbae3c Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Fri, 18 Oct 2024 10:57:23 -0400 Subject: [PATCH 5/8] lint --- eslint.config.js | 1 + .../tests/fixture/graffle/modules/Scalar.ts | 8 +++-- .../1_Schema/Hybrid/types/Scalar/Scalar.ts | 2 +- src/layers/4_generator/generators/Scalar.ts | 30 +++++++++---------- src/layers/4_generator/globalRegistry.ts | 2 +- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 66553538a..325d4796f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -9,6 +9,7 @@ export default tsEslint.config({ 'vitest*.config.ts', '**/generated/**/*', 'tests/_/schemas/*/graffle/**/*', + '**/tests/fixture/graffle/**/*', '**/$/**/*', 'legacy/**/*', 'build/**/*', diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts index 52ae32101..2bb4e2c5d 100644 --- a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts @@ -1,5 +1,7 @@ import type { SchemaKit } from '../../../../../../entrypoints/schema.js' +export * from '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' + // // // @@ -12,8 +14,8 @@ import type { SchemaKit } from '../../../../../../entrypoints/schema.js' // // -export type DateDecoded = SchemaKit.Scalar.GetDecoded -export type DateEncoded = SchemaKit.Scalar.GetEncoded +import type { String as Date } from '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' export { String as Date } from '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' -export * from '../../../../../../layers/1_Schema/Hybrid/types/Scalar/Scalar.js' +export type DateDecoded = SchemaKit.Scalar.GetDecoded +export type DateEncoded = SchemaKit.Scalar.GetEncoded diff --git a/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts b/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts index e4fcb96f2..833799d83 100644 --- a/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts +++ b/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts @@ -1,3 +1,4 @@ +/* eslint-disable */ import type { GlobalRegistry } from '../../../../4_generator/globalRegistry.js' import type { Codec, Mapper } from './codec.js' import { JavaScriptScalarCodecs } from './nativeScalarCodecs.js' @@ -106,7 +107,6 @@ export type $Any = | Boolean | ID | Float - // eslint-disable-next-line | Values type Values = T extends any ? keyof T extends never ? never : T[keyof T] : never diff --git a/src/layers/4_generator/generators/Scalar.ts b/src/layers/4_generator/generators/Scalar.ts index 60d122ebf..3d849430c 100644 --- a/src/layers/4_generator/generators/Scalar.ts +++ b/src/layers/4_generator/generators/Scalar.ts @@ -36,30 +36,28 @@ export const ModuleGeneratorScalar = createModuleGenerator( code(`export type ${scalar.name}Encoded = SchemaKit.Scalar.GetEncoded<${scalar.name}_>`) code() } - } else { - for (const scalar of config.schema.kindMap.GraphQLScalarTypeCustom) { - code(typeTitle2(`custom scalar type`)(scalar)) - code() - code(`export type ${scalar.name}Decoded = SchemaKit.Scalar.GetDecoded<${scalar.name}>`) - code(`export type ${scalar.name}Encoded = SchemaKit.Scalar.GetEncoded<${scalar.name}>`) - code() - } } + code(`export * from '${config.paths.imports.grafflePackage.scalars}'`) + code() + if (isNeedCustomScalarDefaults) { - code() if (config.lint.missingCustomScalarCodec) { console.log( `WARNING: Custom scalars detected in the schema, but you have not created a custom scalars module to import implementations from.`, ) } - code(`export {`) - code( - config.schema.kindMap.GraphQLScalarTypeCustom.map((_) => `String as ${_.name}`).join(`,`), - ) - code(`} from '${config.paths.imports.grafflePackage.scalars}'`) - } - code(`export * from '${config.paths.imports.grafflePackage.scalars}'`) + for (const scalar of config.schema.kindMap.GraphQLScalarTypeCustom) { + code(typeTitle2(`custom scalar type`)(scalar)) + code() + code(`import type { String as ${scalar.name} } from '${config.paths.imports.grafflePackage.scalars}'`) + code() + code(`export { String as ${scalar.name} } from '${config.paths.imports.grafflePackage.scalars}'`) + code(`export type ${scalar.name}Decoded = SchemaKit.Scalar.GetDecoded<${scalar.name}>`) + code(`export type ${scalar.name}Encoded = SchemaKit.Scalar.GetEncoded<${scalar.name}>`) + code() + } + } }, ) diff --git a/src/layers/4_generator/globalRegistry.ts b/src/layers/4_generator/globalRegistry.ts index 49bc77a12..475a7f775 100644 --- a/src/layers/4_generator/globalRegistry.ts +++ b/src/layers/4_generator/globalRegistry.ts @@ -1,6 +1,6 @@ import type { TypeFunction } from '../../entrypoints/utilities-for-generated.js' import type { ConfigManager } from '../../lib/config-manager/__.js' -import type { ExcludeUndefined, GetKeyOr, Values } from '../../lib/prelude.js' +import type { Values } from '../../lib/prelude.js' import type { TSErrorDescriptive } from '../../lib/ts-error.js' import type { Schema } from './generators/Schema.js' From b6ddc2c0141c7e954b60e9e690859dc88e9ab5f6 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Fri, 18 Oct 2024 10:59:22 -0400 Subject: [PATCH 6/8] link --- src/extensions/SchemaErrors/documentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/SchemaErrors/documentation.md b/src/extensions/SchemaErrors/documentation.md index 6ef27de1b..d1fe2b986 100644 --- a/src/extensions/SchemaErrors/documentation.md +++ b/src/extensions/SchemaErrors/documentation.md @@ -132,4 +132,4 @@ result // type is narrowed to just Bar case. ### Articles about schema errors. -- ... +- https://productionreadygraphql.com/2020-08-01-guide-to-graphql-errors From 85f035b5795434ee3ece839da38ae6ed453f83f2 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Fri, 18 Oct 2024 11:00:37 -0400 Subject: [PATCH 7/8] fix website --- website/content/examples/01_about/pokemon-schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/content/examples/01_about/pokemon-schema.md b/website/content/examples/01_about/pokemon-schema.md index 122bcf841..e8e633693 100644 --- a/website/content/examples/01_about/pokemon-schema.md +++ b/website/content/examples/01_about/pokemon-schema.md @@ -8,4 +8,4 @@ This is the GraphQL schema used in all examples throughout the Graffle documenta You can find its implementation in the repo at [tests/_/schemas/pokemon/schema.ts](https://github.com/jasonkuhrt/graffle/tree/main/tests/_/schemas/pokemon/schema.ts). -<<< ../../../../tests/_/schemas/pokemon/schema.graphql +<<< ../../../../tests/_/schemas/pokemon/graffle/schema.graphql From f1dfd5ff8d64549ee4b47462674f64bf2868e8ea Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Fri, 18 Oct 2024 11:07:20 -0400 Subject: [PATCH 8/8] fix --- eslint.config.js | 1 + src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint.config.js b/eslint.config.js index 325d4796f..e00dfc7df 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -10,6 +10,7 @@ export default tsEslint.config({ '**/generated/**/*', 'tests/_/schemas/*/graffle/**/*', '**/tests/fixture/graffle/**/*', + 'src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts', // There is an ESLint error that goes away when ignored leading to a circular issue of either lint error or unused lint disable. '**/$/**/*', 'legacy/**/*', 'build/**/*', diff --git a/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts b/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts index 833799d83..775261cb9 100644 --- a/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts +++ b/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts @@ -1,4 +1,3 @@ -/* eslint-disable */ import type { GlobalRegistry } from '../../../../4_generator/globalRegistry.js' import type { Codec, Mapper } from './codec.js' import { JavaScriptScalarCodecs } from './nativeScalarCodecs.js'