diff --git a/src/utilities/__tests__/extendSchema-test.js b/src/utilities/__tests__/extendSchema-test.js index 31d32d7077..6a971b7f3d 100644 --- a/src/utilities/__tests__/extendSchema-test.js +++ b/src/utilities/__tests__/extendSchema-test.js @@ -994,6 +994,25 @@ 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.__allowedLegacyNames).to.deep.equal(['__badName']); + }); + describe('does not allow extending a non-object type', () => { it('not an interface', () => { const ast = parse(` diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index f064894c17..4ef8deabe1 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -230,6 +230,8 @@ export function extendSchema( types, directives: getMergedDirectives(), astNode: schema.astNode, + allowedLegacyNames: + schema.__allowedLegacyNames && schema.__allowedLegacyNames.slice(), }); // Below are functions used for producing this schema that have closed over