Which GraphQL Server and Client for Node.js should you use? A Comparison.
We will walk you through the most recent and most popular open-source GraphQL Servers and Clients and share some useful hints and insights in our choices along the way.
Apollo Server is an open-source GraphQL server with a great developer experience and a huge community. Its development is led by Apollo Graph Inc. which also provides enterprise support.
When to choose Apollo Server:
- simple setup
- excellent documentation
- great tooling and developer experience
- enterprise support
GraphQL.js is the reference implementation of the GraphQL specification in Node.js. It is the best choice if you want to start small and don’t need the full blown and extensible Apollo framework.
When to choose GraphQL.js:
- If you only need the most basic GraphQL server features
- Small footprint — not as big as the Apollo framework — therefore you need to do more by yourself
Also have a look at this Blogpost comparing GraphQL.js with Apollo.
⭐ 6k GitHub stars
Express GraphQL is the reference implementation of a GraphQL server over an Express web server.
When to choose Express GraphQL:
- Extend your existing Connect, Express or Restify API with a GraphQL endpoint
- Simple to get started
When we want to connect our web frontends to a GraphQL backend it’s always a trade-off between simplicity, tooling and performance (e.g. bundle size).
For small use cases and straightforward GraphQL queries, always start with a plain fetch call:
When to use fetch:
- For small applications
- Simple GraphQL calls
If it gets any more complex, let’s have a look at the following GraphQL clients:
Apollo Client is a full-featured GraphQL client that comes with caching and integrations for React, Angular, and more.
When to use Apollo Client:
- Full-featured GraphQL client
- Flexible client with a shallow learning curve
- Easy to integrate into existing applications
- Huge community & support
Relay is a framework for building data-driven React applications on top of a GraphQL API. Its development is led by Facebook. Relay makes additional assumptions about the standard GraphQL specification. Therefore you need a Relay compatible GraphQL server.
When to use Relay:
- Full featured GraphQL client
- Structured and opinionated client that enforces a defined style
- Working with a big team on the same huge application
- Your GraphQL server follows the Relay GraphQL specification
GraphQL Hooks is a minimal GraphQL client for React.
When to use GraphQL Hooks:
- Web performance: Tiny bundle size
- You only need the basic (query, mutations) GraphQL features
- Versatile, easy to integrate and use
Or another one by LogRocket comparing graphql-hooks with Apollo hooks: https://blog.logrocket.com/comparing-hooks-libraries-for-graphql
Which library you choose always depends on your use case. On our backends we mostly use Apollo GraphQL server because of simplicity, great tooling, and enterprise support.
On our frontends we start simple with browser fetch calls. For more advanced applications we use the graphql-hooks library because of its small bundle size. Only if we need a more advanced feature set we use the Apollo GraphQL client, because the size of the package is not negligible.
This should give you a good starting point. If you want to know more, have a look at https://graphql.org/code/ for an extensive list of even more clients, servers and tools — also in other programming languages.
Build Enterprise-Grade GraphQL Applications
Want to become a GraphQL pro? Follow us and read our whole series on enterprise-grade GraphQL applications.