diff --git a/src/utilities/__tests__/printSchema-test.ts b/src/utilities/__tests__/printSchema-test.ts index 5b7116648a..78f793b183 100644 --- a/src/utilities/__tests__/printSchema-test.ts +++ b/src/utilities/__tests__/printSchema-test.ts @@ -509,6 +509,23 @@ describe('Type System Printer', () => { `); }); + it('Print Input Type with @oneOf directive', () => { + const InputType = new GraphQLInputObjectType({ + name: 'InputType', + isOneOf: true, + fields: { + int: { type: GraphQLInt }, + }, + }); + + const schema = new GraphQLSchema({ types: [InputType] }); + expectPrintedSchema(schema).to.equal(dedent` + input InputType @oneOf { + int: Int + } + `); + }); + it('Custom Scalar', () => { const OddType = new GraphQLScalarType({ name: 'Odd' }); diff --git a/src/utilities/printSchema.ts b/src/utilities/printSchema.ts index c987f64ae1..c4caffc616 100644 --- a/src/utilities/printSchema.ts +++ b/src/utilities/printSchema.ts @@ -204,7 +204,12 @@ function printInputObject(type: GraphQLInputObjectType): string { const fields = Object.values(type.getFields()).map( (f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f), ); - return printDescription(type) + `input ${type.name}` + printBlock(fields); + return ( + printDescription(type) + + `input ${type.name}` + + (type.isOneOf ? ' @oneOf' : '') + + printBlock(fields) + ); } function printFields(type: GraphQLObjectType | GraphQLInterfaceType): string {