GraphQL Mesh – Query Anything, Run Anywhere

Rate this content
Bookmark

In this talk I will demonstrate the new GraphQL Mesh library that was recently announced. GraphQL Mesh changes a lot of the traditional ideas about GraphQL and its relationship with other API protocols.

It can automatically generate a GraphQL API from openapi/Swagger, gRPC, SOAP, oData and others without changing the source and merge them all schemas into a single schema - Schema Stitching for any source!

In this talk I will share some of the original ideas behind it and my opinions on how the future looks for API consumption and exposure.

This talk has been presented at React Summit Remote Edition 2020, check out the latest edition of this React Conference.

FAQ

GraphQL Mesh is a tool that allows you to merge multiple existing data sources into a single GraphQL endpoint. It can take schemas from services like REST, gRPC, and OpenAPI, convert them into GraphQL, and then merge them. This allows for querying across these sources using GraphQL without modifying the original services.

GraphQL Mesh offers features like schema stitching, which integrates multiple schemas into one. It can handle various sources like OpenAPI, Swagger, gRPC, SQL, and more. Additionally, it supports schema federation, enabling the integration of distinct GraphQL services. GraphQL Mesh also allows for mocking of data sources, snapshot prefixing, and transformations.

Yes, GraphQL Mesh can be used with non-GraphQL backends. It is designed to create a GraphQL API layer over existing backends with different technologies such as REST, gRPC, or any other services with defined schemas or even inferred from response logs.

In microservices architectures, GraphQL Mesh can serve as a central or distributed gateway to unify various microservices with different interfaces into a consistent GraphQL schema. This simplifies frontend development, reduces the need for individual service handling, and improves overall data integration across services.

GraphQL Mesh provides type safety by generating fully typed GraphQL SDKs for the merged schemas it creates. This ensures that developers can work with consistent and predictable data types across different services, enhancing reliability and developer productivity in building and maintaining applications.

GraphQL Mesh enhances backend data handling by providing a unified GraphQL layer on top of various data sources, which may include older or legacy systems without GraphQL support. This integration allows developers to query and manipulate data from these sources uniformly, ensuring type safety and reducing the complexity in handling different data formats.

Uri Goldshtein
Uri Goldshtein
15 min
02 Aug, 2021

Comments

Sign in or register to post your comment.
Video Summary and Transcription
GraphQL Mesh is a tool designed to merge multiple existing data sources into a single GraphQL endpoint. It supports various backend technologies such as REST, gRPC, and OpenAPI, converting their schemas into GraphQL and merging them. Key features include schema stitching, which integrates multiple schemas into one, and schema federation, enabling distinct GraphQL services to be combined. GraphQL Mesh offers type safety by generating fully typed GraphQL SDKs and allows for mocking data sources and transforming them. It can be used as a central or distributed gateway in microservices architectures, simplifying frontend development and enhancing backend data handling. The Guild, the group behind GraphQL Mesh, also develops tools like GraphQL Code Generator and GraphQL Inspector. GraphQL Mesh provides a unified GraphQL layer, making it easier to query and manipulate data from various sources, including older or legacy systems without GraphQL support. For more information, visit graphicalmesh.com and join The Guild community for discussions and progress.

1. Introduction to GraphQL mesh

Short description:

Hi, everyone. My name is Uli, and I'm the founder of a group called The Guild. We are a group that created GraphQL Code Generator, GraphQL Inspector to compare schemas and validate it before you go to production, GraphQL CLI, GraphQL modules, and many other community packages that we maintain. Today I want to talk about a new library that we're very excited about, but it's called GraphQL mesh. GraphQL is great. We have type safety over the network, but what about all the data sources that we keep on query? Should we use GraphQL everywhere? One solution would be to build small GraphQL endpoints into those services into those old back-ends and teach them GraphQL or Federation. But many times those are old servers like an old Java server or .NET server. It's not maintained or the people there won't get to learn GraphQL in the foreseeable future.

