Getting Started
Customize the Mesh Server

How to: Customize the Mesh server

GraphQL Mesh provides a reliable and production-ready server implementation built with GraphQL Yoga (opens in a new tab) and Envelop (opens in a new tab) with, out of the box support for:

Customizing your GraphQL Mesh Gateway server can be achieved in 2 ways:

  • Configure and provide Envelop plugins: to add behaviors such as caching, authentication, tracing to your Gateway
  • Provide a standalone server implementation: to completely replace the server used by the Gateway

Configure and provide plugins

Aided by the capabilities of Envelop (opens in a new tab), you can easily add plugins that helps with security and authentication, advanced caching, error handling, monitoring, logging and much more.

For full list of available plugins, please refer to the plugins section.

Configuration: serve reference

  • fork - - Spawn multiple server instances as node clusters (default: 1) One of:
    • Int
    • Boolean
  • port - - TCP Port to listen (default: 4000) One of:
    • Int
    • String
  • hostname (type: String) - The binding hostname (default: localhost)
  • cors (type: Object) - Configuration for CORS:
    • origin (type: Any)
    • allowedHeaders (type: Array of String)
    • exposedHeaders (type: Array of String)
    • credentials (type: Boolean)
    • maxAge (type: Int)
    • preflightContinue (type: Boolean)
    • optionsSuccessStatus (type: Int)
  • staticFiles (type: String) - Path to your static files you want to be served with GraphQL Mesh HTTP Server
  • playground (type: Boolean) - Show GraphiQL Playground
  • sslCredentials (type: Object) - SSL Credentials for HTTPS Server If this is provided, Mesh will be served via HTTPS:
    • key (type: String, required)
    • cert (type: String, required)
  • endpoint (type: String) - Path to GraphQL Endpoint (default: /graphql)
  • browser - - Path to the browser that will be used by mesh serve to open a playground window in development mode This feature can be disabled by passing false One of:
    • String
    • Boolean
  • playgroundTitle (type: String) - Title of GraphiQL Playground
  • trustProxy (type: String) - Configure Express Proxy Handling Learn more (opens in a new tab)
  • batchingLimit (type: Int) - Enable and define a limit for Request Batching (opens in a new tab)

Provide a standalone server implementation

Creation of own server with Mesh Gateway and its deployment is described in Deploy a Mesh Gateway