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.

15 min
02 Aug, 2021

AI Generated Video Summary

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.

3. GraphQL Mesh and Distributed Data

Short description:

And there's many more things. We can mock each one of those sources, we can snapshot prefix, do any transformation we want, it's all pluggable. Mesh is not a central gateway; it can run as a central gateway or a distributed source. By creating a weather API using GraphQL and exposing existing APIs as public mesh modules, we can connect data without a central place. Visit graphicalmesh.com to join the Guild community for more discussions and progress.

And there's many more things. We can mock each one of those sources, we can snapshot prefix, do any transformation we want, it's all pluggable. And the most exciting thing about Mesh is that it's not a central gateway. It can run as a central gateway, but you can basically generate the SDK and run it anywhere on each of your services. So it's completely distributed. It can be like one central place or a distributed source.

And if we take this idea one step further, we can actually start taking those codes that I showed you in the example. And you can start creating a weather API using GraphQL. You can take your own existing bank API and expose this as a public mesh module exposing GraphQL without the bank even knowing what GraphQL is. And now, suddenly, you can even expose the merging strategy of those. So now that your bank has a public GraphQL API that also shows the weather in each of those branches, and the bank didn't do anything, you have, the community did.

And if we take this one step further, that basically means that now we can start having public mesh modules that run anywhere and are completely distributed. So we can have, and they're fully open source, the community is owning it, the registry can be any registry, NPM, GitHub, whatever. And we can really, that can take us closer to the Web 3.0 semantic web. We can all start exposing data that is connected to each other without putting it all in a central place. So if that's interesting for you, then go to graphicalmesh.com and join the Guild community. We have discussions about it all the time and we're moving forward very fast. Thank you very much.

Well, that's a lot of knowledge in just 20 or 28 minutes it was. Four great topics. I would like to invite all the Lightning Talk speakers with me on the stage to do the last round of Q&A of the day. Hey, everyone. Hello. Hey, there. Hey. Good morning, evening, night, whatever it is for you. Yeah, I'm going to go straight into the questions. I'm going to start with the first question for Matt and Claire. What market are you targeting and why would someone use Mox instead of Twitch or YouTube? Yeah, it's a valid question. We're a developer-facing product, so we're purely just APIs for developers to build into their platform, as opposed to Twitch and YouTube, which are much more consumer-facing products.

4. Platforms and Div Buttons

Short description:

If you're a streamer, use platforms that allow you to go live without coding. If you're building a platform, we're a better fit. React Native web team may use a div as a button to wrap non-semantic HTML content and make it accessible. Jen kindly taps on the shoulder and suggests using an accessible div. Martin van Houten compliments Mash and shares positive experiences. The company Albert Hein uses Mash.

So if you're a streamer just looking to go live without writing any code whatsoever, those are great platforms you should probably use them. If you're trying to build a platform, we're probably a better fit there.

OK, so it's more about the target audience, I guess, and that you have more control over what you're doing. Yeah, I would think about it a little bit like a bad analogy that I mentioned at Slack is they're more like the PayPal or Venmo. We're more of the Stripe, if you're thinking about it in terms of payment APIs.

OK, thank you. Next question is for Jen. What are the reasons why someone like the React Native web team would want to use a div as a button? The reason is that putting HTML inside of a button is not actually semantic HTML. So they may want to wrap that content, for instance, a card or a block of an image and text into a div and make that an accessible button instead of putting a button around it.

Yeah, so if you have a completely clickable card with different elements inside it, you can't do that semantically within a button. Correct. So in that case, you'll want to make an accessible div. Well, you should want to at least. Perhaps. And can I say, if you don't, Jen is going to come and get you? I will very kindly tap you on the shoulder and make suggestions. How about that? Yes. Yeah, but tap doesn't work. Then I might hack it. Yeah, yeah.

Not a question, but just for your a nice tap on the shoulder from Martin van Houten, not really a question. Just want to say, Mash looks awesome. Well, that's always nice to hear. Thank you. Thank you very much. Thank you. And I hope that after you try it, you'll feel the same and not hate me. Well, actually at the company I work for, Albert Hein, we are using it. And I have to say it's been a pleasure. So thanks a lot. Oh, you're my neighbor.

5. Visiting and Ionic Support

Short description:

I can come visit you. Yeah, that would be a gezellig. Mike, does Ionic support native apps similar to React Native? It's a mix of both. The majority of the UI is displayed in a web view, but you can integrate it with custom native views or activities on Android. That feels powerful. Thanks, guys and my lady for these great talks. The formal part is now over. Bye-bye.

I can come visit you. Yeah, that would be a gezellig.

Mike, does Ionic support native apps similar to React Native? Or is it like a Cordova standard app where it's a web UI instead of a native app? So it's kind of a mix of both. The majority of the UI is displayed in a web view, but you can integrate it with custom native views or activities on Android and kind of mix which one gets displayed. You got the web view or the native view, or even just overlay the native view on top of the web view. So you get kind of the best of both worlds. That feels powerful.

OK, thanks. Thanks, guys and my lady for these great talks. For the people watching, they are also going to be in the Zoom rooms for questions, but the formal part is now over. I'm going to say goodbye to you for a little bit. So thanks for joining. Thank you Thank you. Bye-bye. Bye.

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

GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
From GraphQL Zero to GraphQL Hero with RedwoodJS
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!
Vue.js London Live 2021Vue.js London Live 2021
24 min
Local State and Server Cache: Finding a Balance
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.
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'.
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

GraphQL Galaxy 2021GraphQL Galaxy 2021
140 min
Build with SvelteKit and GraphQL
Featured WorkshopFree
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
React Advanced Conference 2022React Advanced Conference 2022
95 min
End-To-End Type Safety with React, GraphQL & Prisma
Featured WorkshopFree
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 Galaxy 2022GraphQL Galaxy 2022
112 min
GraphQL for React Developers
Featured Workshop
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.
React Summit 2022React Summit 2022
173 min
Build a Headless WordPress App with Next.js and WPGraphQL
WorkshopFree
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.
GraphQL Galaxy 2020GraphQL Galaxy 2020
106 min
Relational Database Modeling for GraphQL
WorkshopFree
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
GraphQL Galaxy 2021GraphQL Galaxy 2021
48 min
Building GraphQL APIs on top of Ethereum with The Graph
WorkshopFree
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.