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

Schema delegation #116

Closed
frandiox opened this issue Jul 9, 2019 · 10 comments
Closed

Schema delegation #116

frandiox opened this issue Jul 9, 2019 · 10 comments
Labels
kind/feature A request for a new feature. team/client Issue for team Client. topic: prisma1

Comments

@frandiox
Copy link

frandiox commented Jul 9, 2019

I'm modifying the original issue according to #117 (comment)

For GraphQL APIs, schema delegation was a very handy feature in Prisma 1. It would be nice to have it in Prisma 2 as well, especially for those who want to migrate from v1.

Basically, the idea is that Prisma 2 understands the GraphQL's info object to query data. I can think of two ways to implement this:

  • As a core feature of Prisma Client itself: instead of using select or includes, we just pass info object and it's used for querying.
  • As a small external tool that transforms info object into something that can be passed to Prisma Client's select. A proof of concept for this can be found here (a bit outdated since it still uses PhotonJS API).

The premise for all of this is that fields included in the info object (from GraphQL server API) must match the DB fields. If some field doesn't match, it should be ignored.

Advantages: Very handy for GraphQL servers; It would be way simpler to migrate from Prisma 1 + bindings to Prisma 2.
Disadvantages: I think editor type autocompletion wouldn't work since this all happens at run time.

Edit: Just found @prisma-tools, which might be enough to implement all of this.

@pantharshit00 pantharshit00 added kind/feature A request for a new feature. priority/mid labels Jul 9, 2019
@schickling schickling added kind/question and removed kind/feature A request for a new feature. priority/mid labels Jul 10, 2019
@frandiox

This comment has been minimized.

@janpio

This comment has been minimized.

@janpio janpio reopened this Aug 21, 2019
@macrozone
Copy link

we use prisma with https://github.com/marmelab/react-admin/ through https://github.com/Weakky/ra-data-opencrud/. This gives as a easy CRUD admin app. We use prisma-binding to forward all queries and mutations and add graphql-shield, so that we can restrict acess to these apis.

It seems that nexus should help with that: https://nexus.js.org/docs/database-access-with-prisma-v2

so it seems that most information needed is out there, but its a bit hard to find the right approach at the moment

I therefore would love to see a more consolidated documentation with usecases like that.

@marcantoine
Copy link

@macrozone I use the same setup (with a fork of ra-data-opencrud). Did you figure out how we can use delegation/forward with nexus-prisma &prisma2 since then?

@frandiox
Copy link
Author

@macrozone @marcantoine I just created a small tool to transform info into PhotonJS's select API at runtime: https://github.com/frandiox/graphql-info-transformer

It's just a proof of concept but might be helpful. It doesn't need Nexus although generating a DB-GraphQL-schema without it might be hard (for things like "UpdateUserWhereInput" and stuff like that).

@divyenduz

This comment has been minimized.

@janpio janpio reopened this May 11, 2020
@janpio janpio changed the title Schema delegation in Prisma 2 Schema delegation May 11, 2020
@janpio janpio added kind/feature A request for a new feature. topic: prisma1 and removed kind/question labels May 11, 2020
@macrozone
Copy link

@macrozone I use the same setup (with a fork of ra-data-opencrud). Did you figure out how we can use delegation/forward with nexus-prisma &prisma2 since then?

we have built and open sourced a new data-provider for rect-admin https://github.com/panter/ra-data-prisma

it also comes with some helper function that exposes all needed mutations and queries for a given resource using nexus

@janpio janpio assigned janpio and sorenbs and unassigned janpio May 12, 2020
@terion-name
Copy link

@frandiox so how did you manage query forwarding?

@frandiox
Copy link
Author

frandiox commented Sep 9, 2020

@terion-name Query forwarding as in using the forward('users') utility? I would remove those and just call Prisma Client manually in a new resolver.

@pantharshit00 pantharshit00 added the team/client Issue for team Client. label Apr 22, 2021
@janpio
Copy link
Member

janpio commented Jun 20, 2023

Thanks for opening this issue in 2019 @frandiox.

I think it has become clear that this is out of scope for Prisma, and should be solved via a community project if there is still a need for it. Generally it still sounds useful for someone heavily using GraphQL, but I know far to little how that evolved in the last 4 years to really evaluate this.

I am going to close the issue for now. Thanks!

@janpio janpio closed this as not planned Won't fix, can't repro, duplicate, stale Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. team/client Issue for team Client. topic: prisma1
Projects
None yet
Development

No branches or pull requests

9 participants