Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use empty arrays instead of undefined properties #1259

Merged
merged 1 commit into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/type/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class GraphQLSchema {
// Used as a cache for validateSchema().
__validationErrors: ?$ReadOnlyArray<GraphQLError>;
// Referenced by validateSchema().
__allowedLegacyNames: ?$ReadOnlyArray<string>;
__allowedLegacyNames: $ReadOnlyArray<string>;

constructor(config: GraphQLSchemaConfig): void {
// If this schema was built from a source known to be valid, then it may be
Expand Down Expand Up @@ -118,7 +118,7 @@ export class GraphQLSchema {
);
}

this.__allowedLegacyNames = config.allowedLegacyNames;
this.__allowedLegacyNames = config.allowedLegacyNames || [];
this._queryType = config.query;
this._mutationType = config.mutation;
this._subscriptionType = config.subscription;
Expand Down
5 changes: 1 addition & 4 deletions src/type/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,7 @@ function validateName(
): void {
// If a schema explicitly allows some legacy name which is no longer valid,
// allow it to be assumed valid.
if (
context.schema.__allowedLegacyNames &&
context.schema.__allowedLegacyNames.indexOf(node.name) !== -1
) {
if (context.schema.__allowedLegacyNames.indexOf(node.name) !== -1) {
return;
}
// Ensure names are valid, however introspection types opt out.
Expand Down
9 changes: 3 additions & 6 deletions src/utilities/extendSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,9 @@ export function extendSchema(
];

// Support both original legacy names and extended legacy names.
const schemaAllowedLegacyNames = schema.__allowedLegacyNames;
const extendAllowedLegacyNames = options && options.allowedLegacyNames;
const allowedLegacyNames =
schemaAllowedLegacyNames && extendAllowedLegacyNames
? schemaAllowedLegacyNames.concat(extendAllowedLegacyNames)
: schemaAllowedLegacyNames || extendAllowedLegacyNames;
const allowedLegacyNames = schema.__allowedLegacyNames.concat(
(options && options.allowedLegacyNames) || [],
);

// Then produce and return a Schema with these types.
return new GraphQLSchema({
Expand Down