GraphQL Everywhere: Use Hasura + GraphQL Mesh to create the ultimate data graph - Uri Goldshtein @HasuraCon'20
Tags: hasuracon
Published: 2021-05-05 14:50:57

---
title: GraphQL Everywhere: Use Hasura + GraphQL Mesh to create the ultimate data graph - Uri Goldshtein @HasuraCon'20
published: true
date: 2021-05-05 13:51:05 UTC
tags: HasuraCon
canonical_url: https://hasura.io/blog/graphql-everywhere-use-hasura-graphql-mesh-to-create-the-ultimate-data-graph-uri-goldshtein/
---

 ![GraphQL Everywhere: Use Hasura + GraphQL Mesh to create the ultimate data graph - Uri Goldshtein @HasuraCon'20](https://hasura.io/blog/content/images/2021/05/uri.png)

_[Uri Goldshtein](https://twitter.com/UriGoldshtein) spoke last year at HasuraCon'20 on how one can use Hasura's remote joins feature and GraphQL Mesh to create data graphs._

_As HasuraCon'21 is almost here, we thought it would be the perfect time to take a look back on all the amazing talks by our amazing speakers from 2020!_

_[You can sign up for HasuraCon'21 here!](https://hasura.io/events/hasura-con-2021/)_

_Here's Uri's talk in video form:_

{% youtube 8Jr3tSTf5-E %}<figcaption>GraphQL Everywhere: Use Hasura + GraphQL Mesh to create the ultimate data graph - Uri Goldshtein</figcaption>

_And below is a text transcription of the talk for those who prefer reading! (The text is slightly paraphrased and edited here and there for clarity's sake.)_

**TRANSCRIPTION:**

Hi, everyone. My name is Uri. And I'm here to talk with you about Hasura and GraphQL Mesh, and all the new capabilities that you can now do with Hasura's new remote joins and with GraphQL Mesh.

**A bit about me, The Guild, and what we do**

I'm the founder of a group called The Guild. We do a lot of open source work in the community, mostly around GraphQL. Some of our libraries you may have heard of are:

1. GraphQL Code Generator - where you can generate types for your back end and your front end
2. GraphQL Inspector - which basically prevents breaking when changes are made, and every time you go into production, you can make sure your API is valid
3. GraphQL CLI
4. GraphQL Modules - you probably heard about GraphQL modules if you want to work in separate teams, and each team has its own responsibilities on the graph.
5. And also recently, we took over a library, the GraphQL tools library, which is a very famous library that a lot of the people in the community are dependent on. It wasn't so well maintained. We took it over, rebuilt it, added tons of features into it, and also revealed schema stitching. So now schema stitching is way better than it was before, it's no longer deprecated. If you’ve seen it before, really check it out again. 

We have a lot of libraries that we’ve built for the community. We wanted to start a new group that can basically create sustainable, open-source that you can count on for many years to come. And you can use those libraries individually or you can just pull them together into one coherent platform.

**How Hasura fits into Enterprise Environments**

Today, I'm going to talk about how Hasura fits into the whole picture. So Hasura, as we all know here, and we don't need to explain is an amazing, amazing tool. For me, the best thing about Hasura is that you can build super-fast apps, and you can build them super quickly. But you can also do that in any environment. It's an open-source solution that runs on existing databases.

So what we’ve seen is that all of a sudden, these types of apps are being built inside enterprise companies, which are the companies that we mostly work with - we want to work with large companies that have a lot of existing code and a lot of existing infrastructure. Seeing applications like the applications that Hasura helps you create in those companies is amazing to us.

Now, what we see is that once you start with Hasura, obviously you're gonna experience success pretty quickly inside those organizations. And then when you have success inside those organizations, very quickly, people want to get to be a part of it. And very quickly, you get more and more features, and you need to start integrating with other existing systems. And that might be hard because those existing systems might not be as flexible as Hasura is.

**Hasura's Remote Joins**

And, one of the most powerful and exciting things about Hasura, and why we are so excited about it, is remote joins. Remote joins are just is an amazing ability because we can take this very fast-paced application that we built with Hasura and start integrating other sources into that system. I think that's an extremely powerful concept. But the question is, how do we go about doing the transition?

So if we look at Hasura as our thing that communicates with our current app and our client, we now need to start integrating it with other servers, and maybe third-party APIs and things like that. Now, maybe we can start converting them. The thing is, with remote joins is that Hasura expects a GraphQL API to be integrated into. So in order to integrate with other sources, we might want to maybe, start converting all the sources that we want to merge into GraphQL. Or maybe you know, if that's not possible, we want to build small gateways in front of those services.

Now, that sounds good, but in reality, a lot of those services, won't migrate to GraphQL. In reality, they have enough work as it is, they're not going to convert to and learn a new protocol. Maybe those are legacy services that nobody's touching anymore. So, doing this is in large organizations is sometimes not practical.

But we saw the success of Hasura and GraphQL inside those organizations, and we wanted it to continue. So we thought, well, maybe we can do something interesting. Since those services are working, they do have schemas, at least some of them have schemas. Let's say they have a GRPC or open API or swagger schema, or maybe a soap schema. But some of them may use REST without using rest without any schema, there's just information there on the logs that we can extract and understand what's going on.

So what we thought is, maybe you can use all that information, maybe a schema, our data, or whatever we have, and convert this information into a GraphQL schema. And maybe even take older schemas and convert them into one GraphQL source and then we can integrate it with Hasura with remote joins. So that's GraphQL Mesh.

**GraphQL Mesh**

GraphQL Mesh basically takes any source and you can give it any information - it can be open API, GRPC, maybe even queue systems, or if you have an event system, or RabbitMQ, or Kafka or whatever, it can integrate with those as well. And then it generates an executable GraphQL. And the sources can be any source - open API and swagger, GRPC - we have handlers for all those technologies.

When it comes to old data, we actually took the whole Microsoft graph, which is an old database, and converted the whole graph into GraphQL. They had their own project, trying to do it manually, and couldn't succeed. And we did it automatically. Now, once GraphQL Mesh gets that information and converts it, it can be run as a gateway, or it can be run as an SDK on your existing services.

So there's full flexibility of how you can run it and where you want to run it and how you want to use that graph. For example, one person in the community took - basically, if you google GraphQL Mesh Docker, he basically built the library where you can just input it, this swag, the YAML config file for Mesh, and then you just get the gateway running that exposes GraphQL. And again, we built Mesh to be completely flexible. So, every step of the way is customizable, and you can do transformations on any step. That's why it’s extremely flexible and can support so many use cases.

Now, not only did we understand, like what can happen, but actually, the community understood as well. And we started seeing people in the community actually taking GraphQL Mesh, and then converting all the existing APIs that head in their organization, and then merging it with their existing Hasura applications. So that's very, very powerful.

**GraphQL Mesh Demo**

And that's what I want to show you right now. So I created a video, you know, forgive me that I'm not live-coding, but I'm going to explain it a bit. What you see here is an existing Hasura database that has basically series API - series information. We can query a city and its name. Now let's go ahead and create our Mesh application. We're just creating it here. And just yarn in it an application. I'm doing it from scratch here, there is nothing in that library.

Now what we're going to do is we're going to install Mesh. And you'll see that everything I'm doing here basically, you could also have done with just a Docker now, what we want to integrate with is breweries and breweries API. So I wanted an example where we have an API that is out of our control. And it doesn't have a schema. You can watch other talks of mine, and there are also examples on the repo where we show how to just generate everything for Mesh from schemas.

But in many, many cases, in a real enterprise, they don't have schemas or the schemas are completely outdated or things like that. So what I'm gonna do here is, I'm gonna just take an example response and then there's an example Input and Output basically of that API and GraphQL Mesh will take that information, generate a JSON schema out of it, and then generate a GraphQL API off of it. So let's see how it goes. I'm just going to paste this here. And I'm also going to paste an example, the example input.

And again, you can do that just by looking at your logs or bring in whatever you want here. Now let's create our actual Mesh YAML file. I can tell Mesh, what my sources are, and I can name them. In this case, we'll just call it “open brewery” or something like that. And then let's look at the config. So we have many different handlers. In that case, we brought in the JSON schema handler, we told it where the base URL is, and then for the operations, we actually just told it. And in order to get the schema, we basically just told it where to search. And again, you can just bring in your own logging information, or whatever, and generate that yourself from existing services.

And now, just by doing that, let's start Mesh. Let's create the script, let's run yarn start, Mesh serve, and what you're going to see now is that I’ve basically got a fully working GraphQL API. Now, I didn't write any code in here, you see, I have all the docs as if it was a GraphQL service. But it's not. It's a regular REST service that didn't have a schema either. So now I can have the autocomplete and all the amazing experience even on the input, they have autocomplete on the parameters. And I can query for whatever I want I get a fully typesafe interface. You can see that it works. But again, this is from an API that I have no control of.

Now, once that’s done, we can actually join that API into Hasura. So let's just go to remote joins, and paste the URL of my new Mesh instance. So now we can query not only the city through the API as we had before, but we can also query the breweries. But what we really want is we want to get the breweries inside a city. So let's use the powerful remote joins of Hasura for it.

Now in “city”, we can integrate and declare a relationship with the brewery. And we're going to take it from the remote schema. And we're going to, you know, use it by the input of a city like we saw before. And now, if we go back, what we can see is that now we can actually query the breweries in a city. And again, we are using here our own Hasura data, together with an API that doesn't have any schema. And we have no control of it and it’s not GraphQL at all. So that's a very short example.

This example, by the way, exists on our graph on our GitHub repository, you can find it there together with other examples. And just go ahead and try it out. Now, let's go back to the presentation. So now you saw how powerful this combination is with Hasura remote joints and GraphQL Mesh. Now, the thing is, we can take it a step further: we can start actually implementing, and exposing those modules, those Mesh modules into any API, like on our website.

As I said, we have the Microsoft API, we have Stripe, we have all kinds of APIs that are not GraphQL at all, but now you can just take them as GraphQL. And you can create your own integrations and include those integrations into Hasura. And we can start creating a lot of existing integrations and with any API you can think of, and you can share those integrations inside your company, or, you know, with the whole world and basically create a huge graph of all the sources we can think of.

**Thanks!**

So, I hope that was interesting for you. You can follow us, you can go to the website, GraphQLMesh.com. You can follow us on our Twitter. And you can join our community. I think you know, our community and the Hasura community, we're always been very close and we are very close. We love everything Hasura does and we want to come up with more things that we can help everyone at Hasura. So thanks for having me and I hope to hear from you online. Thank you!