1 | import type { Args } from './Args.js'
|
2 | import type { MaybeThunk } from './core/helpers.js'
|
3 | import type { Hybrid } from './Hybrid/__.js'
|
4 | import type { Output } from './Output/__.js'
|
5 |
|
6 | export type Field<$Type extends Output.Any, $Args extends Args<any> | null> = {
|
7 | type: $Type
|
8 | args: $Args
|
9 | }
|
10 |
|
11 | export const field = <$Type extends Output.Any, $Args extends null | Args<any> = null>(
|
12 | type: MaybeThunk<$Type>,
|
13 | args: $Args = null as $Args,
|
14 | ): Field<$Type, $Args> => {
|
15 | return {
|
16 |
|
17 | type: type as any,
|
18 | args,
|
19 | }
|
20 | }
|
21 |
|
22 |
|
23 | export type SomeField = Field<
|
24 | | Hybrid.Enum
|
25 | | Hybrid.Scalar.Any
|
26 | | Output.List<any>
|
27 | | Output.Nullable<any>
|
28 | | Output.Object$2<string, any>
|
29 | | Output.Union<string, [any, ...any[]]>
|
30 | | Output.Interface<string, Record<string, Field<any, Args<any> | null>>, [any, ...any[]]>,
|
31 | Args<any> | null
|
32 | >
|
33 |
|
34 | export type SomeFields<$Keys extends string | number | symbol = string | number | symbol> = Record<
|
35 | $Keys,
|
36 | SomeField
|
37 | >
|