DEV Community

Discussion on: NextJS x GraphQL x Apollo Client SSR

Collapse
 
rezaavoor profile image
Reza Hosseini

Just wondering what the benefit of using graphql api is when using Next.js. Can't you just talk to the database directly in Nextjs backend part instead of having an extra api doing that for you?

Collapse
 
ghackdev profile image
ghack.dev • Edited

Actually, GraphQL is my only backend. I'm consuming some third-party APIs like dev.to API and Youtube API that I orchestrated in my GraphQL backend. I also retrieve some data from MongoDB.

I preferred to use GraphQL rather than Rest API because with GraphQL I can do a lot of things and have good documentation about the data that will be consumed by the front-end apps, web and I also have a plan to build a mobile app.

The benefits of using GraphQL are also I can use Apollo Client that has a lot of awesome features like caching, optimistic response and it also can be rendered on the server for SEO purposes so I think it fits my needs, because I want to build an Isomorphic web app.

Collapse
 
rezaavoor profile image
Reza Hosseini

Ah that explains it.
Thank you!