1 | import Maybe from '../tsutils/Maybe';
|
2 | import {
|
3 | DocumentNode,
|
4 | Location,
|
5 | StringValueNode,
|
6 | TypeDefinitionNode,
|
7 | NamedTypeNode,
|
8 | DirectiveDefinitionNode,
|
9 | FieldDefinitionNode,
|
10 | InputValueDefinitionNode,
|
11 | EnumValueDefinitionNode,
|
12 | TypeNode,
|
13 | } from '../language/ast';
|
14 | import {
|
15 | GraphQLNamedType,
|
16 | GraphQLFieldConfig,
|
17 | GraphQLInputField,
|
18 | GraphQLEnumValueConfig,
|
19 | GraphQLType,
|
20 | GraphQLArgumentConfig,
|
21 | GraphQLInputFieldConfig,
|
22 | } from '../type/definition';
|
23 | import { GraphQLDirective } from '../type/directives';
|
24 | import { Source } from '../language/source';
|
25 | import { GraphQLSchema, GraphQLSchemaValidationOptions } from '../type/schema';
|
26 | import { ParseOptions } from '../language/parser';
|
27 | import { dedentBlockStringValue } from '../language/blockString';
|
28 |
|
29 | interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | commentDescriptions?: boolean;
|
39 |
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | assumeValidSDL?: boolean;
|
46 | }
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | export function buildASTSchema(
|
65 | documentAST: DocumentNode,
|
66 | options?: BuildSchemaOptions,
|
67 | ): GraphQLSchema;
|
68 |
|
69 | type TypeDefinitionsMap = { [key: string]: TypeDefinitionNode };
|
70 | type TypeResolver = (typeRef: NamedTypeNode) => GraphQLNamedType;
|
71 |
|
72 | export class ASTDefinitionBuilder {
|
73 | constructor(options: Maybe<BuildSchemaOptions>, resolveType: TypeResolver);
|
74 |
|
75 | getNamedType(node: NamedTypeNode): GraphQLNamedType;
|
76 |
|
77 | getWrappedType(node: TypeNode): GraphQLType;
|
78 |
|
79 | buildDirective(directive: DirectiveDefinitionNode): GraphQLDirective;
|
80 |
|
81 | buildField(field: FieldDefinitionNode): GraphQLFieldConfig<any, any>;
|
82 |
|
83 | buildArg(value: InputValueDefinitionNode): GraphQLArgumentConfig;
|
84 |
|
85 | buildInputField(value: InputValueDefinitionNode): GraphQLInputFieldConfig;
|
86 |
|
87 | buildEnumValue(value: EnumValueDefinitionNode): GraphQLEnumValueConfig;
|
88 |
|
89 | buildType(node: NamedTypeNode | TypeDefinitionNode): GraphQLNamedType;
|
90 | }
|
91 |
|
92 | /**
|
93 | * Given an ast node, returns its string description.
|
94 | * @deprecated: provided to ease adoption and will be removed in v16.
|
95 | *
|
96 | * Accepts options as a second argument:
|
97 | *
|
98 | * - commentDescriptions:
|
99 | * Provide true to use preceding comments as the description.
|
100 | *
|
101 | */
|
102 | export function getDescription(
|
103 | node: { readonly description?: StringValueNode; readonly loc?: Location },
|
104 | options: Maybe<BuildSchemaOptions>,
|
105 | ): string | undefined;
|
106 |
|
107 | /**
|
108 | * A helper function to build a GraphQLSchema directly from a source
|
109 | * document.
|
110 | */
|
111 | export function buildSchema(
|
112 | source: string | Source,
|
113 | options?: BuildSchemaOptions & ParseOptions,
|
114 | ): GraphQLSchema;
|