UNPKG

1.74 kBPlain TextView Raw
1import type { RootTypeName } from '../../lib/graphql.js'
2import type { Exact } from '../../lib/prelude.js'
3import type { Schema } from '../1_Schema/__.js'
4import type { GlobalRegistry } from '../2_generator/globalRegistry.js'
5import type { SelectionSet } from '../3_SelectionSet/__.js'
6
7// dprint-ignore
8type 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
30type Create = <$Name extends GlobalRegistry.SchemaNames>(
31 name: $Name,
32 // eslint-disable-next-line
33 // @ts-ignore passes after generation
34) => TypeSelectionSets<GlobalRegistry.GetSchemaIndexOrDefault<$Name>>
35
36export const create: Create = (_name) => {
37 return idProxy as any
38}
39
40const idProxy = new Proxy({}, {
41 get: () => (value: unknown) => value,
42})
43
44// eslint-disable-next-line
45// @ts-ignore generated types
46export const select: TypeSelectionSets<GlobalRegistry.SchemaIndexDefault> = idProxy