Building GraphQL Servers in 2022

Building GraphQL servers in 2022 couldn't be any easier thanks to GraphQL Yoga. This year at HasuraCon (opens in a new tab) I discussed how Yoga started, how it evolved, and what we can expect from the future.
For many years of building GraphQL servers in the Node ecosystem, our choices have been limited. Apollo Server library has dominated the ecosystem. With its pairing client library, it was often a good fit for a very long time. However, I believe there are more mature and battle-tested solutions available today, thanks to the evolution of Yoga.
GraphQL Yoga (opens in a new tab) takes a different approach by providing enough bells and whistles that make you production-ready, but builds itself on top of the core primitives of HTTP. Yoga is runtime agnostic too, so if you're currently working with Cloudflare Workers, Vercel Functions, AWS Lambda or something else, Yoga will fit right in.
GraphQL Yoga comes with Envelop (opens in a new tab), and is the recommended way you should be using Envelop today to extend your GraphQL server.
If you haven't used Yoga before, this is how easy it is to create a production-ready GraphQL server:
import { createServer } from '@graphql-yoga/node'
const server = createServer({
schema: {
typeDefs: /* GraphQL */ `
type Query {
hello: String
}
`,
resolvers: {
Query: {
hello: () => 'Hello from Yoga!'
}
}
}
})
server.start()If you are interested in following along with me to build a server, add plugins and more, you can watch the recording of the workshop:
Hopefully you find this talk interesting, and you learn more about building GraphQL severs with Yoga!
Join our newsletter
Want to hear from us when there's something new? Sign up and stay up to date!
By subscribing, you agree with Beehiiv’s Terms of Service and Privacy Policy.
Recent issues of our newsletterSimilar articles
GraphiQL 3 Is Here and GraphiQL 4 Is Coming
GraphiQL 3 was released, here is what was changed and what will be in GraphiQL 4.
The complete GraphQL Scalar Guide
Knowing how native and custom GraphQL Scalar works enables building flexible and extendable GraphQL schema.
Build a GraphQL server running on Cloudflare Workers.
This course aims to build a practical GraphQL server on Cloudflare Workers using GraphQL Yoga, Pothos, Kysely, etc.
Using @defer Directive with GraphQL Code Generator
Learn how to boost GraphQL performance using the @defer directive and GraphQL Code Generator for deferred fragment field resolution.