@@ -6,35 +6,39 @@ import type { Alias } from './Alias.js'
6
6
import type { OutputField } from './OutputField.js'
7
7
import type { ScalarsWildcard } from './ScalarsWildcard.js'
8
8
9
+ // dprint-ignore
9
10
export type OutputObject < $SelectionSet , $Schema extends Schema , $Node extends Schema . OutputObject > =
10
11
Select . SelectScalarsWildcard . IsSelectScalarsWildcard < $SelectionSet > extends true
11
12
// todo what about when scalars wildcard is combined with other fields like relations?
12
13
? ScalarsWildcard < $SelectionSet , $Schema , $Node >
13
14
: SimplifyExcept <
14
- $Schema [ 'scalars' ] [ 'typesDecoded' ] ,
15
- & SelectionNonSelectAlias < $SelectionSet , $Schema , $Node >
16
- & Alias < $Schema , $Node , $SelectionSet >
17
- >
15
+ $Schema [ 'scalars' ] [ 'typesDecoded' ] ,
16
+ & NonAlias < $SelectionSet , $Schema , $Node >
17
+ & Alias < $Schema , $Node , $SelectionSet >
18
+ >
18
19
19
- type SelectionNonSelectAlias < $SelectionSet , $Schema extends Schema , $Node extends Schema . OutputObject > = {
20
+ type NonAlias < $SelectionSet , $Schema extends Schema , $Node extends Schema . OutputObject > = {
20
21
[ $Key in PickSelectsPositiveIndicatorAndNotSelectAlias < $SelectionSet > ] : $Key extends keyof $Node [ 'fields' ]
21
22
? OutputField < $SelectionSet [ $Key ] , $Node [ 'fields' ] [ $Key ] , $Schema >
22
23
: Errors . UnknownFieldName < $Key , $Node >
23
24
}
24
25
25
- export namespace Errors {
26
- export type UnknownFieldName <
27
- $FieldName extends string ,
28
- $Object extends Schema . OutputObject ,
29
- > = TSErrorDescriptive < 'Object' , `field "${$FieldName } " does not exist on object "${$Object [ 'name' ] } "`>
30
- }
31
-
26
+ // dprint-ignore
32
27
export type PickSelectsPositiveIndicatorAndNotSelectAlias < $SelectionSet > = StringKeyof <
33
28
{
34
29
[
35
- $FieldName in keyof $SelectionSet as $SelectionSet [ $FieldName ] extends Select . Indicator . Negative ? never
36
- : $SelectionSet [ $FieldName ] extends any [ ] ? never
37
- : $FieldName
30
+ $FieldName in keyof $SelectionSet as $SelectionSet [ $FieldName ] extends Select . Indicator . Negative
31
+ ? never
32
+ : $SelectionSet [ $FieldName ] extends any [ ]
33
+ ? never
34
+ : $FieldName
38
35
] : 0
39
36
}
40
37
>
38
+
39
+ export namespace Errors {
40
+ export type UnknownFieldName <
41
+ $FieldName extends string ,
42
+ $Object extends Schema . OutputObject ,
43
+ > = TSErrorDescriptive < 'Object' , `field "${$FieldName } " does not exist on object "${$Object [ 'name' ] } "`>
44
+ }
0 commit comments