Overview

GraphQL Mesh v0 documentation (superseded by v1): GraphQL Mesh allows you to create a unified GraphQL schema from multiple sources, using handlers and transforms. Configure sources, handlers, and transforms in a .mesh.yaml file to build your first gateway.

Working with Mesh means dealing with 4 main concepts: Sources, Handlers, Transforms and Unified Schema:

  1. In Mesh, a sub-service (GraphQL API, REST API) is called a Source.
  2. Sources are translated to GraphQL Schemas with the appropriate Handler.
  3. All Sources’ GraphQL Schema are merged into a final Unified Schema.
  4. Finally, if applicable, configured transformations, called Transforms, are applied to the Unified Schema.

Services

GraphQL Mesh server

Weather REST API

Population GraphQL API

City REST API

Configured sources

Weather Source

Population Source

City Source

merged in

merged in

merged in

translated to GraphQL Schemas by handler

translated to GraphQL Schemas by handler

translated to GraphQL Schemas by handler

Unified Schema

City Source GraphQL Schema

Population GraphQL Schema

Weather GraphQL Schema

Swagger definition file

GraphQL Schema

RAML definition file

The above GraphQL Mesh Gateway has 3 configured Sources:

  1. The “City” Source configured with the @graphql-mesh/openapi Handler.
  2. The “Population” Source configured with the @graphql-mesh/graphql Handler.
  3. The “Weather” Source configured with the @graphql-mesh/raml Handler.

Sources, Handlers, Transforms are configured in a .mesh.yaml (or .json, .js, .ts) configuration file that defines:

  • How to fetch the definition of the sub-services (GraphQL API, REST API, and more)
  • What transformations should be applied to the unified schema (optional)
  • The path to the declaration of custom resolvers (optional)
  • Which cache strategy should be used? (optional)
  • Which envelop plugins should be loaded and configured at the server level? (optional)

Let’s have a closer look to a .mesh.yaml configuration file by installing Mesh and building our first Gateway!