Future-Proof GraphQL Schema Design

Rate this content
Bookmark
Slides

In this talk, we will cover schema evolution best practices, common mistakes when extending an existing GraphQL schema and patterns for safely monitoring usage, and finally removing deprecated GraphQL fields over time. The state-of-art GraphQL schema does not need versioning as it only ever returns data that is explicitly requested by a client. In theory, new capabilities and types added to the GraphQL schema are only available as the client updates their operation selection sets. However, in reality, altering and extending a GraphQL schema could easily break existing clients depending on how the change has been implemented, especially when using enum, interface, and union types.

FAQ

GraphQL Yoga version 3 is designed with production-ready defaults such as error masking, validation and parser caching, and health checks. These features ensure that GraphQL servers are secure, performant, and reliable out of the box.

GraphQL Yoga is a server library designed to simplify the setup of a GraphQL server. It was initially created by Prisma to make GraphQL more accessible to newcomers by simplifying existing GraphQL server solutions, which were deemed too complicated.

GraphQL Yoga version 3 focused on ease of use, production readiness, and flexibility to fit into any existing JavaScript stack. It supports new features like serverless deployment and enhanced subscription handling without WebSockets, aiming to be as inclusive as possible for various development environments.

The Guild is a group of developers specializing in open source projects and client work. They adopted GraphQL Yoga after Prisma shifted focus away from GraphQL, updating it and maintaining it as part of their suite of tools to help developers solve common problems.

The Guild has developed several notable projects including GraphQL Code Generator, GraphQL Mesh, GraphQL Inspector, GraphQL Hive, and GraphQL Tools. These tools address various aspects of working with GraphQL, from code generation to schema management and validation.

GraphQL Yoga can be integrated into various JavaScript runtimes such as Node.js, Deno, Bunn, and Cloudflare Workers, thanks to its flexible architecture that utilizes the Fetch API's request-response model. This allows it to operate across multiple platforms efficiently.

The plugin system in GraphQL Yoga allows developers to extend functionality and tailor the server to specific needs. Plugins can be used for tasks like caching, security enhancements, and adding support for advanced GraphQL features like persistent queries and federation.

Laurin Quast
Laurin Quast
38 min
08 Dec, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Today's Talk is about GraphQL Yoga version 3, its evolution, improvements, and features. Yoga version 3 is easy to get started with, production-ready by default, and fits into any existing stack. It offers upgrades to GraphQL 2, simpler subscriptions, and a powerful deference stream feature. Yoga aims to make production deployment easier with error masking, validation and parser caching, health checks, and integration with JavaScript runtimes. The Talk also highlights the extendability of Yoga through plugins and its battle-tested nature in production.

1. Introduction to GraphQL Yoga Version 3

Short description:

Today we're going to talk about building great GraphQL server experiences with GraphQL Yoga version 3. I'm Loren, an open source developer at The Guild. The Guild is a group of developers solving client problems and contributing to open source. We have prominent projects like code generator, GraphQL mash, GraphQL inspector, GraphQL Hive, GraphQL tools, and GraphQL scholars. Today, we'll focus on GraphQL Yoga version 3 and its evolution from Prisma's creation to The Guild's involvement.

Hello, everyone. Today we're going to talk about building great GraphQL server experiences with GraphQL Yoga version 3.

First of all, I'm Loren, and I'm an open source developer at The Guild. You can find me on Twitter and GitHub where I'm mostly posting about open source development.

Before we start with the actual talk, let's have a few words about the Guild. So we at The Guild, we are a group of developers that have been doing open source since almost forever, and we assemble together for client work. And what we're doing is basically, we're working with clients solving their problems. And from there on we look at those issues, see how we can abstract them and share them with the world. And usually that will result in open source software that we then publish and make available for everyone. So basically, we solve problems and feed them back into open source.

