From c14b3d0366deaabc232526bccfdacb27beae3713 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Mon, 14 Oct 2024 01:02:27 -0400 Subject: [PATCH] improve(types): readable result types (#1183) --- src/layers/2_Select/SelectAlias.ts | 7 +- src/layers/2_Select/selectionSet.ts | 16 +- src/layers/3_InferResult/Alias.ts | 2 +- src/layers/3_InferResult/__.test-d.ts | 8 +- .../__snapshots__/generate.test.ts.snap | 679 ++++++++++-------- .../4_generator/generators/MethodsRoot.ts | 39 +- .../client.create.config.output.test-d.ts | 18 +- src/layers/6_client/gql/send.ts | 4 +- src/layers/6_client/handleOutput.ts | 54 +- .../Introspection/Introspection.ts | 4 +- src/lib/anyware/hook/public.ts | 20 +- .../typed-document/TypedDocument.test-d.ts | 2 + .../grafaid/typed-document/TypedDocument.ts | 1 + src/lib/prelude.ts | 2 + .../graffle/modules/MethodsRoot.ts | 677 +++++++++-------- .../graffle/modules/MethodsRoot.ts | 51 +- .../pokemon/graffle/modules/MethodsRoot.ts | 149 ++-- .../query-only/graffle/modules/MethodsRoot.ts | 51 +- website/graffle/modules/MethodsRoot.ts | 99 +-- website/pokemon/modules/MethodsRoot.ts | 149 ++-- 20 files changed, 1181 insertions(+), 851 deletions(-) diff --git a/src/layers/2_Select/SelectAlias.ts b/src/layers/2_Select/SelectAlias.ts index 71197e841..c7632e067 100644 --- a/src/layers/2_Select/SelectAlias.ts +++ b/src/layers/2_Select/SelectAlias.ts @@ -4,7 +4,12 @@ export type SelectAlias<$SelectionSet = AnyExceptAlias> = | SelectAliasOne<$SelectionSet> | SelectAliasMultiple<$SelectionSet> -export type SelectAliasOne<$SelectionSet = AnyExceptAlias> = [alias: string, selectionSet: $SelectionSet] +// dprint-ignore +export type SelectAliasOne<$SelectionSet = AnyExceptAlias> = + [ + alias: string, + selectionSet: $SelectionSet + ] export type SelectAliasMultiple<$SelectionSet = AnyExceptAlias> = [ ...SelectAliasOne<$SelectionSet>[], diff --git a/src/layers/2_Select/selectionSet.ts b/src/layers/2_Select/selectionSet.ts index 7a28f001e..75bc9b562 100644 --- a/src/layers/2_Select/selectionSet.ts +++ b/src/layers/2_Select/selectionSet.ts @@ -4,14 +4,14 @@ import type { Indicator } from './Indicator/__.js' import { type SelectAlias } from './SelectAlias.js' export type AnySelectionSet = { - [k: string]: FieldValue -} & SpecialFields - -interface SpecialFields extends Directive.$Fields { - // todo - this requires having the schema at runtime to know which fields to select. - // $scalars?: SelectionSet.Indicator - $?: ArgsObject -} + [k: string]: FieldValue | ArgsObject +} // & SpecialFields + +// interface SpecialFields extends Directive.$Fields { +// // todo - this requires having the schema at runtime to know which fields to select. +// // $scalars?: SelectionSet.Indicator +// // $?: any // ArgsObject +// } export type FieldValue = AnySelectionSet | Indicator.Indicator diff --git a/src/layers/3_InferResult/Alias.ts b/src/layers/3_InferResult/Alias.ts index eb2f00f85..5278811f0 100644 --- a/src/layers/3_InferResult/Alias.ts +++ b/src/layers/3_InferResult/Alias.ts @@ -36,7 +36,7 @@ type InferSelectAlias< > = $SelectAlias extends Select.SelectAlias.SelectAliasOne ? InferSelectAliasOne<$SelectAlias, $FieldName, $Schema, $Node> : $SelectAlias extends Select.SelectAlias.SelectAliasMultiple ? InferSelectAliasMultiple<$SelectAlias, $FieldName, $Schema, $Node> : - never + never type InferSelectAliasMultiple< $SelectAliasMultiple extends Select.SelectAlias.SelectAliasMultiple, diff --git a/src/layers/3_InferResult/__.test-d.ts b/src/layers/3_InferResult/__.test-d.ts index bf2b1dd10..7ae1fc333 100644 --- a/src/layers/3_InferResult/__.test-d.ts +++ b/src/layers/3_InferResult/__.test-d.ts @@ -84,8 +84,12 @@ AssertEqual<$<{ interfaceWithArgs: { $:{id:'abc'}; id: true }}>, { interfaceWith // todo alias on interfaces, interface fragments // Alias // scalar -AssertEqual<$<{ id: ['id2', true] }>, { id2: null | string }>() -AssertEqual<$<{ idNonNull: ['id2', true] }>, { id2: string }>() +AssertEqual<$<{ id: ['x', true] }>, { x: null | string }>() +AssertEqual<$<{ idNonNull: ['x', true] }>, { x: string }>() +// object +AssertEqual<$<{ object: ['x', { id: true }] }>, { x: { id: null|string } | null }>() +// argument +AssertEqual<$<{objectWithArgs: ['x', { $: {id:''}; id:true }]}>, { x: { id: null|string } | null }>() // multi AssertEqual<$<{ id: [['id1', true],['id2', true]] }>, { id1: null | string; id2: null | string }>() // AssertEqual, { id_as: InferResult.Errors.UnknownFieldName<'id_as', Schema.Root.Query> }>() diff --git a/src/layers/4_generator/__snapshots__/generate.test.ts.snap b/src/layers/4_generator/__snapshots__/generate.test.ts.snap index f2962f229..c1d459f56 100644 --- a/src/layers/4_generator/__snapshots__/generate.test.ts.snap +++ b/src/layers/4_generator/__snapshots__/generate.test.ts.snap @@ -1444,7 +1444,8 @@ export interface BuilderMethodsDocumentFn extends Utilities.HKT.Fn { `; exports[`schema2 11`] = ` -"import type { InferResult } from '../../../../../../src/entrypoints/schema.js' +"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 * as SelectionSet from './SelectionSets.js' @@ -1452,38 +1453,46 @@ 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< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Mutation< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Mutation< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Mutation' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Mutation' + > > > id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.id>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'id', - InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['id'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'id', + InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['id'], Index> + > > > idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.idNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'idNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['idNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'idNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['idNonNull'], Index> + > > > } @@ -1491,391 +1500,477 @@ export interface MutationMethods<$Config extends Utils.Config> { export interface QueryMethods<$Config extends Utils.Config> { // todo Use a static type here? $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query>) => Promise< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Query< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Query< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Query' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Query' + > > > InputObjectNested: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNested>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'InputObjectNested', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['InputObjectNested'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'InputObjectNested', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['InputObjectNested'], Index> + > > > InputObjectNestedNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNestedNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'InputObjectNestedNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['InputObjectNestedNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'InputObjectNestedNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['InputObjectNestedNonNull'], Index> + > > > /** * Query enum field documentation. */ abcEnum: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.abcEnum>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'abcEnum', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['abcEnum'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'abcEnum', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['abcEnum'], Index> + > > > argInputObjectCircular: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.argInputObjectCircular>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'argInputObjectCircular', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['argInputObjectCircular'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'argInputObjectCircular', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['argInputObjectCircular'], Index> + > > > date: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.date>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'date', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['date'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'date', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['date'], Index> + > > > dateArg: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArg>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArg', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArg'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArg', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArg'], Index> + > > > dateArgInputObject: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgInputObject>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgInputObject', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgInputObject'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgInputObject', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgInputObject'], Index> + > > > dateArgList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgList>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgList'], Index> + > > > dateArgNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNull'], Index> + > > > dateArgNonNullList: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullList>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgNonNullList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNullList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgNonNullList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNullList'], Index> + > > > dateArgNonNullListNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullListNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgNonNullListNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNullListNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgNonNullListNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNullListNonNull'], Index> + > > > dateInterface1: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateInterface1>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateInterface1', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateInterface1'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateInterface1', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateInterface1'], Index> + > > > dateList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateList>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateList'], Index> + > > > dateListList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListList>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateListList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateListList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateListList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateListList'], Index> + > > > dateListNonNull: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateListNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateListNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateListNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateListNonNull'], Index> + > > > dateNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateNonNull'], Index> + > > > dateObject1: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateObject1>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateObject1', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateObject1'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateObject1', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateObject1'], Index> + > > > dateUnion: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateUnion>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateUnion', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateUnion'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateUnion', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateUnion'], Index> + > > > error: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.error>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'error', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['error'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'error', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['error'], Index> + > > > id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.id>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'id', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['id'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'id', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['id'], Index> + > > > idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.idNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'idNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['idNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'idNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['idNonNull'], Index> + > > > interface: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$interface>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'interface', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interface'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'interface', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interface'], Index> + > > > interfaceNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'interfaceNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interfaceNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'interfaceNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interfaceNonNull'], Index> + > > > interfaceWithArgs: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceWithArgs>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'interfaceWithArgs', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interfaceWithArgs'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'interfaceWithArgs', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interfaceWithArgs'], Index> + > > > listInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listInt>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'listInt', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listInt'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'listInt', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listInt'], Index> + > > > listIntNonNull: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listIntNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'listIntNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listIntNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'listIntNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listIntNonNull'], Index> + > > > listListInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListInt>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'listListInt', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listListInt'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'listListInt', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listListInt'], Index> + > > > listListIntNonNull: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListIntNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'listListIntNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listListIntNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'listListIntNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listListIntNonNull'], Index> + > > > lowerCaseUnion: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.lowerCaseUnion>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'lowerCaseUnion', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['lowerCaseUnion'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'lowerCaseUnion', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['lowerCaseUnion'], Index> + > > > object: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$object>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'object', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['object'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'object', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['object'], Index> + > > > objectList: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectList>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectList'], Index> + > > > objectListNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectListNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectListNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectListNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectListNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectListNonNull'], Index> + > > > objectNested: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNested>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectNested', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectNested'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectNested', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectNested'], Index> + > > > objectNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectNonNull'], Index> + > > > objectWithArgs: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectWithArgs>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectWithArgs', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectWithArgs'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectWithArgs', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectWithArgs'], Index> + > > > result: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.result>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'result', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['result'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'result', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['result'], Index> + > > > resultNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.resultNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'resultNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['resultNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'resultNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['resultNonNull'], Index> + > > > string: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.$string>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'string', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['string'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'string', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['string'], Index> + > > > stringWithArgEnum: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgEnum>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithArgEnum', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgEnum'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithArgEnum', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgEnum'], Index> + > > > stringWithArgInputObject: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObject>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithArgInputObject', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgInputObject'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithArgInputObject', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgInputObject'], Index> + > > > stringWithArgInputObjectRequired: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObjectRequired>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithArgInputObjectRequired', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgInputObjectRequired'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithArgInputObjectRequired', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgInputObjectRequired'], Index> + > > > /** @@ -1884,87 +1979,105 @@ export interface QueryMethods<$Config extends Utils.Config> { stringWithArgs: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgs>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithArgs', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgs'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithArgs', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgs'], Index> + > > > stringWithListArg: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArg>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithListArg', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithListArg'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithListArg', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithListArg'], Index> + > > > stringWithListArgRequired: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArgRequired>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithListArgRequired', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithListArgRequired'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithListArgRequired', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithListArgRequired'], Index> + > > > stringWithRequiredArg: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithRequiredArg>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithRequiredArg', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithRequiredArg'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithRequiredArg', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithRequiredArg'], Index> + > > > unionFooBar: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBar>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionFooBar', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBar'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionFooBar', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBar'], Index> + > > > unionFooBarNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionFooBarNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBarNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionFooBarNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBarNonNull'], Index> + > > > unionFooBarWithArgs: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarWithArgs>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionFooBarWithArgs', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBarWithArgs'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionFooBarWithArgs', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBarWithArgs'], Index> + > > > unionObject: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObject>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionObject', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionObject'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionObject', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionObject'], Index> + > > > unionObjectNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObjectNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionObjectNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionObjectNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionObjectNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionObjectNonNull'], Index> + > > > } diff --git a/src/layers/4_generator/generators/MethodsRoot.ts b/src/layers/4_generator/generators/MethodsRoot.ts index a49ec1e99..f6cf2831a 100644 --- a/src/layers/4_generator/generators/MethodsRoot.ts +++ b/src/layers/4_generator/generators/MethodsRoot.ts @@ -9,6 +9,7 @@ import { ModuleGeneratorSelectionSets } from './SelectionSets.js' export const ModuleGeneratorMethodsRoot = createModuleGenerator( `MethodsRoot`, ({ config, code }) => { + 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'`) @@ -54,23 +55,27 @@ const renderRootType = createCodeGenerator<{ node: Grafaid.Schema.ObjectType }>( // todo Use a static type here? $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.${node.name}>) => Promise< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.${node.name}< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, '${node.name}', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.${node.name}< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, '${node.name}', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - '${node.name}' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + '${node.name}' + > > > ${fieldMethods} @@ -99,11 +104,13 @@ namespace Helpers { export const returnType = (rootName: string, fieldName: string, selectionSet: string) => { return ` Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '${fieldName}', - InferResult.Field<${selectionSet}, Index['Root']['${rootName}']['fields']['${fieldName}'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '${fieldName}', + InferResult.Field<${selectionSet}, Index['Root']['${rootName}']['fields']['${fieldName}'], Index> + > > > ` diff --git a/src/layers/6_client/Settings/client.create.config.output.test-d.ts b/src/layers/6_client/Settings/client.create.config.output.test-d.ts index 129016542..bd5444b3e 100644 --- a/src/layers/6_client/Settings/client.create.config.output.test-d.ts +++ b/src/layers/6_client/Settings/client.create.config.output.test-d.ts @@ -6,7 +6,7 @@ import { Graffle } from '../../../../tests/_/schemas/kitchen-sink/graffle/__.js' import { schema } from '../../../../tests/_/schemas/kitchen-sink/schema.js' import { AssertEqual } from '../../../lib/assert-equal.js' import { type GraphQLExecutionResultError } from '../../../lib/grafaid/graphql.js' -import type { Envelope, ErrorsOther } from '../handleOutput.js' +import type { ErrorsOther } from '../handleOutput.js' const G = Graffle.create @@ -74,11 +74,11 @@ describe('.envelope', () => { }) describe('true enables it', () => { const g = Graffle.create({ schema, output: { envelope: true } }) - test('query.', async() => { - expectTypeOf(g.query.__typename()).resolves.toEqualTypeOf() + test('query.', () => { + expectTypeOf(g.query.__typename()).resolves.toMatchTypeOf() }) - test('query.', () => { - expectTypeOf(g.query.resultNonNull(resultFieldSelect)).resolves.toEqualTypeOf() + test('query.', async () => { + expectTypeOf((await g.query.resultNonNull(resultFieldSelect))).toMatchTypeOf() }) test('query.$batch', () => { const result = g.query.$batch({ __typename: true, idNonNull: true }) @@ -87,7 +87,7 @@ describe('.envelope', () => { }) test('object enables it', async () => { const graffle = Graffle.create({ schema, output: { envelope: {} } }) - expectTypeOf(await graffle.query.__typename()).toEqualTypeOf() + expectTypeOf(await graffle.query.__typename()).toMatchTypeOf() }) describe('.enabled', () => { test('false disables it', async () => { @@ -96,14 +96,14 @@ describe('.envelope', () => { }) test('true enables it', async () => { const graffle = Graffle.create({ schema, output: { envelope: { enabled: true } } }) - expectTypeOf(await graffle.query.__typename()).toEqualTypeOf() + expectTypeOf(await graffle.query.__typename()).toMatchTypeOf() }) }) describe('with defaults.errorChannel: "return"', () => { describe('.errors', () => { test('defaults to execution errors in envelope', () => { const g = G({ schema, output: { defaults: { errorChannel: 'return' }, envelope: true } }) - expectTypeOf(g.query.__typename()).resolves.toEqualTypeOf | ErrorsOther>() + expectTypeOf(g.query.__typename()).resolves.toMatchTypeOf | ErrorsOther>() }) test('.execution:false restores errors to return', async () => { const g = G({ @@ -119,7 +119,7 @@ describe('.envelope', () => { schema, output: { defaults: { errorChannel: 'return' }, envelope: { errors: { other: true } } }, }) - expectTypeOf(g.query.__typename()).resolves.toEqualTypeOf>() + expectTypeOf(g.query.__typename()).resolves.toMatchTypeOf>() }) }) }) diff --git a/src/layers/6_client/gql/send.ts b/src/layers/6_client/gql/send.ts index e788a2173..c2de5bdd0 100644 --- a/src/layers/6_client/gql/send.ts +++ b/src/layers/6_client/gql/send.ts @@ -1,5 +1,5 @@ import type { Grafaid } from '../../../lib/grafaid/__.js' -import { isString } from '../../../lib/prelude.js' +import { isString, type SimplifyNullable } from '../../../lib/prelude.js' import type { ResolveOutputGql } from '../handleOutput.js' import type { Config } from '../Settings/Config.js' @@ -22,7 +22,7 @@ type SendArguments__<$Variables extends Grafaid.Document.Typed.Variables, $Varia // dprint-ignore export interface DocumentController<$Config extends Config, $TypedDocument extends Grafaid.Document.Typed.TypedDocumentLike> { - send(...args: SendArguments<$TypedDocument>): Promise>> + send(...args: SendArguments<$TypedDocument>): Promise>>> } export type sendArgumentsImplementation = diff --git a/src/layers/6_client/handleOutput.ts b/src/layers/6_client/handleOutput.ts index d2b3b097f..57ae032ce 100644 --- a/src/layers/6_client/handleOutput.ts +++ b/src/layers/6_client/handleOutput.ts @@ -1,10 +1,9 @@ import type { ExecutionResult, GraphQLError } from 'graphql' -import type { Simplify } from 'type-fest' import { SchemaDrivenDataMap } from '../../layers/7_extensions/CustomScalars/schemaDrivenDataMap/types.js' import { Errors } from '../../lib/errors/__.js' import type { Grafaid } from '../../lib/grafaid/__.js' import type { GraphQLExecutionResultError } from '../../lib/grafaid/graphql.js' -import { isRecordLikeObject, isString, type SimplifyExceptError, type Values } from '../../lib/prelude.js' +import { isRecordLikeObject, isString, type Values } from '../../lib/prelude.js' import type { SchemaIndex } from '../4_generator/generators/SchemaIndex.js' import type { TransportHttp } from '../5_request/types.js' import type { State } from './fluent.js' @@ -149,7 +148,6 @@ export const handleOutput = ( // dprint-ignore export type ResolveOutputGql<$Config extends Config, $Data> = - SimplifyExceptError< | IfConfiguredGetOutputErrorReturns<$Config> | ( $Config['output']['envelope']['enabled'] extends true @@ -166,18 +164,15 @@ export type ResolveOutputGql<$Config extends Config, $Data> = // todo We need to integrate this reality into the the other typed non-envelope output types too. : $Data | null ) - > // dprint-ignore export type ResolveOutputReturnRootType<$Config extends Config, $Index extends SchemaIndex, $Data> = - SimplifyExceptError< | IfConfiguredGetOutputErrorReturns<$Config> | ( $Config['output']['envelope']['enabled'] extends true ? Envelope<$Config, IfConfiguredStripSchemaErrorsFromDataRootType<$Config, $Index, $Data>> : IfConfiguredStripSchemaErrorsFromDataRootType<$Config, $Index, $Data> ) - > // dprint-ignore export type ResolveOutputReturnRootField<$Config extends Config, $Index extends SchemaIndex, $RootFieldName extends string, $Data> = @@ -198,9 +193,10 @@ type IfConfiguredGetOutputErrorReturns<$Config extends Config> = // dprint-ignore type IfConfiguredStripSchemaErrorsFromDataRootType<$Config extends Config, $Index extends SchemaIndex, $Data> = - Simplify<{ - [$RootFieldName in keyof $Data]: IfConfiguredStripSchemaErrorsFromDataRootField<$Config, $Index, $Data[$RootFieldName]> - }> + & { + [$RootFieldName in keyof $Data]: IfConfiguredStripSchemaErrorsFromDataRootField<$Config, $Index, $Data[$RootFieldName]> + } + & {} // Simplify type display. // dprint-ignore type IfConfiguredStripSchemaErrorsFromDataRootField<$Config extends Config, $Index extends SchemaIndex, $Data> = @@ -235,27 +231,25 @@ type ConfigResolveOutputErrorChannel<$Config extends Config, $Channel extends Ou // dprint-ignore // todo use ObjMap for $Data export type Envelope<$Config extends Config, $Data = unknown, $Errors extends ReadonlyArray = ReadonlyArray> = - Simplify< - & { - data?: $Data | null - extensions?: ObjMap - } - & ( - $Config['transport']['type'] extends 'http' - ? { response: Response } - : {} - ) - // todo remove use of errors type variable. Rely only on $Config. - & ( - $Errors extends [] - ? {} - : IsEnvelopeWithoutErrors<$Config> extends true - ? {} - : { - errors?: ReadonlyArray - } - ) - > + & { + data?: $Data | null + extensions?: ObjMap + } + & ( + $Config['transport']['type'] extends 'http' + ? { response: Response } + : {} + ) + // todo remove use of errors type variable. Rely only on $Config. + & ( + $Errors extends [] + ? {} + : IsEnvelopeWithoutErrors<$Config> extends true + ? {} + : { + errors?: ReadonlyArray + } + ) type ObjMap = { [key: string]: T diff --git a/src/layers/7_extensions/Introspection/Introspection.ts b/src/layers/7_extensions/Introspection/Introspection.ts index c6b4ba2ea..62357fcbe 100644 --- a/src/layers/7_extensions/Introspection/Introspection.ts +++ b/src/layers/7_extensions/Introspection/Introspection.ts @@ -1,5 +1,5 @@ import { getIntrospectionQuery, type IntrospectionQuery } from 'graphql' -import type { Extension } from '../../../entrypoints/main.js' +import type { Extension, SimplifyNullable } from '../../../entrypoints/main.js' import type { Fluent } from '../../../lib/fluent/__.js' import { createExtension } from '../../6_client/extension/extension.js' import type { FnParametersProperty } from '../../6_client/fluent.js' @@ -60,5 +60,5 @@ interface IntrospectFn extends Fluent.FnProperty<`introspect`> { } interface Introspect<$Args extends FnParametersProperty> { - (): Promise> + (): Promise>> } diff --git a/src/lib/anyware/hook/public.ts b/src/lib/anyware/hook/public.ts index 8aee53646..97b1326d5 100644 --- a/src/lib/anyware/hook/public.ts +++ b/src/lib/anyware/hook/public.ts @@ -40,6 +40,7 @@ type InferPublicHook< // input: $HookMap[$Name]['input'] // } +// dprint-ignore type InferPublicHookReturn< $HookSequence extends HookSequence, $HookMap extends HookDefinitionMap<$HookSequence> = HookDefinitionMap<$HookSequence>, @@ -48,14 +49,17 @@ type InferPublicHookReturn< $Options extends ExtensionOptions = ExtensionOptions, > = Promise< | ($Options['retrying'] extends true ? Error : never) - | (IsLastValue<$Name, $HookSequence> extends true ? $Result : { - [$NameNext in FindValueAfter<$Name, $HookSequence>]: InferPublicHook< - $HookSequence, - $HookMap, - $Result, - $NameNext - > - }) + | (IsLastValue<$Name, $HookSequence> extends true + ? $Result + : { + [$NameNext in FindValueAfter<$Name, $HookSequence>]: InferPublicHook< + $HookSequence, + $HookMap, + $Result, + $NameNext + > + } + ) > type SlotInputify<$Slots extends Record any>> = { diff --git a/src/lib/grafaid/typed-document/TypedDocument.test-d.ts b/src/lib/grafaid/typed-document/TypedDocument.test-d.ts index 5c59e78ee..7cbfd9257 100644 --- a/src/lib/grafaid/typed-document/TypedDocument.test-d.ts +++ b/src/lib/grafaid/typed-document/TypedDocument.test-d.ts @@ -5,6 +5,7 @@ import type { Node, Query, ResultOf, + SomeData, String, Variables, VariablesInputKindNone, @@ -31,6 +32,7 @@ import type { TypedDocumentNode as Node2 } from '@graphql-typed-document-node/co AssertEqual>, {}>() AssertEqual>, {}>() + AssertEqual , SomeData>() AssertEqual>, {x:1}>() AssertEqual>, {x:1}>() AssertEqual>, {x:1}>() diff --git a/src/lib/grafaid/typed-document/TypedDocument.ts b/src/lib/grafaid/typed-document/TypedDocument.ts index c816243db..25abb4b27 100644 --- a/src/lib/grafaid/typed-document/TypedDocument.ts +++ b/src/lib/grafaid/typed-document/TypedDocument.ts @@ -85,6 +85,7 @@ export const unType = (document: TypedDocumentLike): string | DocumentNode => do // dprint-ignore export type ResultOf<$Document extends TypedDocumentLike> = + $Document extends string ? SomeData : $Document extends TypedQueryDocumentNode ? $R : $Document extends TypedDocumentNode ? $R : $Document extends TypedDocumentString ? $R : diff --git a/src/lib/prelude.ts b/src/lib/prelude.ts index 9f8e082a1..f63d99107 100644 --- a/src/lib/prelude.ts +++ b/src/lib/prelude.ts @@ -640,3 +640,5 @@ export const findTyped = <$Value, $Result>( ): undefined | $Result => { return values.find((value) => Boolean(looker(value))) as undefined | $Result } + +export type SimplifyNullable = null extends T ? (T & {}) | null : T & {} diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/MethodsRoot.ts b/tests/_/schemas/kitchen-sink/graffle/modules/MethodsRoot.ts index 38dca2462..b589397ba 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/MethodsRoot.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/MethodsRoot.ts @@ -1,3 +1,4 @@ +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' @@ -6,38 +7,46 @@ 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< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Mutation< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Mutation< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Mutation' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Mutation' + > > > id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.id>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'id', - InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['id'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'id', + InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['id'], Index> + > > > idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.idNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'idNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['idNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'idNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['idNonNull'], Index> + > > > } @@ -45,391 +54,477 @@ export interface MutationMethods<$Config extends Utils.Config> { export interface QueryMethods<$Config extends Utils.Config> { // todo Use a static type here? $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query>) => Promise< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Query< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Query< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Query' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Query' + > > > InputObjectNested: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNested>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'InputObjectNested', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['InputObjectNested'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'InputObjectNested', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['InputObjectNested'], Index> + > > > InputObjectNestedNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.InputObjectNestedNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'InputObjectNestedNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['InputObjectNestedNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'InputObjectNestedNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['InputObjectNestedNonNull'], Index> + > > > /** * Query enum field documentation. */ abcEnum: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.abcEnum>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'abcEnum', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['abcEnum'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'abcEnum', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['abcEnum'], Index> + > > > argInputObjectCircular: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.argInputObjectCircular>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'argInputObjectCircular', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['argInputObjectCircular'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'argInputObjectCircular', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['argInputObjectCircular'], Index> + > > > date: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.date>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'date', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['date'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'date', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['date'], Index> + > > > dateArg: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArg>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArg', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArg'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArg', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArg'], Index> + > > > dateArgInputObject: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgInputObject>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgInputObject', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgInputObject'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgInputObject', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgInputObject'], Index> + > > > dateArgList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgList>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgList'], Index> + > > > dateArgNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNull'], Index> + > > > dateArgNonNullList: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullList>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgNonNullList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNullList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgNonNullList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNullList'], Index> + > > > dateArgNonNullListNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateArgNonNullListNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateArgNonNullListNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNullListNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateArgNonNullListNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateArgNonNullListNonNull'], Index> + > > > dateInterface1: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateInterface1>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateInterface1', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateInterface1'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateInterface1', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateInterface1'], Index> + > > > dateList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateList>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateList'], Index> + > > > dateListList: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListList>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateListList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateListList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateListList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateListList'], Index> + > > > dateListNonNull: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateListNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateListNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateListNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateListNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateListNonNull'], Index> + > > > dateNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.dateNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateNonNull'], Index> + > > > dateObject1: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateObject1>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateObject1', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateObject1'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateObject1', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateObject1'], Index> + > > > dateUnion: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.dateUnion>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'dateUnion', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateUnion'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'dateUnion', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['dateUnion'], Index> + > > > error: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.error>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'error', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['error'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'error', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['error'], Index> + > > > id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.id>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'id', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['id'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'id', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['id'], Index> + > > > idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.idNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'idNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['idNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'idNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['idNonNull'], Index> + > > > interface: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$interface>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'interface', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interface'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'interface', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interface'], Index> + > > > interfaceNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'interfaceNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interfaceNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'interfaceNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interfaceNonNull'], Index> + > > > interfaceWithArgs: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.interfaceWithArgs>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'interfaceWithArgs', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interfaceWithArgs'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'interfaceWithArgs', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['interfaceWithArgs'], Index> + > > > listInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listInt>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'listInt', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listInt'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'listInt', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listInt'], Index> + > > > listIntNonNull: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listIntNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'listIntNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listIntNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'listIntNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listIntNonNull'], Index> + > > > listListInt: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListInt>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'listListInt', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listListInt'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'listListInt', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listListInt'], Index> + > > > listListIntNonNull: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.listListIntNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'listListIntNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listListIntNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'listListIntNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['listListIntNonNull'], Index> + > > > lowerCaseUnion: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.lowerCaseUnion>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'lowerCaseUnion', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['lowerCaseUnion'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'lowerCaseUnion', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['lowerCaseUnion'], Index> + > > > object: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.$object>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'object', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['object'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'object', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['object'], Index> + > > > objectList: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectList>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectList', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectList'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectList', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectList'], Index> + > > > objectListNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectListNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectListNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectListNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectListNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectListNonNull'], Index> + > > > objectNested: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNested>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectNested', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectNested'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectNested', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectNested'], Index> + > > > objectNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectNonNull'], Index> + > > > objectWithArgs: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.objectWithArgs>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'objectWithArgs', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectWithArgs'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'objectWithArgs', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['objectWithArgs'], Index> + > > > result: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.result>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'result', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['result'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'result', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['result'], Index> + > > > resultNonNull: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.resultNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'resultNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['resultNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'resultNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['resultNonNull'], Index> + > > > string: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.$string>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'string', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['string'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'string', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['string'], Index> + > > > stringWithArgEnum: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgEnum>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithArgEnum', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgEnum'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithArgEnum', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgEnum'], Index> + > > > stringWithArgInputObject: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObject>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithArgInputObject', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgInputObject'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithArgInputObject', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgInputObject'], Index> + > > > stringWithArgInputObjectRequired: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgInputObjectRequired>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithArgInputObjectRequired', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgInputObjectRequired'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithArgInputObjectRequired', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgInputObjectRequired'], Index> + > > > /** @@ -438,87 +533,105 @@ export interface QueryMethods<$Config extends Utils.Config> { stringWithArgs: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithArgs>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithArgs', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgs'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithArgs', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithArgs'], Index> + > > > stringWithListArg: <$SelectionSet>( selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArg>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithListArg', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithListArg'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithListArg', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithListArg'], Index> + > > > stringWithListArgRequired: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithListArgRequired>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithListArgRequired', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithListArgRequired'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithListArgRequired', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithListArgRequired'], Index> + > > > stringWithRequiredArg: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.stringWithRequiredArg>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'stringWithRequiredArg', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithRequiredArg'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'stringWithRequiredArg', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['stringWithRequiredArg'], Index> + > > > unionFooBar: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBar>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionFooBar', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBar'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionFooBar', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBar'], Index> + > > > unionFooBarNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionFooBarNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBarNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionFooBarNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBarNonNull'], Index> + > > > unionFooBarWithArgs: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionFooBarWithArgs>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionFooBarWithArgs', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBarWithArgs'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionFooBarWithArgs', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionFooBarWithArgs'], Index> + > > > unionObject: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObject>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionObject', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionObject'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionObject', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionObject'], Index> + > > > unionObjectNonNull: <$SelectionSet>( selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.unionObjectNonNull>, ) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'unionObjectNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionObjectNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'unionObjectNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['unionObjectNonNull'], Index> + > > > } diff --git a/tests/_/schemas/mutation-only/graffle/modules/MethodsRoot.ts b/tests/_/schemas/mutation-only/graffle/modules/MethodsRoot.ts index 72ea4f2c9..212c78131 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/MethodsRoot.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/MethodsRoot.ts @@ -1,3 +1,4 @@ +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' @@ -6,38 +7,46 @@ 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< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Mutation< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Mutation< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Mutation' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Mutation' + > > > id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.id>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'id', - InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['id'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'id', + InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['id'], Index> + > > > idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Mutation.idNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'idNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['idNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'idNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['idNonNull'], Index> + > > > } diff --git a/tests/_/schemas/pokemon/graffle/modules/MethodsRoot.ts b/tests/_/schemas/pokemon/graffle/modules/MethodsRoot.ts index 467b2793e..088c75a99 100644 --- a/tests/_/schemas/pokemon/graffle/modules/MethodsRoot.ts +++ b/tests/_/schemas/pokemon/graffle/modules/MethodsRoot.ts @@ -1,3 +1,4 @@ +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' @@ -6,30 +7,36 @@ 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< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Mutation< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Mutation< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Mutation' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Mutation' + > > > addPokemon: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Mutation.addPokemon>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'addPokemon', - InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['addPokemon'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'addPokemon', + InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['addPokemon'], Index> + > > > } @@ -37,78 +44,96 @@ export interface MutationMethods<$Config extends Utils.Config> { export interface QueryMethods<$Config extends Utils.Config> { // todo Use a static type here? $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query>) => Promise< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Query< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Query< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Query' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Query' + > > > battles: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.battles>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'battles', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['battles'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'battles', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['battles'], Index> + > > > beings: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.beings>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'beings', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['beings'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'beings', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['beings'], Index> + > > > pokemon: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.pokemon>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'pokemon', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemon'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'pokemon', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemon'], Index> + > > > pokemonByName: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.pokemonByName>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'pokemonByName', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemonByName'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'pokemonByName', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemonByName'], Index> + > > > pokemons: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.pokemons>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'pokemons', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemons'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'pokemons', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemons'], Index> + > > > trainerByName: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.trainerByName>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'trainerByName', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['trainerByName'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'trainerByName', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['trainerByName'], Index> + > > > trainers: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.trainers>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'trainers', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['trainers'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'trainers', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['trainers'], Index> + > > > } diff --git a/tests/_/schemas/query-only/graffle/modules/MethodsRoot.ts b/tests/_/schemas/query-only/graffle/modules/MethodsRoot.ts index fcb1f4e40..d440e1c3c 100644 --- a/tests/_/schemas/query-only/graffle/modules/MethodsRoot.ts +++ b/tests/_/schemas/query-only/graffle/modules/MethodsRoot.ts @@ -1,3 +1,4 @@ +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' @@ -6,38 +7,46 @@ import type * as SelectionSet from './SelectionSets.js' export interface QueryMethods<$Config extends Utils.Config> { // todo Use a static type here? $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query>) => Promise< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Query< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Query< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Query' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Query' + > > > id: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.id>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'id', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['id'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'id', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['id'], Index> + > > > idNonNull: <$SelectionSet>(selectionSet?: Utils.Exact<$SelectionSet, SelectionSet.Query.idNonNull>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'idNonNull', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['idNonNull'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'idNonNull', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['idNonNull'], Index> + > > > } diff --git a/website/graffle/modules/MethodsRoot.ts b/website/graffle/modules/MethodsRoot.ts index 020137584..a5fb3c8b6 100644 --- a/website/graffle/modules/MethodsRoot.ts +++ b/website/graffle/modules/MethodsRoot.ts @@ -1,75 +1,92 @@ 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 QueryMethods<$Config extends Utils.Config> { // todo Use a static type here? $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query>) => Promise< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Query< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Query< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Query' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Query' + > > > continent: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.continent>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'continent', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['continent'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'continent', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['continent'], Index> + > > > continents: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.continents>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'continents', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['continents'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'continents', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['continents'], Index> + > > > countries: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.countries>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'countries', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['countries'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'countries', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['countries'], Index> + > > > country: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.country>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'country', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['country'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'country', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['country'], Index> + > > > language: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.language>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'language', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['language'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'language', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['language'], Index> + > > > languages: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.languages>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'languages', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['languages'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'languages', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['languages'], Index> + > > > } diff --git a/website/pokemon/modules/MethodsRoot.ts b/website/pokemon/modules/MethodsRoot.ts index 429ffbac7..593de4222 100644 --- a/website/pokemon/modules/MethodsRoot.ts +++ b/website/pokemon/modules/MethodsRoot.ts @@ -1,35 +1,42 @@ 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< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Mutation< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Mutation< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Mutation', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Mutation' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Mutation' + > > > addPokemon: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Mutation.addPokemon>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'addPokemon', - InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['addPokemon'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'addPokemon', + InferResult.Field<$SelectionSet, Index['Root']['Mutation']['fields']['addPokemon'], Index> + > > > } @@ -37,78 +44,96 @@ export interface MutationMethods<$Config extends Utils.Config> { export interface QueryMethods<$Config extends Utils.Config> { // todo Use a static type here? $batch: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query>) => Promise< - Utils.ResolveOutputReturnRootType< - $Config, - Index, - InferResult.Query< - Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, - Index + Simplify< + Utils.ResolveOutputReturnRootType< + $Config, + Index, + InferResult.Query< + Utils.AddTypenameToSelectedRootTypeResultFields<$Config, Index, 'Query', $SelectionSet>, + Index + > > > > // todo Use a static type here? __typename: () => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - '__typename', - 'Query' + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + '__typename', + 'Query' + > > > battles: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.battles>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'battles', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['battles'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'battles', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['battles'], Index> + > > > beings: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.beings>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'beings', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['beings'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'beings', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['beings'], Index> + > > > pokemon: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.pokemon>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'pokemon', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemon'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'pokemon', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemon'], Index> + > > > pokemonByName: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.pokemonByName>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'pokemonByName', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemonByName'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'pokemonByName', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemonByName'], Index> + > > > pokemons: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.pokemons>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'pokemons', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemons'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'pokemons', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['pokemons'], Index> + > > > trainerByName: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.trainerByName>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'trainerByName', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['trainerByName'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'trainerByName', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['trainerByName'], Index> + > > > trainers: <$SelectionSet>(selectionSet: Utils.Exact<$SelectionSet, SelectionSet.Query.trainers>) => Promise< - Utils.ResolveOutputReturnRootField< - $Config, - Index, - 'trainers', - InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['trainers'], Index> + Simplify< + Utils.ResolveOutputReturnRootField< + $Config, + Index, + 'trainers', + InferResult.Field<$SelectionSet, Index['Root']['Query']['fields']['trainers'], Index> + > > > }