diff --git a/src/utilities/__tests__/extendSchema-test.ts b/src/utilities/__tests__/extendSchema-test.ts index c6bc30ed4b..5e2d786f22 100644 --- a/src/utilities/__tests__/extendSchema-test.ts +++ b/src/utilities/__tests__/extendSchema-test.ts @@ -113,6 +113,17 @@ describe('extendSchema', () => { expect(extendedSchema.getDirectives()).to.have.members(specifiedDirectives); }); + it('preserves original schema config', () => { + const description = 'A schema description'; + const extensions = Object.freeze({ foo: 'bar' }); + const schema = new GraphQLSchema({ description, extensions }); + + const extendedSchema = extendSchema(schema, parse('scalar Bar')); + + expect(extendedSchema.description).to.equal(description); + expect(extendedSchema.extensions).to.deep.equal(extensions); + }); + it('extends objects by adding new fields', () => { const schema = buildSchema(` type Query { diff --git a/src/utilities/extendSchema.ts b/src/utilities/extendSchema.ts index 9ffce731b3..831733b69b 100644 --- a/src/utilities/extendSchema.ts +++ b/src/utilities/extendSchema.ts @@ -239,14 +239,14 @@ export function extendSchemaImpl( // Then produce and return a Schema config with these types. return { - description: schemaDef?.description?.value, + description: schemaDef?.description?.value ?? schemaConfig.description, ...operationTypes, types: Object.values(typeMap), directives: [ ...schemaConfig.directives.map(replaceDirective), ...directiveDefs.map(buildDirective), ], - extensions: Object.create(null), + extensions: schemaConfig.extensions, astNode: schemaDef ?? schemaConfig.astNode, extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExtensions), assumeValid: options?.assumeValid ?? false,