So here's a short summary of some of our most prominent projects that we're currently having, which is basically code generator, which is a tool for generating code and type definitions for any language for your existing GraphQL server. And we have GraphQL mash, which is basically a library for converting any data source into a GraphQL SDK or gateway. We have GraphQL inspector, which is a schema validation and breaking change detection tool for UCI or CD flow. We also have GraphQL Hive, which is basically a GraphQL schema registry and insight platforms for Teams. It's available as a self-hosted version, but also as a SaaS version. Then we also have GraphQL tools, which is an utility for all kinds of GraphQL schema and server tooling that you might need. And then also very popular is GraphQL scholars, which is a scholar and data types, validation types for GraphQL GS. That is basically only a small excerpt of all the stuff we have. You can find more of that on the guild.dev. But today we're going to talk about GraphQL Yoga version 3.

So before we start with that, let's quickly give you a short overview of what happened in the past. How Yoga evolved and how we got to it until today. So I'll try to keep it short, so, someday in the past, Yoga was created by Prisma and the reason for that was that at this point all the available GraphQL server solutions that were already there were far too complicated. So for new people that started coming into the GraphQL space, they had a hard start for actually getting started with GraphQL. So Prisma took the existing Apollo server, wrapped it in another layer and out of that Yoga was born. Then shortly after that, the community saw this GraphQL Yoga server and for obvious reasons, ease of use and batteries included, they started adopting it. Then a while later, Prisma moved away from GraphQL. They introduced their own SDL, ditched GraphQL and inevitably then GraphQL Yoga ended up being unmaintained for a long time, actually. And a lot of GitHub issues and other issues, discussions piled up. That's when the guilt came in.

2. Evolution of GraphQL Yoga Version 3

Short description:

Last year, we adopted Yoga and started working on it. We released Yoga version 2, followed by GraphQL Yoga version 3. The key points for GraphQL Yoga version 3 were: easy to get started, production-ready by default, fit into any existing stack, hide unnecessary complexity, provide solutions for common problems, and allow individuals to solve specific needs with a powerful plugin system. Spinning up a GraphQL server with yoga is as easy as pie, and you get a full GraphQL server with all the latest features.

So last year we reached out to the Prisma team and asked them what's their plan for Yoga and whether we should help them out. And in the end we adopted Yoga, we got the repository transferred over to us, and then we started working on it.

The first milestone that we had in mind was Yoga version 2, and basically the mission behind Yoga version 2 was to bring the Yoga library back into a state where it's maintained, where all the existing issues and feedback got addressed, critical dependencies were updated, and yeah, that happened. About half a year ago, back in June, we finally released Yoga version 2. And then, just a month ago, we released GraphQL Yoga version 3.

But what happened from GraphQL Yoga version 2 to GraphQL Yoga version 3? That's what I'm going to talk about now. So actually in June, when we just released GraphQL Yoga version 2, all of the Guild members were assembling back in San Francisco and were sitting together and we were brainstorming about the GraphQL Server Vision that everyone had. Everyone had some kind of vision, but every individual in the Guild had different needs. And coming from different backgrounds and working on different customer projects, there were different needs.

So after a lot of intense discussions, we came to the following key points that are valuable. So first of all, it should be easy to get started. Like GraphQL Yoga Version 1 was easy to get started and GraphQL Yoga Version 2 was also easy to get started, we wanted to keep that for GraphQL Yoga Version 3. Then the other thing that we wanted to do is to make GraphQL Yoga Version 3 as production ready by default as possible. So batteries included. The details about this I'm going to talk to you about later. So then also, we wanted GraphQL Yoga to fit into any existing stack. And that does not mean, oh, I want to use it with Express, or with Fastify, or I want to use SDL first, or code first. When we said fit into any existing stack, we actually meant any existing JavaScript out there, whether it's Deno, Bunn, Cloudflare Workers, we wanted to support them all. Then also, we wanted to hide unnecessary complexity, which is kind of related to easy to get started. Yeah. Also, we wanted to provide solution paths for common problems, like persistent operations, Apollo Federation, all those fancy words that are out there. We wanted to address them and give solutions for them. And then in the end, we also wanted to allow people or individuals to solve their own specific needs with yoga without having to ditch yoga, or move out of yoga, or having to fork yoga, which basically means we wanted to have a plugin system that is as powerful as possible.

So, how did we achieve all those points? Let's start with easy to get started. So spinning up a GraphQL server with yoga is as easy as pie. With this code on the right, you get a full GraphQL server that supports all the latest GraphQL features. This exists in Platform Primitives, in this example, we are using Node with the HTTP module. So you can also see that yoga is not abstracting the Node HTTP handling away. It's just a request listener that you get from the yoga library and you can plug it into any HTTP server that's either specific for Node or Cloudflare workers or BAN or DNO. And then also from that you get everything, including a GraphQL IDE.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

From GraphQL Zero to GraphQL Hero with RedwoodJS
GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
From GraphQL Zero to GraphQL Hero with RedwoodJS
Top Content
We all love GraphQL, but it can be daunting to get a server up and running and keep your code organized, maintainable, and testable over the long term. No more! Come watch as I go from an empty directory to a fully fledged GraphQL API in minutes flat. Plus, see how easy it is to use and create directives to clean up your code even more. You're gonna love GraphQL even more once you make things Redwood Easy!
Local State and Server Cache: Finding a Balance
Vue.js London Live 2021Vue.js London Live 2021
24 min
Local State and Server Cache: Finding a Balance
Top Content
How many times did you implement the same flow in your application: check, if data is already fetched from the server, if yes - render the data, if not - fetch this data and then render it? I think I've done it more than ten times myself and I've seen the question about this flow more than fifty times. Unfortunately, our go-to state management library, Vuex, doesn't provide any solution for this.For GraphQL-based application, there was an alternative to use Apollo client that provided tools for working with the cache. But what if you use REST? Luckily, now we have a Vue alternative to a react-query library that provides a nice solution for working with server cache. In this talk, I will explain the distinction between local application state and local server cache and do some live coding to show how to work with the latter.
Batteries Included Reimagined - The Revival of GraphQL Yoga
GraphQL Galaxy 2021GraphQL Galaxy 2021
33 min
Batteries Included Reimagined - The Revival of GraphQL Yoga
The Guild has recently released Envelop - a new, modern GraphQL Server Framework and plugin system. In this talk I’ll share a brief overview of Envelop and why you should probably upgrade your existing GraphQL server to it.
Rock Solid React and GraphQL Apps for People in a Hurry
GraphQL Galaxy 2022GraphQL Galaxy 2022
29 min
Rock Solid React and GraphQL Apps for People in a Hurry
In this talk, we'll look at some of the modern options for building a full-stack React and GraphQL app with strong conventions and how this can be of enormous benefit to you and your team. We'll focus specifically on RedwoodJS, a full stack React framework that is often called 'Ruby on Rails for React'.
Step aside resolvers: a new approach to GraphQL execution
GraphQL Galaxy 2022GraphQL Galaxy 2022
16 min
Step aside resolvers: a new approach to GraphQL execution
Though GraphQL is declarative, resolvers operate field-by-field, layer-by-layer, often resulting in unnecessary work for your business logic even when using techniques such as DataLoader. In this talk, Benjie will introduce his vision for a new general-purpose GraphQL execution strategy whose holistic approach could lead to significant efficiency and scalability gains for all GraphQL APIs.

Workshops on related topic

Build with SvelteKit and GraphQL
GraphQL Galaxy 2021GraphQL Galaxy 2021
140 min
Build with SvelteKit and GraphQL
Top Content
Featured WorkshopFree
Scott Spence
Scott Spence
Have you ever thought about building something that doesn't require a lot of boilerplate with a tiny bundle size? In this workshop, Scott Spence will go from hello world to covering routing and using endpoints in SvelteKit. You'll set up a backend GraphQL API then use GraphQL queries with SvelteKit to display the GraphQL API data. You'll build a fast secure project that uses SvelteKit's features, then deploy it as a fully static site. This course is for the Svelte curious who haven't had extensive experience with SvelteKit and want a deeper understanding of how to use it in practical applications.

Table of contents:
- Kick-off and Svelte introduction
- Initialise frontend project
- Tour of the SvelteKit skeleton project
- Configure backend project
- Query Data with GraphQL
- Fetching data to the frontend with GraphQL
- Styling
- Svelte directives
- Routing in SvelteKit
- Endpoints in SvelteKit
- Deploying to Netlify
- Navigation
- Mutations in GraphCMS
- Sending GraphQL Mutations via SvelteKit
- Q&A
End-To-End Type Safety with React, GraphQL & Prisma
React Advanced Conference 2022React Advanced Conference 2022
95 min
End-To-End Type Safety with React, GraphQL & Prisma
Featured WorkshopFree
Sabin Adams
Sabin Adams
In this workshop, you will get a first-hand look at what end-to-end type safety is and why it is important. To accomplish this, you’ll be building a GraphQL API using modern, relevant tools which will be consumed by a React client.
Prerequisites: - Node.js installed on your machine (12.2.X / 14.X)- It is recommended (but not required) to use VS Code for the practical tasks- An IDE installed (VSCode recommended)- (Good to have)*A basic understanding of Node.js, React, and TypeScript
GraphQL for React Developers
GraphQL Galaxy 2022GraphQL Galaxy 2022
112 min
GraphQL for React Developers
Featured Workshop
Roy Derks
Roy Derks
There are many advantages to using GraphQL as a datasource for frontend development, compared to REST APIs. We developers in example need to write a lot of imperative code to retrieve data to display in our applications and handle state. With GraphQL you cannot only decrease the amount of code needed around data fetching and state-management you'll also get increased flexibility, better performance and most of all an improved developer experience. In this workshop you'll learn how GraphQL can improve your work as a frontend developer and how to handle GraphQL in your frontend React application.
Build a Headless WordPress App with Next.js and WPGraphQL
React Summit 2022React Summit 2022
173 min
Build a Headless WordPress App with Next.js and WPGraphQL
Top Content
WorkshopFree
Kellen Mace
Kellen Mace
In this workshop, you’ll learn how to build a Next.js app that uses Apollo Client to fetch data from a headless WordPress backend and use it to render the pages of your app. You’ll learn when you should consider a headless WordPress architecture, how to turn a WordPress backend into a GraphQL server, how to compose queries using the GraphiQL IDE, how to colocate GraphQL fragments with your components, and more.
Relational Database Modeling for GraphQL
GraphQL Galaxy 2020GraphQL Galaxy 2020
106 min
Relational Database Modeling for GraphQL
Top Content
WorkshopFree
Adron Hall
Adron Hall
In this workshop we'll dig deeper into data modeling. We'll start with a discussion about various database types and how they map to GraphQL. Once that groundwork is laid out, the focus will shift to specific types of databases and how to build data models that work best for GraphQL within various scenarios.
Table of contentsPart 1 - Hour 1      a. Relational Database Data Modeling      b. Comparing Relational and NoSQL Databases      c. GraphQL with the Database in mindPart 2 - Hour 2      a. Designing Relational Data Models      b. Relationship, Building MultijoinsTables      c. GraphQL & Relational Data Modeling Query Complexities
Prerequisites      a. Data modeling tool. The trainer will be using dbdiagram      b. Postgres, albeit no need to install this locally, as I'll be using a Postgres Dicker image, from Docker Hub for all examples      c. Hasura
Building GraphQL APIs on top of Ethereum with The Graph
GraphQL Galaxy 2021GraphQL Galaxy 2021
48 min
Building GraphQL APIs on top of Ethereum with The Graph
WorkshopFree
Nader Dabit
Nader Dabit
The Graph is an indexing protocol for querying networks like Ethereum, IPFS, and other blockchains. Anyone can build and publish open APIs, called subgraphs, making data easily accessible.

In this workshop you’ll learn how to build a subgraph that indexes NFT blockchain data from the Foundation smart contract. We’ll deploy the API, and learn how to perform queries to retrieve data using various types of data access patterns, implementing filters and sorting.

By the end of the workshop, you should understand how to build and deploy performant APIs to The Graph to index data from any smart contract deployed to Ethereum.