Skip to content

Commit 7065c71

Browse files
committed
Remove deprecated 'allowedLegacyNames' property of 'GraphQLSche… (#2129)
1 parent 07b0413 commit 7065c71

11 files changed

+0
-170
lines changed

src/type/__tests__/schema-test.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -269,23 +269,13 @@ describe('Type System: Schema', () => {
269269
).to.equal(undefined);
270270
});
271271

272-
it('configures the schema for allowed legacy names', () => {
273-
expect(
274-
new GraphQLSchema({
275-
allowedLegacyNames: ['__badName'],
276-
}).__allowedLegacyNames,
277-
).to.deep.equal(['__badName']);
278-
});
279-
280272
it('checks the configuration for mistakes', () => {
281273
// $DisableFlowOnNegativeTest
282274
expect(() => new GraphQLSchema(() => null)).to.throw();
283275
// $DisableFlowOnNegativeTest
284276
expect(() => new GraphQLSchema({ types: {} })).to.throw();
285277
// $DisableFlowOnNegativeTest
286278
expect(() => new GraphQLSchema({ directives: {} })).to.throw();
287-
// $DisableFlowOnNegativeTest
288-
expect(() => new GraphQLSchema({ allowedLegacyNames: {} })).to.throw();
289279
});
290280
});
291281

@@ -342,15 +332,6 @@ describe('Type System: Schema', () => {
342332
).to.deep.equal([]);
343333
});
344334

345-
it('still configures the schema for allowed legacy names', () => {
346-
expect(
347-
new GraphQLSchema({
348-
assumeValid: true,
349-
allowedLegacyNames: ['__badName'],
350-
}).__allowedLegacyNames,
351-
).to.deep.equal(['__badName']);
352-
});
353-
354335
it('does not check the configuration for mistakes', () => {
355336
const config = () => null;
356337
config.assumeValid = true;
@@ -364,7 +345,6 @@ describe('Type System: Schema', () => {
364345
assumeValid: true,
365346
types: {},
366347
directives: { reduce: () => [] },
367-
allowedLegacyNames: {},
368348
}),
369349
).to.not.throw();
370350
});

src/type/__tests__/validation-test.js

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -463,43 +463,6 @@ describe('Type System: Objects must have fields', () => {
463463
},
464464
]);
465465
});
466-
467-
it('accepts an Object type with explicitly allowed legacy named fields', () => {
468-
const schemaBad = new GraphQLSchema({
469-
query: new GraphQLObjectType({
470-
name: 'Query',
471-
fields: { __badName: { type: GraphQLString } },
472-
}),
473-
});
474-
const schemaOk = new GraphQLSchema({
475-
query: new GraphQLObjectType({
476-
name: 'Query',
477-
fields: { __badName: { type: GraphQLString } },
478-
}),
479-
allowedLegacyNames: ['__badName'],
480-
});
481-
expect(validateSchema(schemaBad)).to.deep.equal([
482-
{
483-
message:
484-
'Name "__badName" must not begin with "__", which is reserved by GraphQL introspection.',
485-
},
486-
]);
487-
expect(validateSchema(schemaOk)).to.deep.equal([]);
488-
});
489-
490-
it('throws with bad value for explicitly allowed legacy names', () => {
491-
expect(
492-
() =>
493-
new GraphQLSchema({
494-
query: new GraphQLObjectType({
495-
name: 'Query',
496-
fields: { __badName: { type: GraphQLString } },
497-
}),
498-
// $DisableFlowOnNegativeTest
499-
allowedLegacyNames: true,
500-
}),
501-
).to.throw('"allowedLegacyNames" must be Array if provided but got: true.');
502-
});
503466
});
504467

