diff --git a/src/validation/__tests__/validation-test.ts b/src/validation/__tests__/validation-test.ts index 2d49f9335b..6194dabe8a 100644 --- a/src/validation/__tests__/validation-test.ts +++ b/src/validation/__tests__/validation-test.ts @@ -179,3 +179,25 @@ describe('Validate: Limit maximum number of validation errors', () => { ).to.throw(/^Error from custom rule!$/); }); }); + +describe('operation and variable definition descriptions', () => { + it('validates operation with description and variable descriptions', () => { + const schema = buildSchema( + 'type Query { field(a: Int, b: String): String }', + ); + const query = ` + "Operation description" + query myQuery( + "Variable a description" + $a: Int, + """Variable b\nmultiline description""" + $b: String + ) { + field(a: $a, b: $b) + } + `; + const ast = parse(query); + const errors = validate(schema, ast); + expect(errors.length).to.equal(0); + }); +}); diff --git a/src/validation/rules/ValuesOfCorrectTypeRule.ts b/src/validation/rules/ValuesOfCorrectTypeRule.ts index 6636e6a552..194c5bc563 100644 --- a/src/validation/rules/ValuesOfCorrectTypeRule.ts +++ b/src/validation/rules/ValuesOfCorrectTypeRule.ts @@ -116,7 +116,7 @@ export function ValuesOfCorrectTypeRule( EnumValue: (node) => isValidValueNode(context, node), IntValue: (node) => isValidValueNode(context, node), FloatValue: (node) => isValidValueNode(context, node), - StringValue: (node) => isValidValueNode(context, node), + StringValue: (node, key) => key !== "description" && isValidValueNode(context, node), BooleanValue: (node) => isValidValueNode(context, node), }; }