2
2
import { Grafaid } from '../../lib/grafaid/_namespace.js'
3
3
import { createFromObjectTypeAndMapOrThrow } from '../../lib/grafaid/schema/RootDetails.js'
4
4
import { capitalizeFirstLetter } from '../../lib/prelude.js'
5
- import { identifiers } from '../helpers/identifiers.js'
5
+ import { $ } from '../helpers/identifiers.js'
6
6
import { createModuleGenerator , importModuleGenerator } from '../helpers/moduleGenerator.js'
7
7
import { createCodeGenerator } from '../helpers/moduleGeneratorRunner.js'
8
8
import { renderDocumentation , renderName } from '../helpers/render.js'
@@ -14,31 +14,27 @@ export const ModuleGeneratorMethodsRoot = createModuleGenerator(
14
14
( { config, code } ) => {
15
15
code ( importModuleGenerator ( config , ModuleGeneratorSelectionSets , true ) )
16
16
code ( importModuleGenerator ( config , ModuleGeneratorSchema , true ) )
17
- code (
18
- `import type * as ${ identifiers . $$Utilities } from '${ config . paths . imports . grafflePackage . utilitiesForGenerated } ';` ,
19
- )
20
- code ( )
21
- code ( )
17
+ code `import type * as ${ $ . $$Utilities } from '${ config . paths . imports . grafflePackage . utilitiesForGenerated } '`
18
+ code ``
19
+ code ``
22
20
config . schema . kindMap . list . Root . forEach ( node => {
23
21
code ( renderRootType ( { config, node } ) )
24
- code ( )
22
+ code ``
25
23
} )
26
- code ( `
27
- export interface BuilderMethodsRoot<$Context extends ${ identifiers . $$Utilities } .Context> {
24
+ code `
25
+ export interface BuilderMethodsRoot<$Context extends ${ $ . $$Utilities } .Context> {
28
26
${
29
27
config . schema . kindMap . root . list . map ( node => {
30
28
return `${ node . operationType } : ${ node . name . canonical } Methods<$Context>`
31
29
} ) . join ( `\n` )
32
30
}
33
31
}
34
- ` )
35
- code ( )
36
- code ( `
37
- export interface BuilderMethodsRootFn extends ${ identifiers . $$Utilities } .TypeFunction {
32
+
33
+ export interface BuilderMethodsRootFn extends ${ $ . $$Utilities } .TypeFunction {
38
34
// @ts-expect-error parameter is Untyped.
39
35
return: BuilderMethodsRoot<this['params']>
40
36
}
41
- ` )
37
+ `
42
38
} ,
43
39
)
44
40
@@ -47,35 +43,36 @@ const renderRootType = createCodeGenerator<{ node: Grafaid.Schema.ObjectType }>(
47
43
const { operationType } = createFromObjectTypeAndMapOrThrow ( node , config . schema . kindMap . root )
48
44
49
45
// dprint-ignore
50
- code ( `
51
- export interface ${ node . name } Methods<$Context extends ${ identifiers . $$Utilities } .Context> {
46
+ code `
47
+ export interface ${ node . name } Methods<$Context extends ${ $ . $$Utilities } .Context> {
52
48
$batch:
53
- ${ identifiers . $$Utilities } .GraffleKit.Context.Configuration.Check.Preflight<
49
+ ${ $ . $$Utilities } .GraffleKit.Context.Configuration.Check.Preflight<
54
50
$Context,
55
- <$SelectionSet>(selectionSet: ${ identifiers . $$Utilities } .Exact<$SelectionSet, ${ identifiers . $$SelectionSets } .${ node . name } <$Context['scalars']>>) =>
51
+ <$SelectionSet>(selectionSet: ${ $ . $$Utilities } .Exact<$SelectionSet, ${ $ . $$SelectionSets } .${ node . name } <$Context['scalars']>>) =>
56
52
Promise<
57
53
& (null | {})
58
- & ${ identifiers . $$Utilities } .HandleOutput<
54
+ & ${ $ . $$Utilities } .HandleOutput<
59
55
$Context,
60
- ${ identifiers . $$Utilities } .DocumentBuilderKit.InferResult.Operation${ capitalizeFirstLetter ( operationType ) } <${ identifiers . $$Utilities } .AssertExtendsObject<$SelectionSet>, ${ identifiers . $$Schema } .${ identifiers . Schema } <$Context['scalars']>>
56
+ ${ $ . $$Utilities } .DocumentBuilderKit.InferResult.Operation${ capitalizeFirstLetter ( operationType ) } <${ $ . $$Utilities } .AssertExtendsObject<$SelectionSet>, ${ $ . $$Schema } .${ $ . Schema } <$Context['scalars']>>
61
57
>
62
58
>
63
59
>
64
60
__typename:
65
- ${ identifiers . $$Utilities } .GraffleKit.Context.Configuration.Check.Preflight<
61
+ ${ $ . $$Utilities } .GraffleKit.Context.Configuration.Check.Preflight<
66
62
$Context,
67
63
() =>
68
64
Promise<
69
65
& (null | {})
70
- & ${ identifiers . $$Utilities } .HandleOutputDocumentBuilderRootField<
66
+ & ${ $ . $$Utilities } .HandleOutputDocumentBuilderRootField<
71
67
$Context,
72
68
{ __typename: '${ node . name } ' },
73
69
'__typename'
74
70
>
75
71
>
76
72
>
77
73
${ fieldMethods }
78
- }` )
74
+ }
75
+ `
79
76
} )
80
77
81
78
const renderFieldMethods = createCodeGenerator < { node : Grafaid . Schema . ObjectType } > ( ( { node, config, code } ) => {
@@ -90,20 +87,20 @@ const renderFieldMethods = createCodeGenerator<{ node: Grafaid.Schema.ObjectType
90
87
91
88
const { operationType } = createFromObjectTypeAndMapOrThrow ( node , config . schema . kindMap . root )
92
89
// dprint-ignore
93
- code ( `
90
+ code `
94
91
${ field . name } :
95
- ${ identifiers . $$Utilities } .GraffleKit.Context.Configuration.Check.Preflight<
92
+ ${ $ . $$Utilities } .GraffleKit.Context.Configuration.Check.Preflight<
96
93
$Context,
97
- <$SelectionSet>(selectionSet${ isOptional ? `?` : `` } : ${ identifiers . $$Utilities } .Exact<$SelectionSet, ${ identifiers . $$SelectionSets } .${ renderName ( node . name ) } .${ renderName ( field ) } <$Context['scalars']>>) =>
94
+ <$SelectionSet>(selectionSet${ isOptional ? `?` : `` } : ${ $ . $$Utilities } .Exact<$SelectionSet, ${ $ . $$SelectionSets } .${ renderName ( node . name ) } .${ renderName ( field ) } <$Context['scalars']>>) =>
98
95
Promise<
99
96
& (null | {})
100
- & ${ identifiers . $$Utilities } .HandleOutputDocumentBuilderRootField<
97
+ & ${ $ . $$Utilities } .HandleOutputDocumentBuilderRootField<
101
98
$Context,
102
- ${ identifiers . $$Utilities } .DocumentBuilderKit.InferResult.Operation${ capitalizeFirstLetter ( operationType ) } <{ ${ field . name } : $SelectionSet}, ${ identifiers . $$Schema } .${ identifiers . Schema } <$Context['scalars']>>,
99
+ ${ $ . $$Utilities } .DocumentBuilderKit.InferResult.Operation${ capitalizeFirstLetter ( operationType ) } <{ ${ field . name } : $SelectionSet}, ${ $ . $$Schema } .${ $ . Schema } <$Context['scalars']>>,
103
100
'${ field . name } '
104
101
>
105
102
>
106
103
>
107
- ` )
104
+ `
108
105
}
109
106
} )
0 commit comments