React Server components I just discovered this <ht...
# orm-help
p
React Server components I just discovered this https://github.com/prisma/prisma/tree/master/src/packages/react-prisma Thanks for taking this on early @tim2 @Joël. I am super excited for react server components and the potential it will bring. Glad to see prisma is staying on top of it. Question: Will there be a way to do mutations with react-prisma? or will it simply be queries done on server components?
t
@Pieter I think doing mutations rather makes sense outside of react-prisma, like they’re also doing it in the example with postgres
So for mutations for now I would say you should just import the normal prisma client (which you can totally do in a server component as well). In the example they had that in a separate api
p
yep, but it would be nice if react-prisma could wrap that logic for us
What I am more looking for is a usePrisma hook or useMutation. Similar to apollo's hooks
except it doesnt take a graphql query, but rather a function calling prisma client
like blitz.js does
t
Good point! We’ll see what we can do 🙂
🦜 1
p
checking in now that a month has past. Where we at with this? Any chance of this happening?
t
👋 so mutations don’t make sense in react-prisma, as for now you can just read in server components, that will also stay like that for a while
If you want to mutate, they use their custom mutations in the demo anyway, which directly sends back the rendered component
There’s not really anything we can do there from the Prisma side yet
Or what exactly have you imagined there?
(Prisma doesn’t plan to get into the frontend business with a RPC library btw)
p
I didn't mean to do it inside the server component. I kinda meant like a rpc lib as you pointed out above. Maybe not fully fledged rpc lib, but some way to call prisma queries from the frontend. If prisma specifically wants to stay out of it, I get that. Was worth asking though
t
Yes, so I think for now we want to keep out of that business
Definitely worth asking
If you would like to work on something like that, we’re more than happy to give you some help
Because I still believe this should exist outside of Blitz
I think there are a few libs doing rpc stuff, also with TypeScript, maybe worth checking out what’s there already
p
Sorry @tim2 I only saw your reply now. I've actually started working with the maintainer of trpc on getting things in there, so its all good. We'll probably end up making a prisma adapter on top of it to generate some crud operations out of the box for users who don't want to configure things. We could stick it into something like react-admin and have an auto generated crud system in place. That way one can have their very own hosted prisma studio alternative with fine-grained control to add auth on top of it as it will be open source unlike studio
k
that would be me 🙋‍♂️ @tim2 have a look at trpc.io 🙂
t
Nice, that looks exciting!