Skip to content

Commit 17f6ec5

Browse files
committed
addeding testing for edge cases around directives
1 parent b60d9fb commit 17f6ec5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/analysis/typeComplexityAnalysis.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,33 @@ describe('Test getQueryTypeComplexity function', () => {
10171017
// 1 query + 1 hero
10181018
expect(queryParser.processQuery(parse(query))).toBe(2);
10191019
});
1020+
1021+
test('and other directive are ignored', () => {
1022+
query = `query {
1023+
hero(episode: EMPIRE) {
1024+
id, name
1025+
}
1026+
human(id: 1) @ignore(if: true) {
1027+
id,
1028+
name,
1029+
homePlanet
1030+
}
1031+
}`;
1032+
// 1 query + 1 hero + 1 human
1033+
expect(queryParser.processQuery(parse(query))).toBe(3);
1034+
query = `query {
1035+
hero(episode: EMPIRE) {
1036+
id, name
1037+
}
1038+
human(id: 1) @includes(when: false) {
1039+
id,
1040+
name,
1041+
homePlanet
1042+
}
1043+
}`;
1044+
// 1 query + 1 hero
1045+
expect(queryParser.processQuery(parse(query))).toBe(3);
1046+
});
10201047
});
10211048

10221049
describe('with nested lists', () => {

0 commit comments

Comments
 (0)