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 #723

Open
hayes opened this issue Dec 27, 2022 · 3 comments
Open

Support Client Directives in Prisma plugin #723

hayes opened this issue Dec 27, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@hayes
Copy link
Owner

hayes commented Dec 27, 2022

The prisma plugin should support the ~@skip! ~@include! and @defer directives.

For skip and include, we can return early to exclude the fields selection if the field will not be resolved here: https://github.com/graphql/graphql-js/blob/main/src/execution/collectFields.ts#L250

For defer, it's slightly more complex because we only want to exclude it during the initial execution phase. I am not yet sure how to determine if a resolver is running deferred or not.

@stream may be useful as well for list or connection fields, but would likely be more complicated to implement

@hayes hayes added enhancement New feature or request help wanted Extra attention is needed labels Dec 27, 2022
@juliobetta
Copy link

I came across this issue today... I think it would be nice to support at least @skip and @include first, which are the most common used directives. would you mind sharing the place where that early return would be? thanks!

@hayes
Copy link
Owner Author

hayes commented Sep 7, 2023

@juliobetta likely it would need to be added somewhere in this function that maps a query to a prisma selection: https://github.com/hayes/pothos/blob/main/packages/plugin-prisma/src/util/map-query.ts#L38

You can see the logic the graphql execute flow uses here: https://github.com/graphql/graphql-js/blob/main/src/execution/collectFields.ts#L306

@liquiad
Copy link

liquiad commented Sep 26, 2023

I think this issue should stay open as @defer and @stream are still missing.

@hayes hayes reopened this Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants