1 | import type { RootTypeName } from '../../lib/graphql.js'
|
2 | import type { Exact } from '../../lib/prelude.js'
|
3 | import type { Schema } from '../1_Schema/__.js'
|
4 | import type { GlobalRegistry } from '../2_generator/globalRegistry.js'
|
5 | import type { SelectionSet } from '../3_SelectionSet/__.js'
|
6 |
|
7 |
|
8 | type TypeSelectionSets<$Index extends Schema.Index> =
|
9 | & {
|
10 | [$RootTypeName in RootTypeName as $RootTypeName extends keyof $Index['Root'] ? $Index['Root'][$RootTypeName] extends null ? never : $RootTypeName:never ]:
|
11 | <$SelectionSet extends object>(selectionSet: Exact<$SelectionSet, SelectionSet.Root<$Index, $RootTypeName>>) =>
|
12 | $SelectionSet
|
13 | }
|
14 | & {
|
15 | [$Name in keyof $Index['objects']]:
|
16 | <$SelectionSet extends object>(selectionSet: Exact<$SelectionSet, SelectionSet.Object<$Index['objects'][$Name], $Index>>) =>
|
17 | $SelectionSet
|
18 | }
|
19 | & {
|
20 | [$Name in keyof $Index['unions']]:
|
21 | <$SelectionSet extends object>(selectionSet: Exact<$SelectionSet, SelectionSet.Union<$Index['unions'][$Name], $Index>>) =>
|
22 | $SelectionSet
|
23 | }
|
24 | & {
|
25 | [$Name in keyof Schema.Index['interfaces']]:
|
26 | <$SelectionSet extends object>(selectionSet: Exact<$SelectionSet, SelectionSet.Interface<$Index['interfaces'][$Name], $Index>>) =>
|
27 | $SelectionSet
|
28 | }
|
29 |
|
30 | type Create = <$Name extends GlobalRegistry.SchemaNames>(
|
31 | name: $Name,
|
32 |
|
33 |
|
34 | ) => TypeSelectionSets<GlobalRegistry.GetSchemaIndexOrDefault<$Name>>
|
35 |
|
36 | export const create: Create = (_name) => {
|
37 | return idProxy as any
|
38 | }
|
39 |
|
40 | const idProxy = new Proxy({}, {
|
41 | get: () => (value: unknown) => value,
|
42 | })
|
43 |
|
44 |
|
45 |
|
46 | export const select: TypeSelectionSets<GlobalRegistry.SchemaIndexDefault> = idProxy
|