How to Choose the Best GraphQL Server for Your Next Project

Article summary

After choosing to use GraphQL to facilitate your backend API development (as opposed to REST), you still need to decide which implementation of the GraphQL spec to use. Three noteworthy GraphQL server implementations are GraphQL Yoga, Apollo Server (v3), and Express GraphQL.

All of these server options boast GraphQL spec compliance, Typescript support, and compatibility with various GraphQL clients. The differences lie in the expressive power and setup details. Note that many more GraphQL server options exist (and I would encourage you to explore those options not mentioned here). However, the following will be sufficient for most situations.

Yoga

The GraphQL server option with the lowest bar to entry is perhaps GraphQL Yoga. Yoga requires minimal setup and hides much of the boilerplate code common with initializing a server. This makes it perfect for beginners and those developing their first GraphQL server. As the Yoga documentation puts it, “graphql-yoga is like create-react-app for building GraphQL servers.” Therefore, like create-react-app for React projects, graphql-yoga abstracts away much of the initial project setup for GraphQL servers. Furthermore, if you grow your project beyond the restrictive boundaries of Yoga, it can easily be ejected and swapped out with a tool like apollo-server.

Apollo

Apollo Server (v3) is another popular choice for GraphQL servers. As mentioned previously, GraphQL Yoga is, in part, built upon Apollo. This creates a logical pipeline from Yoga to Apollo during the evolution of a project. While Apollo Server is compatible with any GraphQL client, it is an obvious choice if you are already using Apollo Client in your project. Because of the vibrant Apollo ecosystem and advanced production-ready tooling, Apollo Server is a great choice for larger, more nuanced projects.

Express

Finally, another popular GraphQL server option worth mentioning is Express GraphQL. Express works with any HTTP framework that supports connect styled middleware. Notably, this includes Connect, Express, and Restify. This makes express an appealing choice for those familiar with or who are using RESTful web services, such as Restify. However, in most other situations, I still prefer Apollo server and the encompassing ecosystem due to its robust community and feature set.

My Go-To

Personally, I value the ease of setup with GraphQL Yoga. I’ve enjoyed using it to quickly get projects up and running. Once projects grow larger, or if I need a more nuanced setup, I prefer Apollo. Furthermore, it is convenient to remain within the Apollo ecosystem, and Apollo Client is an excellent choice for a GraphQL client. If it is unclear where to start, this would be my recommended path.

I should note that any of the above GraphQL server implementations will be sufficient for most use cases, and the choice could come down to personal preference or familiarity. Additionally, the above-mentioned frameworks are very syntactically similar. Therefore, in new projects, one implementation can be torn out and replaced with another in a matter of minutes. For this reason, you may instead find yourself changing frameworks to meet the needs of your project. I hope this encourages exploration of various GraphQL server implementations, and that you find one that works for you!

Conversation
  • Donkey Kong says:

    Honestly thank you so much for your page. I’ve perused all kinds of topics on your channel, and I always thoroughly enjoy all of your content.

  • Comments are closed.