UNPKG

1.6 kBTypeScriptView Raw
1import { DocumentNode } from '../language/ast';
2import { Source } from '../language/source';
3import { GraphQLSchema, GraphQLSchemaValidationOptions } from '../type/schema';
4import { ParseOptions } from '../language/parser';
5
6export interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {
7 /**
8 * Descriptions are defined as preceding string literals, however an older
9 * experimental version of the SDL supported preceding comments as
10 * descriptions. Set to true to enable this deprecated behavior.
11 * This option is provided to ease adoption and will be removed in v16.
12 *
13 * Default: false
14 */
15 commentDescriptions?: boolean;
16
17 /**
18 * Set to true to assume the SDL is valid.
19 *
20 * Default: false
21 */
22 assumeValidSDL?: boolean;
23}
24
25/**
26 * This takes the ast of a schema document produced by the parse function in
27 * src/language/parser.js.
28 *
29 * If no schema definition is provided, then it will look for types named Query
30 * and Mutation.
31 *
32 * Given that AST it constructs a GraphQLSchema. The resulting schema
33 * has no resolve methods, so execution will use default resolvers.
34 *
35 * Accepts options as a second argument:
36 *
37 * - commentDescriptions:
38 * Provide true to use preceding comments as the description.
39 *
40 */
41export function buildASTSchema(
42 documentAST: DocumentNode,
43 options?: BuildSchemaOptions,
44): GraphQLSchema;
45
46/**
47 * A helper function to build a GraphQLSchema directly from a source
48 * document.
49 */
50export function buildSchema(
51 source: string | Source,
52 options?: BuildSchemaOptions & ParseOptions,
53): GraphQLSchema;