diff --git a/src/type/__tests__/schema-test.js b/src/type/__tests__/schema-test.js index 3174624937..8c5dd6733c 100644 --- a/src/type/__tests__/schema-test.js +++ b/src/type/__tests__/schema-test.js @@ -269,14 +269,6 @@ describe('Type System: Schema', () => { ).to.equal(undefined); }); - it('configures the schema for allowed legacy names', () => { - expect( - new GraphQLSchema({ - allowedLegacyNames: ['__badName'], - }).__allowedLegacyNames, - ).to.deep.equal(['__badName']); - }); - it('checks the configuration for mistakes', () => { // $DisableFlowOnNegativeTest expect(() => new GraphQLSchema(() => null)).to.throw(); @@ -284,8 +276,6 @@ describe('Type System: Schema', () => { expect(() => new GraphQLSchema({ types: {} })).to.throw(); // $DisableFlowOnNegativeTest expect(() => new GraphQLSchema({ directives: {} })).to.throw(); - // $DisableFlowOnNegativeTest - expect(() => new GraphQLSchema({ allowedLegacyNames: {} })).to.throw(); }); }); @@ -342,15 +332,6 @@ describe('Type System: Schema', () => { ).to.deep.equal([]); }); - it('still configures the schema for allowed legacy names', () => { - expect( - new GraphQLSchema({ - assumeValid: true, - allowedLegacyNames: ['__badName'], - }).__allowedLegacyNames, - ).to.deep.equal(['__badName']); - }); - it('does not check the configuration for mistakes', () => { const config = () => null; config.assumeValid = true; @@ -364,7 +345,6 @@ describe('Type System: Schema', () => { assumeValid: true, types: {}, directives: { reduce: () => [] }, - allowedLegacyNames: {}, }), ).to.not.throw(); }); diff --git a/src/type/__tests__/validation-test.js b/src/type/__tests__/validation-test.js index 10dcd8453e..903b374dba 100644 --- a/src/type/__tests__/validation-test.js +++ b/src/type/__tests__/validation-test.js @@ -463,43 +463,6 @@ describe('Type System: Objects must have fields', () => { }, ]); }); - - it('accepts an Object type with explicitly allowed legacy named fields', () => { - const schemaBad = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { __badName: { type: GraphQLString } }, - }), - }); - const schemaOk = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { __badName: { type: GraphQLString } }, - }), - allowedLegacyNames: ['__badName'], - }); - expect(validateSchema(schemaBad)).to.deep.equal([ - { - message: - 'Name "__badName" must not begin with "__", which is reserved by GraphQL introspection.', - }, - ]); - expect(validateSchema(schemaOk)).to.deep.equal([]); - }); - - it('throws with bad value for explicitly allowed legacy names', () => { - expect( - () => - new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: { __badName: { type: GraphQLString } }, - }), - // $DisableFlowOnNegativeTest - allowedLegacyNames: true, - }), - ).to.throw('"allowedLegacyNames" must be Array if provided but got: true.'); - }); }); describe('Type System: Fields args must be properly named', () => { diff --git a/src/type/schema.js b/src/type/schema.js index d357288743..1338708665 100644 --- a/src/type/schema.js +++ b/src/type/schema.js @@ -133,8 +133,6 @@ export class GraphQLSchema { _possibleTypeMap: ObjMap>; // Used as a cache for validateSchema(). __validationErrors: ?$ReadOnlyArray; - // Referenced by validateSchema(). - __allowedLegacyNames: $ReadOnlyArray; constructor(config: GraphQLSchemaConfig): void { // If this schema was built from a source known to be valid, then it may be @@ -156,18 +154,12 @@ export class GraphQLSchema { '"directives" must be Array if provided but got: ' + `${inspect(config.directives)}.`, ); - devAssert( - !config.allowedLegacyNames || Array.isArray(config.allowedLegacyNames), - '"allowedLegacyNames" must be Array if provided but got: ' + - `${inspect(config.allowedLegacyNames)}.`, - ); } this.extensions = config.extensions && toObjMap(config.extensions); this.astNode = config.astNode; this.extensionASTNodes = config.extensionASTNodes; - this.__allowedLegacyNames = config.allowedLegacyNames || []; this._queryType = config.query; this._mutationType = config.mutation; this._subscriptionType = config.subscription; @@ -273,7 +265,6 @@ export class GraphQLSchema { extensions: ?ReadOnlyObjMap, extensionASTNodes: $ReadOnlyArray, assumeValid: boolean, - allowedLegacyNames: $ReadOnlyArray, |} { return { query: this.getQueryType(), @@ -285,7 +276,6 @@ export class GraphQLSchema { astNode: this.astNode, extensionASTNodes: this.extensionASTNodes || [], assumeValid: this.__validationErrors !== undefined, - allowedLegacyNames: this.__allowedLegacyNames, }; } } @@ -304,15 +294,6 @@ export type GraphQLSchemaValidationOptions = {| * Default: false */ assumeValid?: boolean, - - /** - * If provided, the schema will consider fields or types with names included - * in this list valid, even if they do not adhere to the specification's - * schema validation rules. - * - * This option is provided to ease adoption and will be removed in v15. - */ - allowedLegacyNames?: ?$ReadOnlyArray, |}; export type GraphQLSchemaConfig = {| diff --git a/src/type/validate.js b/src/type/validate.js index c4e9b0dc6f..6d8ac5c91d 100644 --- a/src/type/validate.js +++ b/src/type/validate.js @@ -204,11 +204,6 @@ function validateName( context: SchemaValidationContext, node: { +name: string, +astNode: ?ASTNode, ... }, ): void { - // If a schema explicitly allows some legacy name which is no longer valid, - // allow it to be assumed valid. - if (context.schema.__allowedLegacyNames.indexOf(node.name) !== -1) { - return; - } // Ensure names are valid, however introspection types opt out. const error = isValidNameError(node.name, node.astNode || undefined); if (error) { diff --git a/src/utilities/__tests__/buildASTSchema-test.js b/src/utilities/__tests__/buildASTSchema-test.js index abcbd91063..8fc68ef3d6 100644 --- a/src/utilities/__tests__/buildASTSchema-test.js +++ b/src/utilities/__tests__/buildASTSchema-test.js @@ -814,17 +814,6 @@ describe('Schema Builder', () => { expect(errors).to.have.lengthOf.above(0); }); - it('Accepts legacy names', () => { - const sdl = ` - type Query { - __badName: String - } - `; - const schema = buildSchema(sdl, { allowedLegacyNames: ['__badName'] }); - const errors = validateSchema(schema); - expect(errors).to.have.lengthOf(0); - }); - it('Rejects invalid SDL', () => { const sdl = ` type Query { diff --git a/src/utilities/__tests__/buildClientSchema-test.js b/src/utilities/__tests__/buildClientSchema-test.js index 33e5b21fca..ce3ad739c9 100644 --- a/src/utilities/__tests__/buildClientSchema-test.js +++ b/src/utilities/__tests__/buildClientSchema-test.js @@ -480,24 +480,6 @@ describe('Type System: build schema from introspection', () => { expect(printSchema(clientSchema)).to.equal(sdl); }); - it('builds a schema with legacy names', () => { - const sdl = dedent` - type Query { - __badName: String - } - `; - const allowedLegacyNames = ['__badName']; - const schema = buildSchema(sdl, { allowedLegacyNames }); - - const introspection = introspectionFromSchema(schema); - const clientSchema = buildClientSchema(introspection, { - allowedLegacyNames, - }); - - expect(schema.__allowedLegacyNames).to.deep.equal(['__badName']); - expect(printSchema(clientSchema)).to.equal(sdl); - }); - it('builds a schema aware of deprecation', () => { const sdl = dedent` enum Color { diff --git a/src/utilities/__tests__/extendSchema-test.js b/src/utilities/__tests__/extendSchema-test.js index 5e115cbe13..e76be144cb 100644 --- a/src/utilities/__tests__/extendSchema-test.js +++ b/src/utilities/__tests__/extendSchema-test.js @@ -1087,48 +1087,6 @@ describe('extendSchema', () => { ); }); - it('maintains configuration of the original schema object', () => { - const testSchemaWithLegacyNames = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: () => ({ - id: { type: GraphQLID }, - }), - }), - allowedLegacyNames: ['__badName'], - }); - const ast = parse(` - extend type Query { - __badName: String - } - `); - const schema = extendSchema(testSchemaWithLegacyNames, ast); - expect(schema).to.deep.include({ __allowedLegacyNames: ['__badName'] }); - }); - - it('adds to the configuration of the original schema object', () => { - const testSchemaWithLegacyNames = new GraphQLSchema({ - query: new GraphQLObjectType({ - name: 'Query', - fields: () => ({ - __badName: { type: GraphQLString }, - }), - }), - allowedLegacyNames: ['__badName'], - }); - const ast = parse(` - extend type Query { - __anotherBadName: String - } - `); - const schema = extendSchema(testSchemaWithLegacyNames, ast, { - allowedLegacyNames: ['__anotherBadName'], - }); - expect(schema).to.deep.include({ - __allowedLegacyNames: ['__badName', '__anotherBadName'], - }); - }); - describe('can add additional root operation types', () => { it('does not automatically include common root type names', () => { const schema = extendTestSchema(` diff --git a/src/utilities/buildASTSchema.js b/src/utilities/buildASTSchema.js index c3d4b350d8..3f0ed0d7ff 100644 --- a/src/utilities/buildASTSchema.js +++ b/src/utilities/buildASTSchema.js @@ -187,7 +187,6 @@ export function buildASTSchema( directives, astNode: schemaDef, assumeValid: options && options.assumeValid, - allowedLegacyNames: options && options.allowedLegacyNames, }); function getOperationTypes(schema: SchemaDefinitionNode) { diff --git a/src/utilities/buildClientSchema.js b/src/utilities/buildClientSchema.js index d2da5d9fe4..366da69625 100644 --- a/src/utilities/buildClientSchema.js +++ b/src/utilities/buildClientSchema.js @@ -121,7 +121,6 @@ export function buildClientSchema( types: objectValues(typeMap), directives, assumeValid: options && options.assumeValid, - allowedLegacyNames: options && options.allowedLegacyNames, }); // Given a type reference in introspection, return the GraphQLType instance. diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index 4d1778e87c..35bc1067ad 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -190,11 +190,6 @@ export function extendSchema( } } - // Support both original legacy names and extended legacy names. - const allowedLegacyNames = schemaConfig.allowedLegacyNames.concat( - (options && options.allowedLegacyNames) || [], - ); - // Then produce and return a Schema with these types. return new GraphQLSchema({ // Note: While this could make early assertions to get the correctly @@ -208,7 +203,6 @@ export function extendSchema( directives: getMergedDirectives(), astNode: schemaDef || schemaConfig.astNode, extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExts), - allowedLegacyNames, }); // Below are functions used for producing this schema that have closed over diff --git a/tstypes/type/schema.d.ts b/tstypes/type/schema.d.ts index 5cbddaed60..468d227584 100644 --- a/tstypes/type/schema.d.ts +++ b/tstypes/type/schema.d.ts @@ -70,7 +70,6 @@ export class GraphQLSchema { extensions: Maybe>>; extensionASTNodes: ReadonlyArray; assumeValid: boolean; - allowedLegacyNames: ReadonlyArray; }; } @@ -85,15 +84,6 @@ export interface GraphQLSchemaValidationOptions { * Default: false */ assumeValid?: boolean; - - /** - * If provided, the schema will consider fields or types with names included - * in this list valid, even if they do not adhere to the specification's - * schema validation rules. - * - * This option is provided to ease adoption and will be removed in v15. - */ - allowedLegacyNames?: Maybe>; } export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {