UNPKG

3.78 kBTypeScriptView Raw
1/**
2 * GraphQL types. See: http://graphql.org/docs/api-reference-type-system
3 */
4declare module "graphql/type" {
5 export abstract class GraphQLType {}
6
7 // Types
8 export type GraphQLOutputType =
9 GraphQLScalarType |
10 GraphQLObjectType |
11 GraphQLInterfaceType |
12 GraphQLUnionType |
13 GraphQLEnumType |
14 GraphQLList | //<GraphQLOutputType> |
15 GraphQLNonNull/*<
16 GraphQLScalarType |
17 GraphQLObjectType |
18 GraphQLInterfaceType |
19 GraphQLUnionType |
20 GraphQLEnumType |
21 GraphQLList<GraphQLOutputType>
22 >;*/
23
24 type TypeMap = { [typeName: string]: GraphQLType }
25
26 export class GraphQLDirective {
27 name: string;
28 description: string;
29 args: Array<GraphQLArgument>;
30 onOperation: boolean;
31 onFragment: boolean;
32 onField: boolean;
33 }
34
35 export interface GraphQLArgument {
36 name: string;
37 type: GraphQLInputType;
38 defaultValue?: any;
39 description?: string;
40 }
41
42 export type GraphQLInputType =
43 GraphQLScalarType |
44 GraphQLEnumType |
45 GraphQLInputObjectType |
46 GraphQLList | //<GraphQLInputType> |
47 GraphQLNonNull/*<
48 GraphQLScalarType |
49 GraphQLEnumType |
50 GraphQLInputObjectType |
51 GraphQLList<GraphQLInputType>
52 >;*/
53
54 // Schema
55 export class GraphQLSchema {
56 constructor(config: any)
57
58 getQueryType(): GraphQLObjectType;
59 getMutationType(): GraphQLObjectType;
60 getSubscriptionType(): GraphQLObjectType;
61 getTypeMap(): TypeMap;
62 getType(name: string): GraphQLType;
63 getDirectives(): Array<GraphQLDirective>;
64 getDirective(name: string): GraphQLDirective;
65 }
66
67 // Definitions
68 export class GraphQLScalarType extends GraphQLType {
69 name: string;
70 constructor(config: any)
71 }
72
73 export class GraphQLObjectType extends GraphQLType {
74 constructor(config: any);
75
76 name: string;
77 getFields(): GraphQLFieldDefinitionMap;
78 getInterfaces(): Array<GraphQLInterfaceType>;
79 }
80
81 export type GraphQLFieldDefinitionMap = {
82 [fieldName: string]: GraphQLFieldDefinition;
83 };
84
85 export type GraphQLFieldDefinition = {
86 name: string;
87 description: string;
88 type: GraphQLOutputType;
89 args: Array<GraphQLArgument>;
90 //resolve?: GraphQLFieldResolveFn;
91 deprecationReason?: string;
92 }
93
94 export class GraphQLInterfaceType extends GraphQLType {
95 name: string;
96 getFields(): GraphQLFieldDefinitionMap;
97 constructor(config: any)
98 }
99
100 export class GraphQLUnionType extends GraphQLType {
101 name: string;
102 constructor(config: any);
103 getTypes(): Array<GraphQLObjectType>;
104 }
105
106 export class GraphQLEnumType extends GraphQLType {
107 name: string;
108 description: string;
109
110 constructor(config: any);
111 getValues(): Array<GraphQLEnumValueDefinition/* <T> */>;
112 }
113
114 export type GraphQLEnumValueDefinition/* <T> */ = {
115 name: string;
116 description: string;
117 deprecationReason: string;
118 value: any/* T */;
119 }
120
121 export class GraphQLInputObjectType extends GraphQLType {
122 name: string;
123 getFields(): GraphQLFieldDefinitionMap;
124 constructor(config: any)
125 }
126
127 export class GraphQLList extends GraphQLType {
128 ofType: GraphQLType;
129 constructor(config: any)
130 }
131
132 export class GraphQLNonNull extends GraphQLType {
133 ofType: GraphQLType;
134 constructor(config: any)
135 }
136
137 // Scalars
138 export class GraphQLInt extends GraphQLScalarType { constructor(config: any) }
139 export class GraphQLFloat extends GraphQLScalarType { constructor(config: any) }
140 export class GraphQLString extends GraphQLScalarType { constructor(config: any) }
141 export class GraphQLBoolean extends GraphQLScalarType { constructor(config: any) }
142 export class GraphQLID extends GraphQLScalarType { constructor(config: any) }
143}