Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2796e1f

Browse files
author
Travis CI
committed
Deploy 87c1bc3 to NPM branch
1 parent a77215b commit 2796e1f

File tree

6 files changed

+105
-15
lines changed

6 files changed

+105
-15
lines changed

error/GraphQLError.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ declare class GraphQLError extends Error {
8484
+originalError: ?Error;
8585

8686
/**
87-
* The original error thrown from a field resolver during execution.
87+
* Extension fields to add to the formatted error.
8888
*/
8989
+extensions: ?{ [key: string]: mixed };
9090
}

module/error/GraphQLError.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ declare class GraphQLError extends Error {
8484
+originalError: ?Error;
8585

8686
/**
87-
* The original error thrown from a field resolver during execution.
87+
* Extension fields to add to the formatted error.
8888
*/
8989
+extensions: ?{ [key: string]: mixed };
9090
}

module/type/schema.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
1313

1414
import { isObjectType, isInterfaceType, isUnionType, isInputObjectType, isWrappingType } from './definition';
1515

16-
import { GraphQLDirective, specifiedDirectives } from './directives';
16+
import { GraphQLDirective, isDirective, specifiedDirectives } from './directives';
1717

1818
import { __Schema } from './introspection';
1919
import find from '../jsutils/find';
@@ -88,7 +88,17 @@ export var GraphQLSchema = function () {
8888
initialTypes = initialTypes.concat(types);
8989
}
9090

91-
this._typeMap = initialTypes.reduce(typeMapReducer, Object.create(null));
91+
// Keep track of all types referenced within the schema.
92+
var typeMap = Object.create(null);
93+
94+
// First by deeply visiting all initial types.
95+
typeMap = initialTypes.reduce(typeMapReducer, typeMap);
96+
97+
// Then by deeply visiting all directive types.
98+
typeMap = this._directives.reduce(typeMapDirectiveReducer, typeMap);
99+
100+
// Storing the resulting map for reference by the schema.
101+
this._typeMap = typeMap;
92102

93103
// Keep track of all implementations by interface name.
94104
this._implementations = Object.create(null);
@@ -213,4 +223,14 @@ function typeMapReducer(map, type) {
213223
}
214224

215225
return reducedMap;
226+
}
227+
228+
function typeMapDirectiveReducer(map, directive) {
229+
// Directives are not validated until validateSchema() is called.
230+
if (!isDirective(directive)) {
231+
return map;
232+
}
233+
return directive.args.reduce(function (_map, arg) {
234+
return typeMapReducer(_map, arg.type);
235+
}, map);
216236
}

module/type/schema.js.flow

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import type {
2222
GraphQLInterfaceType,
2323
} from './definition';
2424
import type { SchemaDefinitionNode } from '../language/ast';
25-
import { GraphQLDirective, specifiedDirectives } from './directives';
25+
import {
26+
GraphQLDirective,
27+
isDirective,
28+
specifiedDirectives,
29+
} from './directives';
2630
import type { GraphQLError } from '../error/GraphQLError';
2731
import { __Schema } from './introspection';
2832
import find from '../jsutils/find';
@@ -121,10 +125,17 @@ export class GraphQLSchema {
121125
initialTypes = initialTypes.concat(types);
122126
}
123127

124-
this._typeMap = initialTypes.reduce(
125-
typeMapReducer,
126-
(Object.create(null): TypeMap),
127-
);
128+
// Keep track of all types referenced within the schema.
129+
let typeMap: TypeMap = Object.create(null);
130+
131+
// First by deeply visiting all initial types.
132+
typeMap = initialTypes.reduce(typeMapReducer, typeMap);
133+
134+
// Then by deeply visiting all directive types.
135+
typeMap = this._directives.reduce(typeMapDirectiveReducer, typeMap);
136+
137+
// Storing the resulting map for reference by the schema.
138+
this._typeMap = typeMap;
128139

