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.

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.

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.

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.

Uri Goldshtein
Uri Goldshtein
15 min
02 Aug, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The speaker introduces GraphQL Mesh, a library that extracts schemas from existing services and merges them into a single GraphQL endpoint. This allows for type safety and the ability to add federated metadata to existing services. GraphQL Mesh can run as a central gateway or a distributed source. The speaker also mentions the use of platforms for streaming and the accessibility benefits of using semantic HTML content. Additionally, there is a mention of Ionic's support for native apps. Overall, the Talk covers the benefits and capabilities of GraphQL Mesh and its applications in different scenarios.

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
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.