Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/validation/__tests__/validation-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion src/validation/rules/ValuesOfCorrectTypeRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}
Expand Down