Hi, everyone. My name is Uli, and I'm the founder of a group called The Guild. I have short time, so I'll get right to it. We are a group that created GraphQL Code Generator, GraphQL Inspector to compare schemas and validate it before you go to production, GraphQL CLI, GraphQL modules, and many other community packages that we maintain. And we strive to get very high level of maintenance of our open source libraries. And we combine them all because we use them as just building blocks or a complete platform for your building your applications using GraphQL.

So but today I want to talk about a new library that we're very excited about, but it's called GraphQL mesh. So GraphQL is great. GraphQL you can query what you want, GraphQL will get whatever it needs from your data sources and gets you back a predictable response. And one of the cool things about it is that the back end the resolvers, I know exactly in each resolver, we know what we're going to get from the parent resolver and what we need to return. So we can basically know those types and even generate typings for the inputs and the outputs of those resolvers.

But one thing that we sometimes forget is that, yeah, we have type safety over the network, what about all the data sources that we keep on query? Over there let's say in the resolver I'm calling the REST endpoints that I used to call before, I don't have types for it, so I have no idea what's coming and that can be a problem. So now that we have GraphQL on the front-end, what can we do to make the back-end even better and all the interactions we have with it? Should we use GraphQL everywhere? One solution would be to basically build small GraphQL endpoints into those services into those old back-ends and teach them GraphQL or Federation which can be nice but many times those are old servers like an old Java server or .NET server. It's not maintained or the people there won't get to learn GraphQL in the foreseeable future. There's also other problems but I don't have a lot of time to talk about it.

2. Using GraphQL Mesh to Merge Multiple Sources

Short description:

But what if we could take existing services, extract their schemas, convert them into GraphQL, and merge them into one endpoint? That's exactly what GraphQL Mesh does. It takes different sources, generates a fully typed GraphQL SDK, and merges them into a single GraphQL endpoint. With schema stitching, we can combine GraphQL with other sources like OData, gRPC, and GraphQL Federation. GraphQL Mesh solves the problem of type safety in resolvers and offers the ability to add federated metadata to existing services.

