Skip to content

Commit 8f936da

Browse files
committed
Standardise schema validation options.
1 parent 3958eae commit 8f936da

File tree

3 files changed

+24
-44
lines changed

3 files changed

+24
-44
lines changed

src/type/schema.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,16 @@ export class GraphQLSchema {
229229

230230
type TypeMap = ObjMap<GraphQLNamedType>;
231231

232-
export type GraphQLSchemaConfig = {
233-
query?: ?GraphQLObjectType,
234-
mutation?: ?GraphQLObjectType,
235-
subscription?: ?GraphQLObjectType,
236-
types?: ?Array<GraphQLNamedType>,
237-
directives?: ?Array<GraphQLDirective>,
238-
astNode?: ?SchemaDefinitionNode,
232+
export type GraphQLSchemaValidationOptions = {|
233+
/**
234+
* When building a schema from a GraphQL service's introspection result, it
235+
* might be safe to assume the schema is valid. Set to true to assume the
236+
* produced schema is valid.
237+
*
238+
* Default: false
239+
*/
239240
assumeValid?: boolean,
241+
240242
/**
241243
* If provided, the schema will consider fields or types with names included
242244
* in this list valid, even if they do not adhere to the specification's
@@ -246,6 +248,16 @@ export type GraphQLSchemaConfig = {
246248
* major release.
247249
*/
248250
allowedLegacyNames?: ?Array<string>,
251+
|};
252+
253+
export type GraphQLSchemaConfig = {
254+
query?: ?GraphQLObjectType,
255+
mutation?: ?GraphQLObjectType,
256+
subscription?: ?GraphQLObjectType,
257+
types?: ?Array<GraphQLNamedType>,
258+
directives?: ?Array<GraphQLDirective>,
259+
astNode?: ?SchemaDefinitionNode,
260+
...GraphQLSchemaValidationOptions,
249261
};
250262

251263
function typeMapReducer(map: TypeMap, type: ?GraphQLType): TypeMap {

src/utilities/buildASTSchema.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import { introspectionTypes } from '../type/introspection';
6464
import { specifiedScalarTypes } from '../type/scalars';
6565

6666
import { GraphQLSchema } from '../type/schema';
67+
import type { GraphQLSchemaValidationOptions } from '../type/schema';
6768

6869
import type {
6970
GraphQLType,
@@ -72,14 +73,7 @@ import type {
7273
} from '../type/definition';
7374

7475
type Options = {|
75-
/**
76-
* When building a schema from a GraphQL service's introspection result, it
77-
* might be safe to assume the schema is valid. Set to true to assume the
78-
* produced schema is valid.
79-
*
80-
* Default: false
81-
*/
82-
assumeValid?: boolean,
76+
...GraphQLSchemaValidationOptions,
8377

8478
/**
8579
* Descriptions are defined as preceding string literals, however an older
@@ -89,16 +83,6 @@ type Options = {|
8983
* Default: false
9084
*/
9185
commentDescriptions?: boolean,
92-
93-
/**
94-
* If provided, the schema will consider fields or types with names included
95-
* in this list valid, even if they do not adhere to the specification's
96-
* schema validation rules.
97-
*
98-
* This option is provided to ease adoption and may be removed in a future
99-
* major release.
100-
*/
101-
allowedLegacyNames?: ?Array<string>,
10286
|};
10387

10488
function buildWrappedType(

src/utilities/extendSchema.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { ASTDefinitionBuilder } from './buildASTSchema';
1313
import { GraphQLError } from '../error/GraphQLError';
1414
import { isSchema, GraphQLSchema } from '../type/schema';
1515

16+
import type { GraphQLSchemaValidationOptions } from '../type/schema';
17+
1618
import {
1719
isObjectType,
1820
isInterfaceType,
@@ -38,14 +40,7 @@ import type {
3840
} from '../language/ast';
3941

4042
type Options = {|
41-
/**
42-
* When extending a schema with a known valid extension, it might be safe to
43-
* assume the schema is valid. Set to true to assume the produced schema
44-
* is valid.
45-
*
46-
* Default: false
47-
*/
48-
assumeValid?: boolean,
43+
...GraphQLSchemaValidationOptions,
4944

5045
/**
5146
* Descriptions are defined as preceding string literals, however an older
@@ -55,17 +50,6 @@ type Options = {|
5550
* Default: false
5651
*/
5752
commentDescriptions?: boolean,
58-
59-
/**
60-
* If provided, the schema will consider fields or types with names included
61-
* in this list valid, in addition to those already allowed on the original
62-
* schema, even if they do not adhere to the specification's schema validation
63-
* rules.
64-
*
65-
* This option is provided to ease adoption and may be removed in a future
66-
* major release.
67-
*/
68-
allowedLegacyNames?: ?Array<string>,
6953
|};
7054

7155
/**

0 commit comments

Comments
 (0)