DEV Community

Domitrius
Domitrius

Posted on

Has anyone used Apollo Server 2 w/ Prisma?

I'm starting a project I'd like to use for a workshop. (setting up to submit for a few upcoming conferences) Just looking for opinions/examples.

Thanks :)

Top comments (9)

Collapse
 
nikomontana profile image
Niko Montana

Well it seems that @leob didnt quite get the conzept of prisma. I must admit, at first I didnt to.

The most misleading point in this topic is that prisma got an "graphql like" query language. Which does not mean it automatically provides graphql to you.

Now for even better understanding, leave prisma out of this paragraph. You have installed your Apollo server - great! Now you are writing your first resolver which should display all "to-do" items to the client. How do you fetch the data from the database?

You should be able to understand now that prisma is exactly this - an ORM.

@Domiritus Yeah, would also like to know if somebody is rocking with this setup in production.

I tried prisma for some node apps and really liked the workflow - it feels like next gen to me, especially when prisma admin started! Prisma and TypeScript is really fast for me.

My team was really thinking about scaling and we got into Apollo because with Apollo Platform you have valuable insights about your performance and much more.

What I discovered is that there can be some limitations with prisma with nested queries - sometimes you have to run 2 queries, which kind of sucks but they told me they are working on this. I dont bother because I can always run direct SQL queries to.
And from Apollo side we are currently searching a solution to provide webhooks for third party companies.

Hope that helps =)

Collapse
 
alan345 profile image
Alan • Edited

Great answer!

My limitations so far with Prisma are:
-the 1000 max node. In my backend, sometimes, I have to sum all Prices: invoice { id price }. If you used ctx.db.query.invoices(), you will get a max of 1000 nodes.. (stackoverflow.com/questions/573132...). I also used in parallel a server SQL to run my customs queries to solve that issue.. (youtube.com/watch?time_continue=15...)

-running in production. Because everything is in docker, the database and the Apollo server are in the same image. I could not find any documentation regarding the good practices.

-they started with graphCool, then Prisma and now Prisma2. Hard to follow. And Im really afraid of the breaking changes.

-Order by related fields: You have a table wit column companyName/UserName. you pull id Invoice user { id UserName} with ctx.db.query.companys(). You can order the table by companyName, but Not by UserName. (1 user has 1 company)
(github.com/prisma/prisma/issues/95)

For the rest, Prisma is amazing.. I recommend it!

Collapse
 
chemicalkosek profile image
Kosek • Edited

I think you can set up the limit for yourself from Prisma 1.32.1

port: 4466
        databases:
          default:
            connector: postgres
            host: postgres
            port: 5432
            user: prisma
            password: prisma
            queueSize: 10000
Enter fullscreen mode Exit fullscreen mode
Collapse
 
leob profile image
leob

Got it, yes Prisma is an ORM, from there site:

"Prisma replaces traditional ORMs and can be used to build GraphQL servers, REST APIs, microservices & more"

What confused me is that apart from their ORM ('Prisma') they are also offering a GraphQL server called 'GraphQL Yoga' (github.com/prisma/graphql-yoga). But then again, Yoga is again based on Apollo-Server (and a few other packages).

So yes they're marketing it as "easiest way to run a GraphQL server" but it's basically an ORM, which you can use with Apollo (server). Apologies for causing unnecessary confusion :-)

Collapse
 
leob profile image
leob • Edited

Why are you choosing Prisma, and not just staying within the Apollo stack? I'm also interested in GraphQL and Apollo seems the most mature stack (and ecosystem) by far. I've read about Prism but for simplicity I'd choose to stay within the "mainstream" i.e. entirely within the Apollo stack. Large community, easy to google/SO your answers, etc.

As soon as you start integrating additional stacks/technologies then the complexity rises exponentially and there are far fewer answers to be found (on that particular combination of technologies) on SO etc.

By the way what are you going to use for the client (frontend) ?

Collapse
 
cpattondev profile image
cpattonDev

What orm would you consider to be inside the Apollo Stack. I have used sequelize in the past and now i want to try out prisma.

Collapse
 
leob profile image
leob

Well, seeing other comments here in this thread (the one below from Renaud looks very convincing) it looks like Prisma is the way to go, most advanced and mature.

Collapse
 
renaud009 profile image
Renaud Hébert-Legault • Edited

Currently working with both apollo server and prisma. Those two technologies are complementary and awesome.

I use Prisma as the ORM layer that facilitates (autogen) communication with the DB while providing crazy advanced queries, mutations and search/filtering inputs for all entities.

Then I use Apollo Server 2 to act as a middleware layer that validate permissions which are in an external REST service. My apollo server also offers some more custom queries and mutations that call Prisma or some other services, such queries and resolvers are stitched into a single massive schema.

Collapse
 
thearidg profile image
Aritra Dattagupta

Prisma is a modern ORM built with graphql in mind. If you are using typescript, checkout typegraphql-prisma or just typegraphql