33import type { Simplify } from 'type-fest'
44import type { GetKeyOr , SimplifyDeep } from '../lib/prelude.js'
55import type { TSError } from '../lib/TSError.js'
6- import type { Schema } from '../Schema/__.js'
6+ import type { Schema , SomeField } from '../Schema/__.js'
7+ import type { PickScalarFields } from '../Schema/Output/Output.js'
78import type { SelectionSet } from '../SelectionSet/__.js'
89
910// dprint-ignore
@@ -19,18 +20,15 @@ export type Subscription<$SelectionSetSubscription extends object, $Index extend
1920 SimplifyDeep < Object$ < $SelectionSetSubscription , Exclude < $Index [ 'Root' ] [ 'Subscription' ] , null > , $Index > >
2021
2122// dprint-ignore
22- export type Object$ < $SelectionSet , $Node extends Schema . Named . Object$2 , $Index extends Schema . Index > =
23+ export type Object$ < $SelectionSet , $Node extends Schema . Output . Object$2 , $Index extends Schema . Index > =
2324 SelectionSet . IsSelectScalarsWildcard < $SelectionSet > extends true
2425
2526 /**
2627 * Handle Scalars Wildcard
2728 */
2829 ?
2930 {
30- [ $Key in keyof $Node [ 'fields' ] as $Node [ 'fields' ] [ $Key ] extends Schema . Field . Field < Schema . Field . Type . Output . __typename > | { 'typeUnwrapped' :{ kind :'Scalar' } } ? $Key : never ] :
31- // eslint-disable-next-line
32- // @ts -ignore infinite depth issue, can this be fixed?
33- Field < $SelectionSet , Schema . Field . As < $Node [ 'fields' ] [ $Key ] > , $Index >
31+ [ $Key in keyof PickScalarFields < $Node > ] : Field < $SelectionSet , $Node [ 'fields' ] [ $Key ] , $Index >
3432 }
3533 /**
3634 * Handle fields in regular way.
@@ -44,15 +42,15 @@ export type Object$<$SelectionSet, $Node extends Schema.Named.Object$2, $Index e
4442 } >
4543
4644// dprint-ignore
47- type Union < $SelectionSet , $Node extends Schema . Named . Union , $Index extends Schema . Index > =
45+ type Union < $SelectionSet , $Node extends Schema . Output . Union , $Index extends Schema . Index > =
4846 OnTypeFragment < $SelectionSet , $Node [ 'members' ] [ number ] , $Index >
4947
5048// dprint-ignore
51- type Interface < $SelectionSet , $Node extends Schema . Named . Interface , $Index extends Schema . Index > =
49+ type Interface < $SelectionSet , $Node extends Schema . Output . Interface , $Index extends Schema . Index > =
5250 OnTypeFragment < $SelectionSet , $Node [ 'implementors' ] [ number ] , $Index >
5351
5452// dprint-ignore
55- type OnTypeFragment < $SelectionSet , $Node extends Schema . Named . Object$2 , $Index extends Schema . Index > =
53+ type OnTypeFragment < $SelectionSet , $Node extends Schema . Output . Object$2 , $Index extends Schema . Index > =
5654 $Node extends any // force distribution
5755 ? Object$ <
5856 GetKeyOr < $SelectionSet , `on${Capitalize < $Node [ 'fields' ] [ '__typename' ] [ 'type' ] [ 'type' ] > } `, { } > & SelectionSet . OmitOnTypeFragments < $SelectionSet > ,
@@ -62,7 +60,7 @@ type OnTypeFragment<$SelectionSet, $Node extends Schema.Named.Object$2, $Index e
6260 : never
6361
6462// dprint-ignore
65- type Field < $SelectionSet , $Field extends Schema . Field . Field , $Index extends Schema . Index > =
63+ type Field < $SelectionSet , $Field extends SomeField , $Index extends Schema . Index > =
6664 $SelectionSet extends SelectionSet . Directive . Include . Negative | SelectionSet . Directive . Skip . Positive ?
6765 null :
6866 (
@@ -74,18 +72,18 @@ type Field<$SelectionSet, $Field extends Schema.Field.Field, $Index extends Sche
7472// dprint-ignore
7573type FieldType <
7674 $SelectionSet ,
77- $Type extends Schema . Field . Type . Output . Any ,
75+ $Type extends Schema . Output . Any ,
7876 $Index extends Schema . Index
7977> = Simplify <
80- $Type extends Schema . Field . Type . Output . __typename < infer $Value > ? $Value :
81- $Type extends Schema . Field . Type . Output . Nullable < infer $InnerType > ? null | FieldType < $SelectionSet , $InnerType , $Index > :
82- $Type extends Schema . Field . Type . Output . List < infer $InnerType > ? Array < FieldType < $SelectionSet , $InnerType , $Index > > :
83- $Type extends Schema . Named . Enum < infer _ , infer $Members > ? $Members [ number ] :
84- $Type extends Schema . Named . Scalar . Any ? ReturnType < $Type [ 'codec' ] [ 'decode' ] > :
85- $Type extends Schema . Named . Object$2 ? Object$ < $SelectionSet , $Type , $Index > :
86- $Type extends Schema . Named . Interface ? Interface < $SelectionSet , $Type , $Index > :
87- $Type extends Schema . Named . Union ? Union < $SelectionSet , $Type , $Index > :
88- TSError < 'FieldType' , `Unknown type`, { $Type : $Type } >
78+ $Type extends Schema . __typename < infer $Value > ? $Value :
79+ $Type extends Schema . Output . Nullable < infer $InnerType > ? null | FieldType < $SelectionSet , $InnerType , $Index > :
80+ $Type extends Schema . Output . List < infer $InnerType > ? Array < FieldType < $SelectionSet , $InnerType , $Index > > :
81+ $Type extends Schema . Enum < infer _ , infer $Members > ? $Members [ number ] :
82+ $Type extends Schema . Scalar . Any ? ReturnType < $Type [ 'codec' ] [ 'decode' ] > :
83+ $Type extends Schema . Object$2 ? Object$ < $SelectionSet , $Type , $Index > :
84+ $Type extends Schema . Interface ? Interface < $SelectionSet , $Type , $Index > :
85+ $Type extends Schema . Union ? Union < $SelectionSet , $Type , $Index > :
86+ TSError < 'FieldType' , `Unknown type`, { $Type : $Type } >
8987 >
9088
9189// dprint-ignore
@@ -104,5 +102,5 @@ type FieldDirectiveSkip<$SelectionSet> =
104102
105103// dprint-ignore
106104export namespace Errors {
107- export type UnknownFieldName < $FieldName extends string , $Object extends Schema . Named . Object$2 > = TSError < 'Object' , `field "${$FieldName } " does not exist on object "${$Object [ 'fields' ] [ '__typename' ] [ 'type' ] [ 'type' ] } "`>
105+ export type UnknownFieldName < $FieldName extends string , $Object extends Schema . Object$2 > = TSError < 'Object' , `field "${$FieldName } " does not exist on object "${$Object [ 'fields' ] [ '__typename' ] [ 'type' ] [ 'type' ] } "`>
108106}
0 commit comments