Tomek Poniatowicz
Posted on May 5, 2022
Everyone including beginners who are just getting into GraphQL sooner rather than later arrives at what you can call the server question. In GraphQL everything is basically dealt with in two parts, the schema (type definitions and resolvers) and the HTTP server. On the client side you can find many useful libraries that will help you build your schema and everything is in SDL which is a pretty transparent language that isn't too hard to get a hang of. The server side might be a bit tougher to handle, but there’s also a number of options that can help you with that as well. One particular library just got a big revamp so it's a good idea to check it out.
Yoga 1.0 - quick and easy
Graphql-yoga has been around since 2017 and while not nearly as popular as Apollo-server it did have a lot of advantages. Its documentation described it as ‘create-react-app for building GraphQL servers’ and it's hard to argue with that. It required minimal setup, kept most of the boilerplate code you usually get when starting a server hidden and handled much of the initial project setup for you. Together this made it the easiest server option for beginners to get into as well as a useful tool for experienced users looking for a way to make a quick NodeJS GraphQL server. Down the line if your project grew too large for Yoga you could’ve simply swapped it out for a more complex tool like the above mentioned Apollo-server. All wasn't rosy though as by 2019 the project stopped getting updates and was basically abandoned. This resigned it to the role of a learning tool with some uses in case you need to get up a server quickly, but pretty much ensured you wouldn't ever use it for a fully fledged project. The fate of the Yoga library might’ve been a bit of a bummer considering the lack of an alternative lightweight and versatile GraphQL server option.
The Guild comes to the rescue
In late 2021 Yoga was taken over by The Guild and they decided to rewrite it from scratch. Their main focus was performance, flexibility, easy setup and improving overall developer experience, in other words a lot of what the old Yoga was about combined with new more comprehensive solutions. The key thing here is that The Guild promises to be here for the long run and not only update Yoga, but also keep working on improving it with new features. They can be trusted to uphold that as they have quite a bit of experience with GraphQL with a number of popular and still developed libraries like GraphQL Tools or Envelop. On GitHub you can already see Yoga has received hundreds of commits and lots of updates so the project is very much alive. In late March the big 2.0 update finally arrived so let’s check out what the key features are:
- flexible: Built around W3C Request/Response which is supported in all major serverless, worker and serverful JavaScript environments, Yoga is designed to run basically anywhere
- lean: Yoga has a really light core and a small bundle size, three times smaller than Apollo-server, which can prove very significant for performance in serverless environments and make maintenance much easier in general
- out of the box: Some popular GraphQL API features like advanced error handling, file-uploads, subscription support or CORS come built-in with Yoga
- easy to get a hang of: Keeping up with the beginner firendly approach Yoga has robust documentation and comprehensive tutorials to help you get to know all the features and functionalities
- plugin system: With Envelop The Guild has started a large plugin system for GraphQL, which Yoga has built-in and comes with a default preset enabled (which can be disabled or customized)
Beyond 2.0
Yoga has been a useful tool for easily and quickly creating a GraphQL server, especially great if you just wanted to get a hang of it. Now though it looks like the aims are quite a bit larger and the team behind it wants to make it a viable or even superior alternative to other server options. It already had its niche and now fusing the old Yoga approach of getting started quickly with the rich ecosystem of Envelop can prove to be a powerful combination. The Guild know their way around GraphQL and have already created a number of very useful and popular tools so we pretty much know we can expect good things to happen to Yoga as well. With the development picking up speed so quickly additional new features will probably arrive soon, so even if you’re still not convinced it's a good idea to keep an eye out on the growth of Yoga and how it compares to other server options.
A guest blog post for GraphQL Editor blog by Michał Tyszkiewicz
Speed up your GraphQL API development
GraphQL Editor is a supportive tool for both advanced GraphQL users as well as those taking their first steps with GraphQL APIs. Our all-in-one development environment for GraphQL will help you build, manage & deploy your GraphQL API much faster. Try GraphQL Editor for free!
Posted on May 5, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
March 27, 2024