But what if... what do we really want right? Like what do we love about GraphQL that we want on the back-end? And that's probably the schema and the query language. So you know what can we do with it? So we thought about it and we thought well those back-ends they do sense something and they do sometimes have schemas even if it's not GraphQL. In the past we created a library called solfa that took a similar concept where we took an existing GraphQL server and we generated a complete REST and OpenAPI server endpoints out of it to serve for third parties or like other applications that don't know GraphQL. So we thought well maybe in order to solve those problems we can do the other way around. Maybe we can take those services, get their schemas whether if they have it defined like gRPC or OpenAPI or maybe we can just look at the logs of their responses and generate schemas from there, convert each one of those schemas into GraphQL, and then even merge them into one single GraphQL endpoint that basically we can query for all of our sources that we need when we're into our resolvers. And what we've done here is basically if we'll do that, we can take the best out of GraphQL using all the existing services we have today without needing to change them or touch them or them even knowing, being aware of what GraphQL is. And that's GraphQL mesh. So GraphQL mesh takes all those different sources, there's a lot of them, and generates a fully typed GraphQL SDK which you can run anywhere. So basically it takes all those sources and merge them into one. Let's see an example. So this is a simple example where we have two public APIs, one cities, which is a REST API with Swagger, and another weather, which also is a public Swagger API. So just by defining those two into our mesh config, we can start querying it as it was GraphQL. That's it. And those are just the existing endpoint, we have full documentation, GraphQL, anything. But that's not where we want to stop. We also want to merge them. So we can add a new field called daily forecasts on a city. And into those functions that we're connecting them both, this function is completely typed because we generate SDKs out of it. So now just by defining this field, we can start querying not only the city Tel Aviv, but also the forecast there. And what we've done here is basically schema stitching, not only on GraphQL but on any source, which is extremely powerful. We can do schema stitching between OData and gRPC. We can do schema stitching between GraphQL and GraphQL Federation. And there's many, many sources that were already created and there's more coming. So OpenAPI and Swagger, gRPC, so GraphQL Federation, Federated Services, and regular GraphQL, SQL and more. So just by trying to solve the problem of having full type safety over our resolvers, we basically solved a much bigger problem. Now, GraphQL Mesh has much more into it. Those merging that I showed you with stitching, which by the way we took over schema stitching, improved it and released new versions to make it undeprecated. But you can also use Federation into doing those stitching. And more than that, we have an opportunity, we have a way for you to take existing services and even Swagger services and add federated metadata into it, and then federate services that are not Federation at all.

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
Tom Pressenwurter introduces Redwood.js, a full stack app framework for building GraphQL APIs easily and maintainably. He demonstrates a Redwood.js application with a React-based front end and a Node.js API. Redwood.js offers a simplified folder structure and schema for organizing the application. It provides easy data manipulation and CRUD operations through GraphQL functions. Redwood.js allows for easy implementation of new queries and directives, including authentication and limiting access to data. It is a stable and production-ready framework that integrates well with other front-end technologies.
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
This Talk discusses handling local state in software development, particularly when dealing with asynchronous behavior and API requests. It explores the challenges of managing global state and the need for actions when handling server data. The Talk also highlights the issue of fetching data not in Vuex and the challenges of keeping data up-to-date in Vuex. It mentions alternative tools like Apollo Client and React Query for handling local state. The Talk concludes with a discussion on GitLab going public and the celebration that followed.
Batteries Included Reimagined - The Revival of GraphQL Yoga
GraphQL Galaxy 2021GraphQL Galaxy 2021
33 min
Batteries Included Reimagined - The Revival of GraphQL Yoga
Envelope is a powerful GraphQL plugin system that simplifies server development and allows for powerful plugin integration. It provides conformity for large corporations with multiple GraphQL servers and can be used with various frameworks. Envelope acts as the Babel of GraphQL, allowing the use of non-spec features. The Guild offers GraphQL Hive, a service similar to Apollo Studio, and encourages collaboration with other frameworks and languages.
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
The Talk discusses the challenges and advancements in using GraphQL and React together. It introduces RedwoodJS, a framework that simplifies frontend-backend integration and provides features like code generation, scaffolding, and authentication. The Talk demonstrates how to set up a Redwood project, generate layouts and models, and perform CRUD operations. Redwood automates many GraphQL parts and provides an easy way for developers to get started with GraphQL. It also highlights the benefits of Redwood and suggests checking out RedwoodJS.com for more information.
Adopting GraphQL in an Enterprise
GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
Adopting GraphQL in an Enterprise
Today's Talk is about adopting GraphQL in an enterprise. It discusses the challenges of using REST APIs and the benefits of GraphQL. The Talk explores different approaches to adopting GraphQL, including coexistence with REST APIs. It emphasizes the power of GraphQL and provides tips for successful adoption. Overall, the Talk highlights the advantages of GraphQL in terms of efficiency, collaboration, and control over APIs.
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
GraphQL has made a huge impact in the way we build client applications, websites, and mobile apps. Despite the dominance of resolvers, the GraphQL specification does not mandate their use. Introducing Graphast, a new project that compiles GraphQL operations into execution and output plans, providing advanced optimizations. In GraphFast, instead of resolvers, we have plan resolvers that deal with future data. Graphfast plan resolvers are short and efficient, supporting all features of modern GraphQL.

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
Build Modern Applications Using GraphQL and Javascript
Node Congress 2024Node Congress 2024
152 min
Build Modern Applications Using GraphQL and Javascript
Featured Workshop
Emanuel Scirlet
Miguel Henriques
2 authors
Come and learn how you can supercharge your modern and secure applications using GraphQL and Javascript. In this workshop we will build a GraphQL API and we will demonstrate the benefits of the query language for APIs and what use cases that are fit for it. Basic Javascript knowledge required.
End-To-End Type Safety with React, GraphQL & Prisma
React Advanced 2022React Advanced 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