129140
// Keep track of all implementations by interface name.
130141
this._implementations = Object.create(null);
@@ -269,3 +280,17 @@ function typeMapReducer(map: TypeMap, type: ?GraphQLType): TypeMap {
269280

270281
return reducedMap;
271282
}
283+
284+
function typeMapDirectiveReducer(
285+
map: TypeMap,
286+
directive: ?GraphQLDirective,
287+
): TypeMap {
288+
// Directives are not validated until validateSchema() is called.
289+
if (!isDirective(directive)) {
290+
return map;
291+
}
292+
return directive.args.reduce(
293+
(_map, arg) => typeMapReducer(_map, arg.type),
294+
map,
295+
);
296+
}

type/schema.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,17 @@ var GraphQLSchema = exports.GraphQLSchema = function () {
108108
initialTypes = initialTypes.concat(types);
109109
}
110110

111-
this._typeMap = initialTypes.reduce(typeMapReducer, Object.create(null));
111+
// Keep track of all types referenced within the schema.
112+
var typeMap = Object.create(null);
113+
114+
// First by deeply visiting all initial types.
115+
typeMap = initialTypes.reduce(typeMapReducer, typeMap);
116+
117+
// Then by deeply visiting all directive types.
118+
typeMap = this._directives.reduce(typeMapDirectiveReducer, typeMap);
119+
120+
// Storing the resulting map for reference by the schema.
121+
this._typeMap = typeMap;
112122

113123
// Keep track of all implementations by interface name.
114124
this._implementations = Object.create(null);
@@ -233,4 +243,14 @@ function typeMapReducer(map, type) {
233243
}
234244

235245
return reducedMap;
246+
}
247+
248+
function typeMapDirectiveReducer(map, directive) {
249+
// Directives are not validated until validateSchema() is called.
250+
if (!(0, _directives.isDirective)(directive)) {
251+
return map;
252+
}
253+
return directive.args.reduce(function (_map, arg) {
254+
return typeMapReducer(_map, arg.type);
255+
}, map);
236256
}

type/schema.js.flow

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import type {
2222
GraphQLInterfaceType,
2323
} from './definition';
2424
import type { SchemaDefinitionNode } from '../language/ast';
25-
import { GraphQLDirective, specifiedDirectives } from './directives';
25+
import {
26+
GraphQLDirective,
27+
isDirective,
28+
specifiedDirectives,
29+
} from './directives';
2630
import type { GraphQLError } from '../error/GraphQLError';
2731
import { __Schema } from './introspection';
2832
import find from '../jsutils/find';
@@ -121,10 +125,17 @@ export class GraphQLSchema {
121125
initialTypes = initialTypes.concat(types);
122126
}
123127

124-
this._typeMap = initialTypes.reduce(
125-
typeMapReducer,
126-
(Object.create(null): TypeMap),
127-
);
128+
// Keep track of all types referenced within the schema.
129+
let typeMap: TypeMap = Object.create(null);
130+
131+
// First by deeply visiting all initial types.
132+
typeMap = initialTypes.reduce(typeMapReducer, typeMap);
133+
134+
// Then by deeply visiting all directive types.
135+
typeMap = this._directives.reduce(typeMapDirectiveReducer, typeMap);
136+
137+
// Storing the resulting map for reference by the schema.
138+
this._typeMap = typeMap;
128139

129140
// Keep track of all implementations by interface name.
130141
this._implementations = Object.create(null);
@@ -269,3 +280,17 @@ function typeMapReducer(map: TypeMap, type: ?GraphQLType): TypeMap {
269280

270281
return reducedMap;
271282
}
283+
284+
function typeMapDirectiveReducer(
285+
map: TypeMap,
286+
directive: ?GraphQLDirective,
287+
): TypeMap {
288+
// Directives are not validated until validateSchema() is called.
289+
if (!isDirective(directive)) {
290+
return map;
291+
}
292+
return directive.args.reduce(
293+
(_map, arg) => typeMapReducer(_map, arg.type),
294+
map,
295+
);
296+
}

0 commit comments

Comments
 (0)