Hello, I have a question that may be a beginner qu...
# orm-help
a
Hello, I have a question that may be a beginner question but I can’t figure out a simple answer. I use (and love) the prisma api with a prisma service, connected to a react app via apollo. The problem is that when a go into my browser console and in the network tab, I can see the URL apollo is making the request against and, by just copy pasting it, anyone can do so and do whatever they want. I found ways to use a custom server to proxy the requests but is there a simpler way? Thanks πŸ™‚
i
you typically need something else in front of prisma to handle auth. i'm about to try https://github.com/maticzav/graphql-shield or similar on my apollo-server setup. there's also this: https://nexus.js.org/docs/database-access-with-prisma#hide-fields-of-a-model
j
Prisma is not meant to be a direct access layer to the 'outside'. It's meant to be used as an ORM-like service between your backend API and your database system. The best way to go about it is to write a quick server using graphql-yoga or apollo-server.
Like @iago here just beat me to say πŸ™‚
😁 1
I can also wholeheartedly recommend graphql-shield for auth purposes. Prisma recently released their new library called nexus-prisma, which simplifies the steps to get a 'protective layer' in front of your Prisma server significantly.
πŸ’― 1
a
Thanks a lot guys, I’ll try all of that πŸ™‚
🦜 1
j
Glhf! We're here if you need us! πŸ™‚
a
So, if I understood well, I put that on my server and connect it to Prisma, and I keep apollo on my client and instead of doing requests to prisma on the client side, I do requests to my server ie to nexus, right?
j
Yes.
nexus-prisma
still requires either GraphQL-Yoga or ApolloServer though.
a
Thanks!
I think I am kind of mixing everything up. When I created a service in the Prisma API, an heroku server was setted up by Prisma, should I keep using that or does the extra layer replaces it?
I am really sorry to bother you 😞 I started using graph.cool a long long time ago and kinda missed the transition to prisma
j
Hey, don't be sorry! We all start somewhere! πŸ™‚ You can choose how you want to do Prisma. I personally recommend doing it locally with your own DB and docker-compose, but you can create one on Prisma's own service. I would recommend the tutorial series in the docs. https://www.prisma.io/docs/get-started/01-setting-up-prisma-demo-server-JAVASCRIPT-a001/ shows you how to use their "Test DB" (Hosted in their cloud service). You can transition to Docker later.
Also, here: https://www.howtographql.com/graphql-js/1-getting-started/ Might be a little slow-paced if you have GraphQL experience from before, but it uses Prisma with GraphQL-Yoga. If this is still weird and confusing, feel free to throw me a PM and I'll create a quick little server to show you πŸ™‚
a
Thanks a lot Jenkins!
❀️ 1