diff --git a/CHANGELOG.md b/CHANGELOG.md index 93d9039b50e..5aafe3ce59f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ [@nagelflorian](https://github.com/nagelflorian) in [#936](https://github.com/apollographql/graphql-tools/pull/936) * Update `IFieldResolver` to allow typed input args.
[@luk3thomas](https://github.com/luk3thomas) in [#932](https://github.com/apollographql/graphql-tools/pull/932) +* Changes to `extractExtensionDefinitions` to properly support `graphql-js` input extensions.
+ [@jure](https://github.com/jure) in [#948](https://github.com/apollographql/graphql-tools/pull/948) * Documentation updates.
[@Amorites](https://github.com/Amorites) in [#944](https://github.com/apollographql/graphql-tools/pull/944)
[@trevor-scheer](https://github.com/trevor-scheer) in [#946](https://github.com/apollographql/graphql-tools/pull/946)
diff --git a/src/generate/extractExtensionDefinitions.ts b/src/generate/extractExtensionDefinitions.ts index 05fb394411c..54d8dd671e6 100644 --- a/src/generate/extractExtensionDefinitions.ts +++ b/src/generate/extractExtensionDefinitions.ts @@ -2,12 +2,14 @@ import { DocumentNode, DefinitionNode } from 'graphql'; const newExtensionDefinitionKind = 'ObjectTypeExtension'; const interfaceExtensionDefinitionKind = 'InterfaceTypeExtension'; +const inputObjectExtensionDefinitionKind = 'InputObjectTypeExtension'; export default function extractExtensionDefinitions(ast: DocumentNode) { const extensionDefs = ast.definitions.filter( (def: DefinitionNode) => (def.kind as any) === newExtensionDefinitionKind || - (def.kind as any) === interfaceExtensionDefinitionKind, + (def.kind as any) === interfaceExtensionDefinitionKind || + (def.kind as any) === inputObjectExtensionDefinitionKind, ); return Object.assign({}, ast, { diff --git a/src/test/testExtensionExtraction.ts b/src/test/testExtensionExtraction.ts new file mode 100644 index 00000000000..a5ab306c458 --- /dev/null +++ b/src/test/testExtensionExtraction.ts @@ -0,0 +1,25 @@ +import { expect } from 'chai'; +import { parse } from 'graphql'; +import extractExtensionDefinitons from '../generate/extractExtensionDefinitions'; +import 'mocha'; + +describe('Extension extraction', () => { + it('extracts extended inputs', () => { + const typeDefs = ` + input Input { + foo: String + } + + extend input Input { + bar: String + } + `; + + const astDocument = parse(typeDefs); + const extensionAst = extractExtensionDefinitons(astDocument); + + expect(extensionAst.definitions).to.have.length(1); + expect(extensionAst.definitions[0].kind).to.equal('InputObjectTypeExtension'); + }); +}); + diff --git a/src/test/tests.ts b/src/test/tests.ts index edc4fabca67..7da887e0719 100755 --- a/src/test/tests.ts +++ b/src/test/tests.ts @@ -12,3 +12,4 @@ import './testMocking'; import './testResolution'; import './testSchemaGenerator'; import './testTransforms'; +import './testExtensionExtraction';