Skip to content

Commit

Permalink
Fix bug where @include directive is ignored if @Skip is present.
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith authored and leebyron committed Apr 5, 2016
1 parent 136630f commit d6da0bf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/execution/__tests__/directives-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,30 @@ describe('Execute: handles directives', () => {
});
});
});

describe('works with skip and include directives', () => {
it('include and no skip', async () => {
return expect(
await executeTestQuery('{ a, b @include(if: true) @skip(if: false) }')
).to.deep.equal({
data: { a: 'a', b: 'b' }
});
});

it('include and skip', async () => {
return expect(
await executeTestQuery('{ a, b @include(if: true) @skip(if: true) }')
).to.deep.equal({
data: { a: 'a' }
});
});

it('no include or skip', async () => {
return expect(
await executeTestQuery('{ a, b @include(if: false) @skip(if: false) }')
).to.deep.equal({
data: { a: 'a' }
});
});
});
});
4 changes: 3 additions & 1 deletion src/execution/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ function shouldIncludeNode(
skipAST.arguments,
exeContext.variableValues
);
return !skipIf;
if (skipIf) {
return false;
}
}

const includeAST = directives && find(
Expand Down

0 comments on commit d6da0bf

Please sign in to comment.