Skip to content

Commit 85b4f58

Browse files
IvanGoncharovmjmahone
authored andcommitted
__allowedLegacyNames: Use empty array instead of undefined properties (#1259)
1 parent e79faaa commit 85b4f58

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/type/schema.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class GraphQLSchema {
8989
// Used as a cache for validateSchema().
9090
__validationErrors: ?$ReadOnlyArray<GraphQLError>;
9191
// Referenced by validateSchema().
92-
__allowedLegacyNames: ?$ReadOnlyArray<string>;
92+
__allowedLegacyNames: $ReadOnlyArray<string>;
9393

9494
constructor(config: GraphQLSchemaConfig): void {
9595
// If this schema was built from a source known to be valid, then it may be
@@ -119,7 +119,7 @@ export class GraphQLSchema {
119119
);
120120
}
121121

122-
this.__allowedLegacyNames = config.allowedLegacyNames;
122+
this.__allowedLegacyNames = config.allowedLegacyNames || [];
123123
this._queryType = config.query;
124124
this._mutationType = config.mutation;
125125
this._subscriptionType = config.subscription;

src/type/validate.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ function validateName(
221221
): void {
222222
// If a schema explicitly allows some legacy name which is no longer valid,
223223
// allow it to be assumed valid.
224-
if (
225-
context.schema.__allowedLegacyNames &&
226-
context.schema.__allowedLegacyNames.indexOf(node.name) !== -1
227-
) {
224+
if (context.schema.__allowedLegacyNames.indexOf(node.name) !== -1) {
228225
return;
229226
}
230227
// Ensure names are valid, however introspection types opt out.

src/utilities/extendSchema.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,9 @@ export function extendSchema(
237237
];
238238

239239
// Support both original legacy names and extended legacy names.
240-
const schemaAllowedLegacyNames = schema.__allowedLegacyNames;
241-
const extendAllowedLegacyNames = options && options.allowedLegacyNames;
242-
const allowedLegacyNames =
243-
schemaAllowedLegacyNames && extendAllowedLegacyNames
244-
? schemaAllowedLegacyNames.concat(extendAllowedLegacyNames)
245-
: schemaAllowedLegacyNames || extendAllowedLegacyNames;
240+
const allowedLegacyNames = schema.__allowedLegacyNames.concat(
241+
(options && options.allowedLegacyNames) || [],
242+
);
246243

247244
// Then produce and return a Schema with these types.
248245
return new GraphQLSchema({

0 commit comments

Comments
 (0)