Building GraphQL Servers in 2022
Building GraphQL servers in 2022 couldn’t be any easier thanks to GraphQL Yoga. This year at HasuraCon 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 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, 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.