Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Client Directives in Prisma plugin (@skip and @include) #1017

Merged
merged 4 commits into from Sep 7, 2023

Conversation

julioxavierr
Copy link
Contributor

Related to #723

@vercel
Copy link

vercel bot commented Sep 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pothos ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 7, 2023 9:10pm

@changeset-bot
Copy link

changeset-bot bot commented Sep 7, 2023

🦋 Changeset detected

Latest commit: 1fc5b60

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@pothos/plugin-prisma Patch
@pothos-examples/complex-app Patch
@pothos-examples/prisma-federation Patch
@pothos-examples/prisma-relay Patch
@pothos-examples/prisma-smart-subscriptions-apollo Patch
@pothos-examples/prisma-subscriptions Patch
@pothos-examples/prisma Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Owner

@hayes hayes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! thanks for adding this ❤️

@hayes
Copy link
Owner

hayes commented Sep 7, 2023

It would be great to add a test for these directives. The prisma tests all verify the queries that are executed, so adding a test that skips some relation field should be pretty straight forward

me {
id
name @skip(if: true)
email @include(if: false)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to add these to a relation instead to see any difference, unless you query a type that is using select mode. This change only changes the generated query, and not what revolvers get run.

query {
        me {
          id
          profile @skip(if: true) {
            bio
          } 
          posts(limit: 1) @include(if: false) {
            id
          }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I just updated the test

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thanks!

@@ -65,6 +65,54 @@ describe('prisma', () => {
`);
});

it('skips fields based on @skip and @include directives', async () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry to keep asking for more changes one at a time, but would also be nice to check the inverted condition, so that if the conditions is reversed the selection includes the expected relations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no worries! Just pushed one more commit

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@hayes hayes merged commit c3f242b into hayes:main Sep 7, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants