Skip to content

Commit

Permalink
Add additional test, written by @spawnia
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 26, 2018
1 parent cf0c922 commit d4a3f70
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/type/__tests__/validation-test.js
Expand Up @@ -761,6 +761,46 @@ describe('Type System: Input Objects must have fields', () => {
]);
});

it('rejects Input Objects with multiple non-breakable circular reference', () => {
const schema = buildSchema(`
type Query {
field(arg: SomeInputObject): String
}
input SomeInputObject {
startLoop: AnotherInputObject!
}
input AnotherInputObject {
closeLoop: SomeInputObject!
startSecondLoop: YetAnotherInputObject!
}
input YetAnotherInputObject {
closeSecondLoop: AnotherInputObject!
nonNullSelf: YetAnotherInputObject!
}
`);

expect(validateSchema(schema)).to.deep.equal([
{
message:
'Cannot reference Input Object "SomeInputObject" within itself through a series of non-null fields: "startLoop.closeLoop".',
locations: [{ line: 7, column: 9 }, { line: 11, column: 9 }],
},
{
message:
'Cannot reference Input Object "AnotherInputObject" within itself through a series of non-null fields: "startSecondLoop.closeSecondLoop".',
locations: [{ line: 12, column: 9 }, { line: 16, column: 9 }],
},
{
message:
'Cannot reference Input Object "YetAnotherInputObject" within itself through a series of non-null fields: "nonNullSelf".',
locations: [{ line: 17, column: 9 }],
},
]);
});

it('rejects an Input Object type with incorrectly typed fields', () => {
const schema = buildSchema(`
type Query {
Expand Down

0 comments on commit d4a3f70

Please sign in to comment.