505468
describe('Type System: Fields args must be properly named', () => {

src/type/schema.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ export class GraphQLSchema {
133133
_possibleTypeMap: ObjMap<ObjMap<boolean>>;
134134
// Used as a cache for validateSchema().
135135
__validationErrors: ?$ReadOnlyArray<GraphQLError>;
136-
// Referenced by validateSchema().
137-
__allowedLegacyNames: $ReadOnlyArray<string>;
138136

139137
constructor(config: GraphQLSchemaConfig): void {
140138
// If this schema was built from a source known to be valid, then it may be
@@ -156,18 +154,12 @@ export class GraphQLSchema {
156154
'"directives" must be Array if provided but got: ' +
157155
`${inspect(config.directives)}.`,
158156
);
159-
devAssert(
160-
!config.allowedLegacyNames || Array.isArray(config.allowedLegacyNames),
161-
'"allowedLegacyNames" must be Array if provided but got: ' +
162-
`${inspect(config.allowedLegacyNames)}.`,
163-
);
164157
}
165158

166159
this.extensions = config.extensions && toObjMap(config.extensions);
167160
this.astNode = config.astNode;
168161
this.extensionASTNodes = config.extensionASTNodes;
169162

170-
this.__allowedLegacyNames = config.allowedLegacyNames || [];
171163
this._queryType = config.query;
172164
this._mutationType = config.mutation;
173165
this._subscriptionType = config.subscription;
@@ -273,7 +265,6 @@ export class GraphQLSchema {
273265
extensions: ?ReadOnlyObjMap<mixed>,
274266
extensionASTNodes: $ReadOnlyArray<SchemaExtensionNode>,
275267
assumeValid: boolean,
276-
allowedLegacyNames: $ReadOnlyArray<string>,
277268
|} {
278269
return {
279270
query: this.getQueryType(),
@@ -285,7 +276,6 @@ export class GraphQLSchema {
285276
astNode: this.astNode,
286277
extensionASTNodes: this.extensionASTNodes || [],
287278
assumeValid: this.__validationErrors !== undefined,
288-
allowedLegacyNames: this.__allowedLegacyNames,
289279
};
290280
}
291281
}
@@ -304,15 +294,6 @@ export type GraphQLSchemaValidationOptions = {|
304294
* Default: false
305295
*/
306296
assumeValid?: boolean,
307-
308-
/**
309-
* If provided, the schema will consider fields or types with names included
310-
* in this list valid, even if they do not adhere to the specification's
311-
* schema validation rules.
312-
*
313-
* This option is provided to ease adoption and will be removed in v15.
314-
*/
315-
allowedLegacyNames?: ?$ReadOnlyArray<string>,
316297
|};
317298

318299
export type GraphQLSchemaConfig = {|

src/type/validate.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,6 @@ function validateName(
204204
context: SchemaValidationContext,
205205
node: { +name: string, +astNode: ?ASTNode, ... },
206206
): void {
207-
// If a schema explicitly allows some legacy name which is no longer valid,
208-
// allow it to be assumed valid.
209-
if (context.schema.__allowedLegacyNames.indexOf(node.name) !== -1) {
210-
return;
211-
}
212207
// Ensure names are valid, however introspection types opt out.
213208
const error = isValidNameError(node.name, node.astNode || undefined);
214209
if (error) {

src/utilities/__tests__/buildASTSchema-test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -814,17 +814,6 @@ describe('Schema Builder', () => {
814814
expect(errors).to.have.lengthOf.above(0);
815815
});
816816

817-
it('Accepts legacy names', () => {
818-
const sdl = `
819-
type Query {
820-
__badName: String
821-
}
822-
`;
823-
const schema = buildSchema(sdl, { allowedLegacyNames: ['__badName'] });
824-
const errors = validateSchema(schema);
825-
expect(errors).to.have.lengthOf(0);
826-
});
827-
828817
it('Rejects invalid SDL', () => {
829818
const sdl = `
830819
type Query {

src/utilities/__tests__/buildClientSchema-test.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -480,24 +480,6 @@ describe('Type System: build schema from introspection', () => {
480480
expect(printSchema(clientSchema)).to.equal(sdl);
481481
});
482482

483-
it('builds a schema with legacy names', () => {
484-
const sdl = dedent`
485-
type Query {
486-
__badName: String
487-
}
488-
`;
489-
const allowedLegacyNames = ['__badName'];
490-
const schema = buildSchema(sdl, { allowedLegacyNames });
491-
492-
const introspection = introspectionFromSchema(schema);
493-
const clientSchema = buildClientSchema(introspection, {
494-
allowedLegacyNames,
495-
});
496-
497-
expect(schema.__allowedLegacyNames).to.deep.equal(['__badName']);
498-
expect(printSchema(clientSchema)).to.equal(sdl);
499-
});
500-
501483
it('builds a schema aware of deprecation', () => {
502484
const sdl = dedent`
503485
enum Color {

src/utilities/__tests__/extendSchema-test.js

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,48 +1087,6 @@ describe('extendSchema', () => {
10871087
);
10881088
});
10891089

1090-
it('maintains configuration of the original schema object', () => {
1091-
const testSchemaWithLegacyNames = new GraphQLSchema({
1092-
query: new GraphQLObjectType({
1093-
name: 'Query',
1094-
fields: () => ({
1095-
id: { type: GraphQLID },
1096-
}),
1097-
}),
1098-
allowedLegacyNames: ['__badName'],
1099-
});
1100-
const ast = parse(`
1101-
extend type Query {
1102-
__badName: String
1103-
}
1104-
`);
1105-
const schema = extendSchema(testSchemaWithLegacyNames, ast);
1106-
expect(schema).to.deep.include({ __allowedLegacyNames: ['__badName'] });
1107-
});
1108-
1109-
it('adds to the configuration of the original schema object', () => {
1110-
const testSchemaWithLegacyNames = new GraphQLSchema({
1111-
query: new GraphQLObjectType({
1112-
name: 'Query',
1113-
fields: () => ({
1114-
__badName: { type: GraphQLString },
1115-
}),
1116-
}),
1117-
allowedLegacyNames: ['__badName'],
1118-
});
1119-
const ast = parse(`
1120-
extend type Query {
1121-
__anotherBadName: String
1122-
}
1123-
`);
1124-
const schema = extendSchema(testSchemaWithLegacyNames, ast, {
1125-
allowedLegacyNames: ['__anotherBadName'],
1126-
});
1127-
expect(schema).to.deep.include({
1128-
__allowedLegacyNames: ['__badName', '__anotherBadName'],
1129-
});
1130-
});
1131-
11321090
describe('can add additional root operation types', () => {
11331091
it('does not automatically include common root type names', () => {
11341092
const schema = extendTestSchema(`

src/utilities/buildASTSchema.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ export function buildASTSchema(
187187
directives,
188188
astNode: schemaDef,
189189
assumeValid: options && options.assumeValid,
190-
allowedLegacyNames: options && options.allowedLegacyNames,
191190
});
192191

193192
function getOperationTypes(schema: SchemaDefinitionNode) {

src/utilities/buildClientSchema.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export function buildClientSchema(
121121
types: objectValues(typeMap),
122122
directives,
123123
assumeValid: options && options.assumeValid,
124-
allowedLegacyNames: options && options.allowedLegacyNames,
125124
});
126125

127126
// Given a type reference in introspection, return the GraphQLType instance.

src/utilities/extendSchema.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,6 @@ export function extendSchema(
190190
}
191191
}
192192

193-
// Support both original legacy names and extended legacy names.
194-
const allowedLegacyNames = schemaConfig.allowedLegacyNames.concat(
195-
(options && options.allowedLegacyNames) || [],
196-
);
197-
198193
// Then produce and return a Schema with these types.
199194
return new GraphQLSchema({
200195
// Note: While this could make early assertions to get the correctly
@@ -208,7 +203,6 @@ export function extendSchema(
208203
directives: getMergedDirectives(),
209204
astNode: schemaDef || schemaConfig.astNode,
210205
extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExts),
211-
allowedLegacyNames,
212206
});
213207

214208
// Below are functions used for producing this schema that have closed over

tstypes/type/schema.d.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export class GraphQLSchema {
7070
extensions: Maybe<Readonly<Record<string, any>>>;
7171
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
7272
assumeValid: boolean;
73-
allowedLegacyNames: ReadonlyArray<string>;
7473
};
7574
}
7675

@@ -85,15 +84,6 @@ export interface GraphQLSchemaValidationOptions {
8584
* Default: false
8685
*/
8786
assumeValid?: boolean;
88-
89-
/**
90-
* If provided, the schema will consider fields or types with names included
91-
* in this list valid, even if they do not adhere to the specification's
92-
* schema validation rules.
93-
*
94-
* This option is provided to ease adoption and will be removed in v15.
95-
*/
96-
allowedLegacyNames?: Maybe<ReadonlyArray<string>>;
9787
}
9888

9989
export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {

0 commit comments

Comments
 (0)