Skip to main content

Mesh as Gateway

Apollo Federation

You can use GraphQL Mesh as a gateway for your data sources. CLI's serve command creates a GraphQL Endpoint with GraphQL Playground.

mesh serve

You can configure serve command like below in .meshrc.yml;

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)
  • exampleQuery (type: String) - Provide an example query or queries for GraphQL Playground The value can be the file path, glob expression for the file paths or the SDL. (.js, .jsx, .graphql, .gql, .ts and .tsx files are supported. But TypeScript support is only available if ts-node is installed and ts-node/register is added under require parameter)
  • 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
      • 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