Skip to content

Commit

Permalink
[prisma] test query with skip and include directives
Browse files Browse the repository at this point in the history
  • Loading branch information
julioxavierr committed Sep 7, 2023
1 parent 0515ad5 commit 66a62ac
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions packages/plugin-prisma/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,54 @@ describe('prisma', () => {
`);
});

it('skips fields based on @skip and @include directives', async () => {
const query = gql`
query {
me {
id
profile @skip(if: true) {
bio
}
posts(limit: 1) @include(if: false) {
id
}
}
}
`;

const result = await execute({
schema,
document: query,
contextValue: { user: { id: 1 } },
});

expect(result).toMatchInlineSnapshot(`
{
"data": {
"me": {
"id": "VXNlcjox",
},
},
}
`);

expect(queries).toMatchInlineSnapshot(`
[
{
"action": "findUnique",
"args": {
"where": {
"id": 1,
},
},
"dataPath": [],
"model": "User",
"runInTransaction": false,
},
]
`);
});

it('queries decimals', async () => {
const query = gql`
query {
Expand Down

0 comments on commit 66a62ac

Please sign in to comment.