├── .gitignore
├── LICENSE
├── README.md
├── graphql.d.ts
├── package.json
├── tsconfig.json
└── typings.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | *.log
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Nitin Tutlani (nitintutlani@yahoo.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Typed graphql-js
2 |
3 | The type definition for [`graphql-js`](https://github.com/graphql/graphql-js).
4 |
5 | ## Install using npm for Typescript 2
6 |
7 | ```bash
8 | npm install --save-dev typed-graphql
9 | ```
10 |
11 | ## Install latest using npm for Typescript 2
12 |
13 | ```bash
14 | npm install --save-dev git://github.com/nitintutlani/typed-graphql#master
15 | ```
16 |
17 | Add this to a typings.d.ts file.
18 | ```
19 | ///
20 | ```
21 |
22 | ## Install using [typings](https://www.npmjs.com/package/typings)
23 |
24 | ```bash
25 | typings install --save github:nitintutlani/typed-graphql
26 | ```
27 |
28 | ## Usage
29 |
30 | Follow these reference links for more information:
31 |
32 | [Typings project](https://www.npmjs.com/package/typings)
33 |
34 | [tsconfig.json documentation](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html)
35 |
36 | Make sure your typescript compatible code editor, linter and tsc compiler are able to reach out to `typings/index.d.ts` to resolve related references.
37 |
38 | ## License
39 |
40 | MIT
41 |
--------------------------------------------------------------------------------
/graphql.d.ts:
--------------------------------------------------------------------------------
1 | // graphql.js
2 | declare module graphql {
3 |
4 | export function graphql(
5 | schema: GraphQLSchema,
6 | requestString: string,
7 | rootValue?: any,
8 | contextValue?: any,
9 | variableValues?: { [key: string]: any },
10 | operationName?: string
11 | ): Promise;
12 |
13 | interface GraphQLResult {
14 | data?: any;
15 | errors?: Array;
16 | }
17 |
18 | // error/*.js
19 |
20 | class GraphQLError extends Error {
21 | constructor(
22 | message: string,
23 | nodes?: Array,
24 | stack?: string,
25 | source?: Source,
26 | positions?: Array
27 | );
28 | }
29 |
30 | export function formatError(error: GraphQLError): GraphQLFormattedError;
31 |
32 | interface GraphQLFormattedError {
33 | message: string;
34 | locations: Array;
35 | }
36 |
37 | interface GraphQLErrorLocation {
38 | line: number;
39 | column: number;
40 | }
41 |
42 | function locatedError(originalError: Error, nodes: Array): GraphQLError;
43 |
44 | function syntaxError(source: Source, position: number, description: string): GraphQLError;
45 |
46 | // execution/*.js
47 |
48 | interface ExecutionContext {
49 | schema: GraphQLSchema;
50 | fragments: { [key: string]: FragmentDefinition };
51 | rootValue: any;
52 | operation: OperationDefinition;
53 | variableValues: { [key: string]: any };
54 | errors: Array;
55 | }
56 |
57 | interface ExecutionResult {
58 | data: any;
59 | errors?: Array;
60 | }
61 |
62 | function execute(
63 | schema: GraphQLSchema,
64 | documentAST: Document,
65 | rootValue?: any,
66 | contextValue?: any,
67 | variableValues?: { [key: string]: any },
68 | operationName?: string
69 | ): Promise;
70 |
71 | function getVariableValues(
72 | schema: GraphQLSchema,
73 | definitionASTs: Array,
74 | inputs: { [key: string]: any }
75 | ): { [key: string]: any };
76 |
77 | function getArgumentValues(
78 | argDefs: Array,
79 | argASTs: Array,
80 | variableValues: { [key: string]: any }
81 | ): { [key: string]: any };
82 |
83 | // validation/*.js
84 |
85 | type ValidationRule = (context: ValidationContext) => any;
86 |
87 | export function validate(
88 | schema: GraphQLSchema,
89 | ast: Document,
90 | rules?: Array
91 | ): Array;
92 |
93 | export const specifiedRules: Array;
94 |
95 | type HasSelectionSet = OperationDefinition | FragmentDefinition;
96 | type VariableUsage = { node: Variable, type: GraphQLInputType };
97 |
98 | class ValidationContext {
99 | constructor(schema: GraphQLSchema, ast: Document, typeInfo: TypeInfo);
100 | reportError(error: GraphQLError): void;
101 | getErrors(): Array;
102 | getSchema(): GraphQLSchema;
103 | getDocument(): Document;
104 | getFragment(name: string): FragmentDefinition;
105 | getFragmentSpreads(node: SelectionSet): Array;
106 | getRecursivelyReferencedFragments(
107 | operation: OperationDefinition
108 | ): Array;
109 | getVariableUsages(node: HasSelectionSet): Array;
110 | getRecursiveVariableUsages(
111 | operation: OperationDefinition
112 | ): Array;
113 | getType(): GraphQLOutputType;
114 | getParentType(): GraphQLCompositeType;
115 | getInputType(): GraphQLInputType;
116 | getFieldDef(): GraphQLFieldDefinition;
117 | getDirective(): GraphQLDirective;
118 | getArgument(): GraphQLArgument;
119 | }
120 |
121 | // jsutils/*.js
122 |
123 | function find(list: Array, predicate: (item: T) => boolean): T;
124 | function invariant(condition: any, message: string): void;
125 | function isNullish(value: any): boolean;
126 | function keyMap(
127 | list: Array,
128 | keyFn: (item: T) => string
129 | ): { [key: string]: T };
130 | function keyValMap(
131 | list: Array,
132 | keyFn: (item: T) => string,
133 | valFn: (item: T) => V
134 | ): { [key: string]: V }
135 |
136 | // language/ast.js
137 | interface Location {
138 | start: number;
139 | end: number;
140 | source?: Source;
141 | }
142 |
143 | type Node = Name
144 | | Document
145 | | OperationDefinition
146 | | VariableDefinition
147 | | Variable
148 | | SelectionSet
149 | | Field
150 | | Argument
151 | | FragmentSpread
152 | | InlineFragment
153 | | FragmentDefinition
154 | | IntValue
155 | | FloatValue
156 | | StringValue
157 | | BooleanValue
158 | | EnumValue
159 | | ListValue
160 | | ObjectValue
161 | | ObjectField
162 | | Directive
163 | | ListType
164 | | NonNullType
165 | | ObjectTypeDefinition
166 | | FieldDefinition
167 | | InputValueDefinition
168 | | InterfaceTypeDefinition
169 | | UnionTypeDefinition
170 | | ScalarTypeDefinition
171 | | EnumTypeDefinition
172 | | EnumValueDefinition
173 | | InputObjectTypeDefinition
174 | | TypeExtensionDefinition;
175 |
176 | interface Name {
177 | kind: string;
178 | loc?: Location;
179 | value: string;
180 | }
181 |
182 | interface Document {
183 | kind: string;
184 | loc?: Location;
185 | definitions: Array;
186 | }
187 |
188 | type Definition = OperationDefinition
189 | | FragmentDefinition
190 | | TypeDefinition;
191 |
192 | interface OperationDefinition {
193 | kind: string;
194 | loc?: Location;
195 | // Note: subscription is an experimental non-spec addition.
196 | operation: string;
197 | name?: Name;
198 | variableDefinitions?: Array;
199 | directives?: Array;
200 | selectionSet: SelectionSet;
201 | }
202 |
203 | interface VariableDefinition {
204 | kind: string;
205 | loc?: Location;
206 | variable: Variable;
207 | type: Type;
208 | defaultValue?: Value;
209 | }
210 |
211 | interface Variable {
212 | kind: string;
213 | loc?: Location;
214 | name: Name;
215 | }
216 |
217 | interface SelectionSet {
218 | kind: string;
219 | loc?: Location;
220 | selections: Array;
221 | }
222 |
223 | type Selection = Field
224 | | FragmentSpread
225 | | InlineFragment;
226 |
227 | interface Field {
228 | kind: string;
229 | loc?: Location;
230 | alias?: Name;
231 | name: Name;
232 | arguments?: Array;
233 | directives?: Array;
234 | selectionSet?: SelectionSet;
235 | }
236 |
237 | interface Argument {
238 | kind: string;
239 | loc?: Location;
240 | name: Name;
241 | value: Value;
242 | }
243 |
244 |
245 | // Fragments
246 |
247 | interface FragmentSpread {
248 | kind: string;
249 | loc?: Location;
250 | name: Name;
251 | directives?: Array;
252 | }
253 |
254 | interface InlineFragment {
255 | kind: string;
256 | loc?: Location;
257 | typeCondition?: NamedType;
258 | directives?: Array;
259 | selectionSet: SelectionSet;
260 | }
261 |
262 | interface FragmentDefinition {
263 | kind: string;
264 | loc?: Location;
265 | name: Name;
266 | typeCondition: NamedType;
267 | directives?: Array;
268 | selectionSet: SelectionSet;
269 | }
270 |
271 |
272 | // Values
273 |
274 | type Value = Variable
275 | | IntValue
276 | | FloatValue
277 | | StringValue
278 | | BooleanValue
279 | | EnumValue
280 | | ListValue
281 | | ObjectValue;
282 |
283 | interface IntValue {
284 | kind: string;
285 | loc?: Location;
286 | value: string;
287 | }
288 |
289 | interface FloatValue {
290 | kind: string;
291 | loc?: Location;
292 | value: string;
293 | }
294 |
295 | interface StringValue {
296 | kind: string;
297 | loc?: Location;
298 | value: string;
299 | }
300 |
301 | interface BooleanValue {
302 | kind: string;
303 | loc?: Location;
304 | value: boolean;
305 | }
306 |
307 | interface EnumValue {
308 | kind: string;
309 | loc?: Location;
310 | value: string;
311 | }
312 |
313 | interface ListValue {
314 | kind: string;
315 | loc?: Location;
316 | values: Array;
317 | }
318 |
319 | interface ObjectValue {
320 | kind: string;
321 | loc?: Location;
322 | fields: Array;
323 | }
324 |
325 | interface ObjectField {
326 | kind: string;
327 | loc?: Location;
328 | name: Name;
329 | value: Value;
330 | }
331 |
332 |
333 | // Directives
334 |
335 | interface Directive {
336 | kind: string;
337 | loc?: Location;
338 | name: Name;
339 | arguments?: Array;
340 | }
341 |
342 |
343 | // Type Reference
344 |
345 | type Type = NamedType
346 | | ListType
347 | | NonNullType;
348 |
349 | interface NamedType {
350 | kind: string;
351 | loc?: Location;
352 | name: Name;
353 | }
354 |
355 | interface ListType {
356 | kind: string;
357 | loc?: Location;
358 | type: Type;
359 | }
360 |
361 | interface NonNullType {
362 | kind: string;
363 | loc?: Location;
364 | type: NamedType | ListType;
365 | }
366 |
367 | // Type Definition
368 |
369 | type TypeDefinition = ObjectTypeDefinition
370 | | InterfaceTypeDefinition
371 | | UnionTypeDefinition
372 | | ScalarTypeDefinition
373 | | EnumTypeDefinition
374 | | InputObjectTypeDefinition
375 | | TypeExtensionDefinition;
376 |
377 | interface ObjectTypeDefinition {
378 | kind: string;
379 | loc?: Location;
380 | name: Name;
381 | interfaces?: Array;
382 | fields: Array;
383 | }
384 |
385 | interface FieldDefinition {
386 | kind: string;
387 | loc?: Location;
388 | name: Name;
389 | arguments: Array;
390 | type: Type;
391 | }
392 |
393 | interface InputValueDefinition {
394 | kind: string;
395 | loc?: Location;
396 | name: Name;
397 | type: Type;
398 | defaultValue?: Value;
399 | }
400 |
401 | interface InterfaceTypeDefinition {
402 | kind: string;
403 | loc?: Location;
404 | name: Name;
405 | fields: Array;
406 | }
407 |
408 | interface UnionTypeDefinition {
409 | kind: string;
410 | loc?: Location;
411 | name: Name;
412 | types: Array;
413 | }
414 |
415 | interface ScalarTypeDefinition {
416 | kind: string;
417 | loc?: Location;
418 | name: Name;
419 | }
420 |
421 | interface EnumTypeDefinition {
422 | kind: string;
423 | loc?: Location;
424 | name: Name;
425 | values: Array;
426 | }
427 |
428 | interface EnumValueDefinition {
429 | kind: string;
430 | loc?: Location;
431 | name: Name;
432 | }
433 |
434 | interface InputObjectTypeDefinition {
435 | kind: string;
436 | loc?: Location;
437 | name: Name;
438 | fields: Array;
439 | }
440 |
441 | interface TypeExtensionDefinition {
442 | kind: string;
443 | loc?: Location;
444 | definition: ObjectTypeDefinition;
445 | }
446 |
447 | // language/kinds.js
448 | namespace Kind {
449 | const NAME: string;
450 |
451 | // Document
452 |
453 | const DOCUMENT: string;
454 | const OPERATION_DEFINITION: string;
455 | const VARIABLE_DEFINITION: string;
456 | const VARIABLE: string;
457 | const SELECTION_SET: string;
458 | const FIELD: string;
459 | const ARGUMENT: string;
460 |
461 | // Fragments
462 |
463 | const FRAGMENT_SPREAD: string;
464 | const INLINE_FRAGMENT: string;
465 | const FRAGMENT_DEFINITION: string;
466 |
467 | // Values
468 |
469 | const INT: string;
470 | const FLOAT: string;
471 | const STRING: string;
472 | const BOOLEAN: string;
473 | const ENUM: string;
474 | const LIST: string;
475 | const OBJECT: string;
476 | const OBJECT_FIELD: string;
477 |
478 | // Directives
479 |
480 | const DIRECTIVE: string;
481 |
482 | // Types
483 |
484 | const NAMED_TYPE: string;
485 | const LIST_TYPE: string;
486 | const NON_NULL_TYPE: string;
487 |
488 | // Type Definitions
489 |
490 | const OBJECT_TYPE_DEFINITION: string;
491 | const FIELD_DEFINITION: string;
492 | const INPUT_VALUE_DEFINITION: string;
493 | const INTERFACE_TYPE_DEFINITION: string;
494 | const UNION_TYPE_DEFINITION: string;
495 | const SCALAR_TYPE_DEFINITION: string;
496 | const ENUM_TYPE_DEFINITION: string;
497 | const ENUM_VALUE_DEFINITION: string;
498 | const INPUT_OBJECT_TYPE_DEFINITION: string;
499 | const TYPE_EXTENSION_DEFINITION: string;
500 | }
501 |
502 | // language/lexer.js
503 |
504 | interface Token {
505 | kind: number;
506 | start: number;
507 | end: number;
508 | value: string;
509 | }
510 |
511 | type Lexer = (resetPosition?: number) => Token;
512 |
513 | function lex(source: Source): Lexer;
514 |
515 | type TokenKind = { [key: string]: number };
516 |
517 | function getTokenDesc(token: Token): string;
518 | function getTokenKindDesc(kind: number): string;
519 |
520 | // language/location.js
521 |
522 | interface SourceLocation {
523 | line: number;
524 | column: number;
525 | }
526 |
527 | function getLocation(source: Source, position: number): SourceLocation;
528 |
529 | // language/parser.js
530 |
531 | interface ParseOptions {
532 | noLocation?: boolean;
533 | noSource?: boolean;
534 | }
535 |
536 | function parse(
537 | source: Source | string,
538 | options?: ParseOptions
539 | ): Document;
540 |
541 | function parseValue(
542 | source: Source | string,
543 | options?: ParseOptions
544 | ): Value;
545 |
546 | function parseConstValue(parser: any): Value;
547 |
548 | function parseType(parser: any): Type;
549 |
550 | function parseNamedType(parser: any): NamedType;
551 |
552 | // language/printer.js
553 |
554 | function print(ast: any): string;
555 |
556 | // language/source.js
557 |
558 | class Source {
559 | body: string;
560 | name: string;
561 | constructor(body: string, name?: string);
562 | }
563 |
564 | // language/visitor.js
565 |
566 | interface QueryDocumentKeys {
567 | Name: any[];
568 | Document: string[];
569 | OperationDefinition: string[];
570 | VariableDefinition: string[];
571 | Variable: string[];
572 | SelectionSet: string[];
573 | Field: string[];
574 | Argument: string[];
575 |
576 | FragmentSpread: string[];
577 | InlineFragment: string[];
578 | FragmentDefinition: string[];
579 |
580 | IntValue: number[];
581 | FloatValue: number[];
582 | StringValue: string[];
583 | BooleanValue: boolean[];
584 | EnumValue: any[];
585 | ListValue: string[];
586 | ObjectValue: string[];
587 | ObjectField: string[];
588 |
589 | Directive: string[];
590 |
591 | NamedType: string[];
592 | ListType: string[];
593 | NonNullType: string[];
594 |
595 | ObjectTypeDefinition: string[];
596 | FieldDefinition: string[];
597 | InputValueDefinition: string[];
598 | InterfaceTypeDefinition: string[];
599 | UnionTypeDefinition: string[];
600 | ScalarTypeDefinition: string[];
601 | EnumTypeDefinition: string[];
602 | EnumValueDefinition: string[];
603 | InputObjectTypeDefinition: string[];
604 | TypeExtensionDefinition: string[];
605 | }
606 |
607 | const BREAK: Object;
608 |
609 | function visit(root: any, visitor: any, keyMap: any): any;
610 |
611 | function visitInParallel(visitors: any): any;
612 |
613 | function visitWithTypeInfo(typeInfo: any, visitor: any): any;
614 |
615 | // type/definition.js
616 |
617 | type GraphQLType =
618 | GraphQLScalarType |
619 | GraphQLObjectType |
620 | GraphQLInterfaceType |
621 | GraphQLUnionType |
622 | GraphQLEnumType |
623 | GraphQLInputObjectType |
624 | GraphQLList |
625 | GraphQLNonNull;
626 |
627 | function isType(type: any): boolean;
628 |
629 | type GraphQLInputType =
630 | GraphQLScalarType |
631 | GraphQLEnumType |
632 | GraphQLInputObjectType |
633 | GraphQLList |
634 | GraphQLNonNull;
635 |
636 | function isInputType(type: GraphQLType): boolean;
637 |
638 | type GraphQLOutputType =
639 | GraphQLScalarType |
640 | GraphQLObjectType |
641 | GraphQLInterfaceType |
642 | GraphQLUnionType |
643 | GraphQLEnumType |
644 | GraphQLList |
645 | GraphQLNonNull;
646 |
647 | function isOutputType(type: GraphQLType): boolean;
648 |
649 | type GraphQLLeafType =
650 | GraphQLScalarType |
651 | GraphQLEnumType;
652 |
653 | function isLeafType(type: GraphQLType): boolean;
654 |
655 | type GraphQLCompositeType =
656 | GraphQLObjectType |
657 | GraphQLInterfaceType |
658 | GraphQLUnionType;
659 |
660 | function isCompositeType(type: GraphQLType): boolean;
661 |
662 | type GraphQLAbstractType =
663 | GraphQLInterfaceType |
664 | GraphQLUnionType;
665 |
666 | function isAbstractType(type: GraphQLType): boolean;
667 |
668 | type GraphQLNullableType =
669 | GraphQLScalarType |
670 | GraphQLObjectType |
671 | GraphQLInterfaceType |
672 | GraphQLUnionType |
673 | GraphQLEnumType |
674 | GraphQLInputObjectType |
675 | GraphQLList;
676 |
677 | function getNullableType(type: GraphQLType): GraphQLNullableType;
678 |
679 | type GraphQLNamedType =
680 | GraphQLScalarType |
681 | GraphQLObjectType |
682 | GraphQLInterfaceType |
683 | GraphQLUnionType |
684 | GraphQLEnumType |
685 | GraphQLInputObjectType;
686 |
687 | function getNamedType(type: GraphQLType): GraphQLNamedType;
688 |
689 | export class GraphQLScalarType {
690 | name: string;
691 | constructor(config: GraphQLScalarTypeConfig);
692 | serialize(value: any): any;
693 | parseValue(value: any): any;
694 | parseLiteral(valueAST: Value): any;
695 | toString(): string;
696 | }
697 |
698 | interface GraphQLScalarTypeConfig {
699 | name: string;
700 | description?: string;
701 | serialize: (value: any) => any;
702 | parseValue?: (value: any) => any;
703 | parseLiteral?: (valueAST: Value) => any;
704 | }
705 |
706 | export class GraphQLObjectType {
707 | name: string;
708 | constructor(config: GraphQLObjectTypeConfig);
709 | getFields(): GraphQLFieldDefinitionMap;
710 | getInterfaces(): Array;
711 | toString(): string;
712 | }
713 |
714 | interface GraphQLObjectTypeConfig {
715 | name: string;
716 | interfaces?: GraphQLInterfacesThunk | Array;
717 | fields: GraphQLFieldConfigMapThunk | GraphQLFieldConfigMap;
718 | isTypeOf?: GraphQLIsTypeOfFn;
719 | description?: string;
720 | }
721 |
722 | type GraphQLInterfacesThunk = () => Array;
723 |
724 | type GraphQLFieldConfigMapThunk = () => GraphQLFieldConfigMap;
725 |
726 | type GraphQLFieldResolveFn = (
727 | source: any,
728 | args: { [argName: string]: any },
729 | context: any,
730 | info: GraphQLResolveInfo
731 | ) => any;
732 |
733 | type GraphQLTypeResolveFn = (
734 | value: any,
735 | context: any,
736 | info: GraphQLResolveInfo
737 | ) => GraphQLObjectType;
738 |
739 | export type GraphQLIsTypeOfFn = (
740 | source: any,
741 | context: any,
742 | info: GraphQLResolveInfo
743 | ) => boolean;
744 |
745 | interface GraphQLResolveInfo {
746 | fieldName: string;
747 | fieldASTs: Array;
748 | returnType: GraphQLOutputType;
749 | parentType: GraphQLCompositeType;
750 | schema: GraphQLSchema;
751 | fragments: { [fragmentName: string]: FragmentDefinition };
752 | rootValue: any;
753 | operation: OperationDefinition;
754 | variableValues: { [variableName: string]: any };
755 | }
756 |
757 | interface GraphQLFieldConfig {
758 | type: GraphQLOutputType;
759 | args?: GraphQLFieldConfigArgumentMap;
760 | resolve?: GraphQLFieldResolveFn;
761 | deprecationReason?: string;
762 | description?: string;
763 | }
764 |
765 | interface GraphQLFieldConfigArgumentMap {
766 | [argName: string]: GraphQLArgumentConfig;
767 | }
768 |
769 | interface GraphQLArgumentConfig {
770 | type: GraphQLInputType;
771 | defaultValue?: any;
772 | description?: string;
773 | }
774 |
775 | interface GraphQLFieldConfigMap {
776 | [fieldName: string]: GraphQLFieldConfig;
777 | }
778 |
779 | interface GraphQLFieldDefinition {
780 | name: string;
781 | description: string;
782 | type: GraphQLOutputType;
783 | args: Array;
784 | resolve?: GraphQLFieldResolveFn;
785 | deprecationReason?: string;
786 | }
787 |
788 | interface GraphQLArgument {
789 | name: string;
790 | type: GraphQLInputType;
791 | defaultValue?: any;
792 | description?: string;
793 | }
794 |
795 | interface GraphQLFieldDefinitionMap {
796 | [fieldName: string]: GraphQLFieldDefinition;
797 | }
798 |
799 | export class GraphQLInterfaceType {
800 | name: string;
801 | description: string;
802 | resolveType: GraphQLTypeResolveFn;
803 | constructor(config: GraphQLInterfaceTypeConfig);
804 | getFields(): GraphQLFieldDefinitionMap;
805 | getPossibleTypes(): Array;
806 | isPossibleType(type: GraphQLObjectType): boolean;
807 | getObjectType(value: any, info: GraphQLResolveInfo): GraphQLObjectType;
808 | toString(): string;
809 | }
810 |
811 | interface GraphQLInterfaceTypeConfig {
812 | name: string;
813 | fields: GraphQLFieldConfigMapThunk | GraphQLFieldConfigMap;
814 | resolveType?: GraphQLTypeResolveFn;
815 | description?: string;
816 | }
817 |
818 | export class GraphQLUnionType {
819 | name: string;
820 | description: string;
821 | resolveType: GraphQLTypeResolveFn;
822 | constructor(config: GraphQLUnionTypeConfig);
823 | getTypes(): Array
824 | toString(): string;
825 | }
826 |
827 |
828 | interface GraphQLUnionTypeConfig {
829 | name: string;
830 | types: Array;
831 | /**
832 | * Optionally provide a custom type resolver function. If one is not provided,
833 | * the default implementation will call `isTypeOf` on each implementing
834 | * Object type.
835 | */
836 | resolveType?: GraphQLTypeResolveFn;
837 | description?: string;
838 | }
839 |
840 | export class GraphQLEnumType {
841 | name: string;
842 | description: string;
843 | constructor(config: GraphQLEnumTypeConfig);
844 | getValues(): Array;
845 | serialize(value: any): string;
846 | parseValue(value: any): any;
847 | parseLiteral(valueAST: Value): any;
848 | toString(): string;
849 | }
850 |
851 | interface GraphQLEnumTypeConfig {
852 | name: string;
853 | values: GraphQLEnumValueConfigMap;
854 | description?: string;
855 | }
856 |
857 | interface GraphQLEnumValueConfigMap {
858 | [valueName: string]: GraphQLEnumValueConfig;
859 | }
860 |
861 | interface GraphQLEnumValueConfig {
862 | value?: any;
863 | deprecationReason?: string;
864 | description?: string;
865 | }
866 |
867 | interface GraphQLEnumValueDefinition {
868 | name: string;
869 | description: string;
870 | deprecationReason: string;
871 | value: any;
872 | }
873 |
874 | export class GraphQLInputObjectType {
875 | name: string;
876 | description: string;
877 | constructor(config: InputObjectConfig);
878 | getFields(): InputObjectFieldMap;
879 | toString(): string;
880 | }
881 |
882 | interface InputObjectConfig {
883 | name: string;
884 | fields: InputObjectConfigFieldMapThunk | InputObjectConfigFieldMap;
885 | description?: string;
886 | }
887 |
888 | type InputObjectConfigFieldMapThunk = () => InputObjectConfigFieldMap;
889 |
890 | interface InputObjectFieldConfig {
891 | type: GraphQLInputType;
892 | defaultValue?: any;
893 | description?: string;
894 | }
895 |
896 | interface InputObjectConfigFieldMap {
897 | [fieldName: string]: InputObjectFieldConfig;
898 | }
899 |
900 | interface InputObjectField {
901 | name: string;
902 | type: GraphQLInputType;
903 | defaultValue?: any;
904 | description?: string;
905 | }
906 |
907 | interface InputObjectFieldMap {
908 | [fieldName: string]: InputObjectField;
909 | }
910 |
911 | export class GraphQLList {
912 | ofType: GraphQLType;
913 | constructor(type: GraphQLType);
914 | toString(): string;
915 | }
916 |
917 | export class GraphQLNonNull {
918 | ofType: GraphQLNullableType;
919 | constructor(type: GraphQLNullableType);
920 | toString(): string;
921 | }
922 |
923 | // type/directives.js
924 |
925 | class GraphQLDirective {
926 | name: string;
927 | description: string;
928 | args: Array;
929 | onOperation: boolean;
930 | onFragment: boolean;
931 | onField: boolean;
932 | constructor(config: GraphQLDirectiveConfig);
933 | }
934 |
935 | interface GraphQLDirectiveConfig {
936 | name: string;
937 | description?: string;
938 | args?: Array;
939 | onOperation?: boolean;
940 | onFragment?: boolean;
941 | onField?: boolean;
942 | }
943 |
944 | export var GraphQLIncludeDirective: GraphQLDirective;
945 |
946 | export var GraphQLSkipDirective: GraphQLDirective;
947 |
948 | // type/introspection.js
949 |
950 | var __Schema: GraphQLObjectType;
951 |
952 | type TypeKind = { [key: string]: string };
953 |
954 | var SchemaMetaFieldDef: GraphQLFieldDefinition;
955 |
956 | var TypeMetaFieldDef: GraphQLFieldDefinition;
957 |
958 | var TypeNameMetaFieldDef: GraphQLFieldDefinition;
959 |
960 | // type/scalars.js
961 |
962 | export var GraphQLInt: GraphQLScalarType;
963 | export var GraphQLFloat: GraphQLScalarType;
964 | export var GraphQLString: GraphQLScalarType;
965 | export var GraphQLBoolean: GraphQLScalarType;
966 | export var GraphQLID: GraphQLScalarType;
967 |
968 | // type/schema.js
969 |
970 | export class GraphQLSchema {
971 | constructor(config: GraphQLSchemaConfig);
972 | getQueryType(): GraphQLObjectType;
973 | getMutationType(): GraphQLObjectType;
974 | getSubscriptionType(): GraphQLObjectType;
975 | getTypeMap(): TypeMap;
976 | getType(name: string): GraphQLType;
977 | getDirectives(): Array;
978 | getDirective(name: string): GraphQLDirective;
979 | getPossibleTypes(abstractType: GraphQLAbstractType): Array;
980 | }
981 |
982 | type TypeMap = { [typeName: string]: GraphQLType };
983 |
984 | interface GraphQLSchemaConfig {
985 | query: GraphQLObjectType;
986 | mutation?: GraphQLObjectType;
987 | subscription?: GraphQLObjectType;
988 | directives?: Array;
989 | types?: Array;
990 | }
991 |
992 | // utilities/Typeinfo.js
993 |
994 | class TypeInfo {
995 | constructor(
996 | schema: GraphQLSchema,
997 | getFieldDefFn?: typeof getFieldDef
998 | );
999 |
1000 | getType(): GraphQLOutputType;
1001 | getParentType(): GraphQLCompositeType;
1002 | getInputType(): GraphQLInputType;
1003 | getFieldDef(): GraphQLFieldDefinition;
1004 | getDirective(): GraphQLDirective;
1005 | getArgument(): GraphQLArgument;
1006 | enter(node: Node): void;
1007 | leave(node: Node): void;
1008 | }
1009 |
1010 | function getFieldDef(
1011 | schema: GraphQLSchema,
1012 | parentType: GraphQLType,
1013 | fieldAST: Field
1014 | ): GraphQLFieldDefinition;
1015 |
1016 | // utilities/valueFromAST.js
1017 | function valueFromAST(
1018 | valueAST: Value,
1019 | type: GraphQLInputType,
1020 | variables?: { [key: string]: any }
1021 | ): any;
1022 |
1023 | // utilities/buildASTSchema.js
1024 | function buildASTSchema(ast: Document): GraphQLSchema
1025 | function buildSchema(source: string | Source): GraphQLSchema
1026 |
1027 | // utilities/extendSchema.js
1028 | function extendSchema(schema: GraphQLSchema, documentAST: Document): GraphQLSchema
1029 |
1030 | // utilities/schemaPrinter.js
1031 | function printSchema(schema: GraphQLSchema): string;
1032 | function printIntrospectionSchema(schema: GraphQLSchema): string;
1033 |
1034 | // type/directives.js
1035 | enum DirectiveLocationEnum {
1036 | QUERY,
1037 | MUTATION,
1038 | SUBSCRIPTION,
1039 | FIELD,
1040 | FRAGMENT_DEFINITION,
1041 | FRAGMENT_SPREAD,
1042 | INLINE_FRAGMENT,
1043 | }
1044 |
1045 | // utilities/introspectionQuery
1046 | export const introspectionQuery: string;
1047 |
1048 | interface IntrospectionQuery {
1049 | __schema: IntrospectionSchema;
1050 | }
1051 |
1052 | interface IntrospectionSchema {
1053 | queryType: IntrospectionNamedTypeRef;
1054 | mutationType?: IntrospectionNamedTypeRef;
1055 | subscriptionType?: IntrospectionNamedTypeRef;
1056 | types: Array;
1057 | directives: Array;
1058 | }
1059 |
1060 | type IntrospectionType =
1061 | IntrospectionScalarType |
1062 | IntrospectionObjectType |
1063 | IntrospectionInterfaceType |
1064 | IntrospectionUnionType |
1065 | IntrospectionEnumType |
1066 | IntrospectionInputObjectType
1067 |
1068 | interface IntrospectionScalarType {
1069 | kind: 'SCALAR';
1070 | name: string;
1071 | description?: string;
1072 | }
1073 |
1074 | interface IntrospectionObjectType {
1075 | kind: 'OBJECT';
1076 | name: string;
1077 | description?: string;
1078 | fields: Array;
1079 | interfaces: Array;
1080 | }
1081 |
1082 | interface IntrospectionInterfaceType {
1083 | kind: 'INTERFACE';
1084 | name: string;
1085 | description?: string;
1086 | fields: Array;
1087 | possibleTypes: Array;
1088 | }
1089 |
1090 | interface IntrospectionUnionType {
1091 | kind: 'UNION';
1092 | name: string;
1093 | description?: string;
1094 | possibleTypes: Array;
1095 | }
1096 |
1097 | interface IntrospectionEnumType {
1098 | kind: 'ENUM';
1099 | name: string;
1100 | description?: string;
1101 | enumValues: Array;
1102 | }
1103 |
1104 | interface IntrospectionInputObjectType {
1105 | kind: 'INPUT_OBJECT';
1106 | name: string;
1107 | description?: string;
1108 | inputFields: Array;
1109 | }
1110 |
1111 | type IntrospectionTypeRef =
1112 | IntrospectionNamedTypeRef |
1113 | IntrospectionListTypeRef |
1114 | IntrospectionNonNullTypeRef
1115 |
1116 | interface IntrospectionNamedTypeRef {
1117 | kind: string;
1118 | name: string;
1119 | }
1120 |
1121 | interface IntrospectionListTypeRef {
1122 | kind: 'LIST';
1123 | ofType?: IntrospectionTypeRef;
1124 | }
1125 |
1126 | interface IntrospectionNonNullTypeRef {
1127 | kind: 'NON_NULL';
1128 | ofType?: IntrospectionTypeRef;
1129 | }
1130 |
1131 | interface IntrospectionField {
1132 | name: string;
1133 | description?: string;
1134 | args: Array;
1135 | type: IntrospectionTypeRef;
1136 | isDeprecated: boolean;
1137 | deprecationReason?: string;
1138 | }
1139 |
1140 | interface IntrospectionInputValue {
1141 | name: string;
1142 | description?: string;
1143 | type: IntrospectionTypeRef;
1144 | defaultValue?: string;
1145 | }
1146 |
1147 | interface IntrospectionEnumValue {
1148 | name: string;
1149 | description?: string;
1150 | isDeprecated: boolean;
1151 | deprecationReason?: string;
1152 | }
1153 |
1154 | interface IntrospectionDirective {
1155 | name: string;
1156 | description?: string;
1157 | locations: Array;
1158 | args: Array;
1159 | }
1160 |
1161 | // utilities/buildClientSchema.js
1162 | export function buildClientSchema(
1163 | introspection: IntrospectionQuery
1164 | ): GraphQLSchema
1165 | }
1166 |
1167 | declare module "graphql" {
1168 | export = graphql;
1169 | }
1170 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typed-graphql",
3 | "version": "1.0.3",
4 | "description": "Type definitions for graphql-js",
5 | "main": "index.js",
6 | "scripts": {
7 | "compile": "tsc graphql.d.ts",
8 | "test": "npm run compile"
9 | },
10 | "devDependencies": {
11 | "@types/es6-promise": "0.0.32",
12 | "typescript": "^2.1.6"
13 | },
14 | "typings": "./graphql.d.ts",
15 | "repository": {
16 | "type": "git",
17 | "url": "git+https://github.com/nitintutlani/typed-graphql.git"
18 | },
19 | "author": "Nitin Tutlani ",
20 | "license": "MIT",
21 | "bugs": {
22 | "url": "https://github.com/NewSpring/typed-graphql/issues"
23 | },
24 | "homepage": "https://github.com/NewSpring/typed-graphql#readme"
25 | }
26 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6"
4 | },
5 | "files": [
6 | "graphql.d.ts"
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "graphql",
3 | "main": "graphql.d.ts",
4 | "author": "Nitin Tutlani "
5 | }
6 |
--------------------------------------------------------------------------------