Prisma plug-in exposing all fields #429
Replies: 3 comments 5 replies
-
This is probably not something that would be part of Pothos core. It could be something you could write yourself if you wanted. There will be some utilities coming in the future (see #348) that will make building something like this your self easier. It would be posssible to use data from the prisma client (currently I strongly believe that your data and API should not be tied closely together, and the Pothos APIs try to reflect that by making the types and fields in your API be defined explicitly. A simple test for this is asking if the API would change automatically if your data source chages. In Pothos, the goal is for this to cause a type-error rather than for it to cause a change in the schema. You will notice things like the expose methods requiring the field name as well as the name of the column they are exposing even though they are often the same. Pothos also requires you to explicit define the type of the fields you are exposing. a String type in your DB could be a String in graphql, but it could also be an ID, or a custom scalar like email. When you get into exposing things automatically you take away that control, and usually end up with a lower quality API. I recently posted a bit about plans around making crud APIs easier to build in the Pothos discord channel:
Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
I can probably use the Prisma |
Beta Was this translation helpful? Give feedback.
-
This feature would be extraordinarily helpful in early prototyping/development; perhaps enabled/gated by some sort of |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to expose all Prisma fields on an Object automatically without exposing the one by one explicitly?
Beta Was this translation helpful? Give feedback.
All reactions