forked from graphql/graphql-js
/
schema.d.ts
141 lines (124 loc) · 4.3 KB
/
schema.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// FIXME
/* eslint-disable import/no-cycle */
import { Maybe } from '../jsutils/Maybe';
import { ObjMap } from '../jsutils/ObjMap';
import { SchemaDefinitionNode, SchemaExtensionNode } from '../language/ast';
import { GraphQLDirective } from './directives';
import {
GraphQLNamedType,
GraphQLAbstractType,
GraphQLObjectType,
GraphQLInterfaceType,
} from './definition';
/**
* Test if the given value is a GraphQL schema.
*/
export function isSchema(schema: unknown): schema is GraphQLSchema;
export function assertSchema(schema: unknown): GraphQLSchema;
/**
* Custom extensions
*
* @remarks
* Use a unique identifier name for your extension, for example the name of
* your library or project. Do not use a shortened identifier as this increases
* the risk of conflicts. We recommend you add at most one extension field,
* an object which can contain all the values you need.
*/
export interface GraphQLSchemaExtensions {
[attributeName: string]: any;
}
/**
* Schema Definition
*
* A Schema is created by supplying the root types of each type of operation,
* query and mutation (optional). A schema definition is then supplied to the
* validator and executor.
*
* Example:
*
* const MyAppSchema = new GraphQLSchema({
* query: MyAppQueryRootType,
* mutation: MyAppMutationRootType,
* })
*
* Note: If an array of `directives` are provided to GraphQLSchema, that will be
* the exact list of directives represented and allowed. If `directives` is not
* provided then a default set of the specified directives (e.g. @include and
* @skip) will be used. If you wish to provide *additional* directives to these
* specified directives, you must explicitly declare them. Example:
*
* const MyAppSchema = new GraphQLSchema({
* ...
* directives: specifiedDirectives.concat([ myCustomDirective ]),
* })
*
*/
export class GraphQLSchema {
description: Maybe<string>;
extensions: Maybe<Readonly<GraphQLSchemaExtensions>>;
astNode: Maybe<SchemaDefinitionNode>;
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
constructor(config: Readonly<GraphQLSchemaConfig>);
getQueryType(): Maybe<GraphQLObjectType>;
getMutationType(): Maybe<GraphQLObjectType>;
getSubscriptionType(): Maybe<GraphQLObjectType>;
getTypeMap(): TypeMap;
getType(name: string): Maybe<GraphQLNamedType>;
getPossibleTypes(
abstractType: GraphQLAbstractType,
): ReadonlyArray<GraphQLObjectType>;
getImplementations(
interfaceType: GraphQLInterfaceType,
): InterfaceImplementations;
isSubType(
abstractType: GraphQLAbstractType,
maybeSubType: GraphQLObjectType | GraphQLInterfaceType,
): boolean;
getDirectives(): ReadonlyArray<GraphQLDirective>;
getDirective(name: string): Maybe<GraphQLDirective>;
toConfig(): GraphQLSchemaConfig & {
types: Array<GraphQLNamedType>;
directives: Array<GraphQLDirective>;
extensions: Maybe<Readonly<GraphQLSchemaExtensions>>;
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
assumeValid: boolean;
};
get [Symbol.toStringTag](): string;
}
type TypeMap = ObjMap<GraphQLNamedType>;
interface InterfaceImplementations {
objects: ReadonlyArray<GraphQLObjectType>;
interfaces: ReadonlyArray<GraphQLInterfaceType>;
}
export interface GraphQLSchemaValidationOptions {
/**
* When building a schema from a GraphQL service's introspection result, it
* might be safe to assume the schema is valid. Set to true to assume the
* produced schema is valid.
*
* Default: false
*/
assumeValid?: boolean;
}
export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
description?: Maybe<string>;
query?: Maybe<GraphQLObjectType>;
mutation?: Maybe<GraphQLObjectType>;
subscription?: Maybe<GraphQLObjectType>;
types?: Maybe<Array<GraphQLNamedType>>;
directives?: Maybe<Array<GraphQLDirective>>;
extensions?: Maybe<Readonly<GraphQLSchemaExtensions>>;
astNode?: Maybe<SchemaDefinitionNode>;
extensionASTNodes?: Maybe<ReadonlyArray<SchemaExtensionNode>>;
}
/**
* @internal
*/
export interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig {
description: Maybe<string>;
types: Array<GraphQLNamedType>;
directives: Array<GraphQLDirective>;
extensions: Maybe<Readonly<GraphQLSchemaExtensions>>;
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
assumeValid: boolean;
}