UNPKG

5.09 kBTypeScriptView Raw
1import * as graphql from 'graphql';
2declare type PromiseOrValue<T> = Promise<T> | T;
3declare type Maybe<T> = T | null | undefined;
4export declare type OutputType<Ctx, Src> = Scalar<Src> | Enum<Src> | ObjectType<Ctx, Src> | Union<Ctx, Src> | Interface<Ctx, Src> | ListType<Ctx, Src> | NonNullType<Ctx, Src>;
5interface ListType<Ctx, Src> extends List<Ctx, OutputType<Ctx, Src>> {
6}
7interface NonNullType<Ctx, Src> extends NonNull<Ctx, OutputType<Ctx, Src>> {
8}
9export declare type InputType<Src> = Scalar<Src> | Enum<Src> | InputObject<Src> | ListInputType<Src> | NonNullInputType<Src>;
10interface ListInputType<Src> extends ListInput<InputType<Src>> {
11}
12interface NonNullInputType<Src> extends NonNullInput<InputType<Src>> {
13}
14export declare type AllType<Ctx> = OutputType<Ctx, any> | InputType<any>;
15export declare type Scalar<Src> = {
16 kind: 'Scalar';
17 graphqlTypeConfig: graphql.GraphQLScalarTypeConfig<Src, JSON>;
18} | {
19 kind: 'Scalar';
20 builtInType: graphql.GraphQLScalarType;
21};
22export declare type Enum<Src> = {
23 kind: 'Enum';
24 name: string;
25 description?: string;
26 values: Array<EnumValue<Src>>;
27};
28export declare type EnumValue<Src> = {
29 name: string;
30 description?: string;
31 deprecationReason?: string;
32 value: Src;
33};
34export declare type List<Ctx, Src> = {
35 kind: 'List';
36 ofType: OutputType<Ctx, Src>;
37};
38export declare type NonNull<Ctx, Src> = {
39 kind: 'NonNull';
40 ofType: OutputType<Ctx, Src>;
41};
42export declare type ListInput<Src> = {
43 kind: 'ListInput';
44 ofType: InputType<Src>;
45};
46export declare type NonNullInput<Src> = {
47 kind: 'NonNullInput';
48 ofType: InputType<Src>;
49};
50export declare type Argument<Src> = {
51 kind: 'Argument';
52 type: InputType<Src>;
53 description?: string;
54};
55export declare type DefaultArgument<Src> = {
56 kind: 'DefaultArgument';
57 type: InputType<Src>;
58 description?: string;
59 default: Src;
60};
61export declare type ArgMap<T> = {
62 [K in keyof T]: DefaultArgument<T[K]> | Argument<T[K]>;
63};
64export declare type ArgMapValue<TArg> = TArg extends DefaultArgument<infer Src> ? Src : TArg extends Argument<infer Src> ? Src extends null ? Maybe<Src> : Src : never;
65export declare type TOfArgMap<TArgMap> = {
66 [K in keyof TArgMap]: ArgMapValue<TArgMap[K]>;
67};
68export declare type Field<Ctx, Src, Out, TArg extends object = {}> = {
69 kind: 'Field';
70 name: string;
71 description?: string;
72 type: OutputType<Ctx, Out>;
73 args: ArgMap<TArg>;
74 deprecationReason?: string;
75 resolve: (src: Src, args: TOfArgMap<ArgMap<TArg>>, ctx: Ctx, info: graphql.GraphQLResolveInfo) => Out | Promise<Out>;
76 extensions?: Record<string, any>;
77};
78export declare type AbstractField<Ctx, Out> = {
79 kind: 'AbstractField';
80 name: string;
81 description?: string;
82 deprecationReason?: string;
83 type: OutputType<Ctx, Out>;
84};
85export declare type ObjectType<Ctx, Src> = {
86 kind: 'ObjectType';
87 name: string;
88 description?: string;
89 deprecationReason?: string;
90 interfaces: Array<Interface<Ctx, any>>;
91 fieldsFn: () => Array<Field<Ctx, Src, any, any>>;
92 isTypeOf?: (src: any, ctx: Ctx, info: graphql.GraphQLResolveInfo) => boolean | Promise<boolean>;
93 extensions?: Record<string, any>;
94};
95export declare type InputField<Src> = {
96 type: InputType<Src>;
97 description?: string;
98};
99export declare type InputFieldMap<T> = {
100 [K in keyof T]: InputField<T[K]>;
101};
102export declare type InputObject<Src> = {
103 kind: 'InputObject';
104 name: string;
105 description?: string;
106 fieldsFn: () => InputFieldMap<Src>;
107};
108declare type ResolveType<Src, Ctx> = (src: Src, ctx: Ctx, info: graphql.GraphQLResolveInfo) => PromiseOrValue<Maybe<ObjectType<Ctx, Src | null> | string>>;
109export declare type Interface<Ctx, Src> = {
110 kind: 'Interface';
111 name: string;
112 description?: string;
113 interfaces: Array<Interface<Ctx, any>>;
114 fieldsFn: () => Array<AbstractField<Ctx, any>>;
115 resolveType?: ResolveType<Src, Ctx>;
116};
117export declare type Union<Ctx, Src> = {
118 kind: 'Union';
119 name: string;
120 types: Array<ObjectType<Ctx, Src>>;
121 resolveType: ResolveType<Src, Ctx>;
122};
123export declare type SubscriptionObject<Ctx, RootSrc> = {
124 kind: 'SubscriptionObject';
125 name: string;
126 fields: Array<SubscriptionField<Ctx, RootSrc, any, any>>;
127};
128export declare type SubscriptionField<Ctx, RootSrc, TArg, Out> = {
129 kind: 'SubscriptionField';
130 name: string;
131 description?: string;
132 type: OutputType<Ctx, Out>;
133 args: ArgMap<TArg>;
134 deprecationReason?: string;
135 subscribe: (source: RootSrc, args: TOfArgMap<ArgMap<TArg>>, ctx: Ctx, info: graphql.GraphQLResolveInfo) => PromiseOrValue<AsyncIterator<Out>>;
136 resolve?: (source: RootSrc, args: TOfArgMap<ArgMap<TArg>>, ctx: Ctx, info: graphql.GraphQLResolveInfo) => PromiseOrValue<Out>;
137};
138export declare type Schema<Ctx, RootSrc = undefined> = {
139 query: ObjectType<Ctx, RootSrc>;
140 mutation?: ObjectType<Ctx, RootSrc>;
141 subscription?: SubscriptionObject<Ctx, RootSrc>;
142 types?: ObjectType<Ctx, any>[];
143 directives?: graphql.GraphQLDirective[];
144};
145export {};