GraphQL Mesh can gain new capabilities by using plugins.

  - some-plugin:# name of the plugin
    # ...pluginConfig can be found inside the dedicated documentation
PluginNPM PackageDocs
Live Queries@graphql-mesh/plugin-live-querydocs
Response Caching@graphql-mesh/plugin-response-cachedocs
Operation Field Permissions@graphql-mesh/plugin-operation-field-permissionsdocs
Rate Limit@graphql-mesh/plugin-rate-limitdocs
Caching in HTTP@graphql-mesh/plugin-http-cachedocs
HTTP Details in Extensions@graphql-mesh/plugin-http-details-extensionsdocs
Deduplicate HTTP Requests@graphql-mesh/deduplicate-requestdocs

Additional Plugins

Envelop is a library that helps build GraphQL API faster and flexibly with plugin-based architecture.

Similar to Express middlewares allowing you to customize requests’ behavior, Envelop applies the same idea to GraphQL requests.

By exposing hooks in all the phases of a GraphQL Request execution, Envelop enables the creation of plugins that simplify the setup of standard API features such as:

  • Security: Depth limits, Rate limiting
  • Authentication
  • Advanced caching
  • Error handling: Sentry, error masking
  • Monitoring: Hive
  • Logging
  • Tracing: NewRelic, Datadog, StatsD, Apollo Tracing

An Envelop plugin is a standalone npm package that provides a plugin function that can be used in an Envelop setup to customize a GraphQL API behavior.

Examples of plugins are:

  • useGenericAuth (@envelop/generic-auth): Custom authentication flow by providing a custom user resolver.
  • useDepthLimit (@envelop/depth-limit): Limit the depth of executed selection sets.

The GraphQL Mesh configuration accepts an additionalEnvelopPlugins parameter that should point to a file that exports a list of Envelop plugins, as shown below:

  # …
additionalEnvelopPlugins: './envelopPlugins'
import { useDepthLimit } from '@envelop/depth-limit'
import { useSentry } from '@envelop/sentry'
import { MeshPlugin } from '@graphql-mesh/types'
const plugins: MeshPlugin<any>[] = [
    maxDepth: 10
    includeRawResult: false
export default plugins

Note: The file can also export a factory function returning a PluginOrDisabledPlugin list

Mesh-specific Plugin Hooks

Mesh provides each plugin with unique hooks:

  • onFetch: triggered when fetch is called. Enables parameters manipulation, logging and even fetch function replacement.
  • onDelegate: triggered when a request is forwarded to the upstream (Either by context SDK or directly through the gateway).

These hooks have access to all remote execution parameters (root, args, context, info etc).

Example Mesh Envelop plugin therefore can look like this:

import { MeshPlugin, MeshPluginOptions } from '@graphql-mesh/types'
export default function customMeshPlugin(options: MeshPluginOptions<YourConfig>): MeshPlugin<any> {
  // Some other logic or config handling
  return {
    onFetch(payload) {
      // your logic with payload
    onDelegate(payload) {
      // your logic with payload

Usage of plugin and Native Envelop hooks are described in Envelop page Building Plugins