Skip to content

Commit d6da0bf

Browse files
dylanahsmithleebyron
authored andcommitted
Fix bug where @include directive is ignored if @Skip is present.
1 parent 136630f commit d6da0bf

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/execution/__tests__/directives-test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,30 @@ describe('Execute: handles directives', () => {
312312
});
313313
});
314314
});
315+
316+
describe('works with skip and include directives', () => {
317+
it('include and no skip', async () => {
318+
return expect(
319+
await executeTestQuery('{ a, b @include(if: true) @skip(if: false) }')
320+
).to.deep.equal({
321+
data: { a: 'a', b: 'b' }
322+
});
323+
});
324+
325+
it('include and skip', async () => {
326+
return expect(
327+
await executeTestQuery('{ a, b @include(if: true) @skip(if: true) }')
328+
).to.deep.equal({
329+
data: { a: 'a' }
330+
});
331+
});
332+
333+
it('no include or skip', async () => {
334+
return expect(
335+
await executeTestQuery('{ a, b @include(if: false) @skip(if: false) }')
336+
).to.deep.equal({
337+
data: { a: 'a' }
338+
});
339+
});
340+
});
315341
});

src/execution/execute.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ function shouldIncludeNode(
444444
skipAST.arguments,
445445
exeContext.variableValues
446446
);
447-
return !skipIf;
447+
if (skipIf) {
448+
return false;
449+
}
448450
}
449451

450452
const includeAST = directives && find(

0 commit comments

Comments
 (0)