The Guild LogoThe Guild Monogram

Search docs

Search icon

Products by The Guild

Products

Hive logoHive blurred logo

Hive

Schema Registry for your GraphQL Workflows

Skip to main content

Mesh as Gateway

Apollo Federation

You can use GraphQL Mesh as an HTTP gateway proxy for your data sources. GraphQL Mesh provides you an HTTP server with Express, GraphQL Helix, GraphQL-WS and GraphiQL Explorer with a bunch of configurable features out-of-box.

There are two commands for GraphQL Mesh's HTTP Server;

  • dev commands generates the unified schema without using any existing artifacts on the disk and it introspects all the schemas but it doesn't save it.
  • start commands generates the unified schema by using the existing artifacts previously created by mesh build command. Learn more about Mesh artifacts..

You can also point to a specific directory which contains the source files (.meshrc.yaml, etc.)

mesh dev --dir some/path/to-configuration/

GraphQL Mesh's HTTP Server can be configured using serve command like below;

serve:
port: 5000

  • fork - - Spawn multiple server instances as node clusters (default: 1) One of:
    • Int
    • Boolean
  • port - - TCP Port to listen (default: 3000) 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)
  • handlers - - Express/Connect compatible handlers and middlewares extend GraphQL Mesh HTTP Server Array of:
    • object:
      • path (type: String, required) - Path that remote API will ping
      • method (type: String (GET | POST | DELETE | PATCH)) - HTTP Method that the handler will control
      • pubsubTopic (type: String, required) - Name of the topic you want to pass incoming payload
      • payload (type: String) - Part of the object you want to pass (e.g. data.messages)
    • object:
      • path (type: String, required) - Path that the handler will control
      • handler (type: String, required) - Path of the handler's code
      • method (type: String (GET | POST | DELETE | PATCH)) - HTTP Method that the handler will control
  • staticFiles (type: String) - Path to your static files you want to be served with GraphQL Mesh HTTP Server
  • playground (type: Boolean) - Show GraphiQL Playground
  • maxRequestBodySize - - Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the bytes library for parsing. Defaults to '100kb'. One of:
    • Int
    • String
  • upload (type: Object) - Configuration for GraphQL File Upload:
    • maxFileSize (type: Int) - Maximum File Size for GraphQL Upload (default: 100000000)
    • maxFiles (type: Int) - Maximum number of files for GraphQL Upload (default: 10)
  • 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 disable by passing false One of:
    • String
    • Boolean
  • customServerHandler (type: String) - If you want to use a custom GraphQL server, you can pass the path of the code file that exports a custom Mesh Server Handler With a custom server handler, you won't be able to use the features of GraphQL Mesh HTTP Server