How to: Customize the Mesh server
GraphQL Mesh provides a reliable and production-ready server implementation built with GraphQL Yoga and Envelop with, out of the box support for:
- Persisted queries
- Live queries
- Files upload
- Serverless deployment
- and more...
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, 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 Serverplayground
(type:Boolean
) - Show GraphiQL PlaygroundsslCredentials
(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 bymesh serve
to open a playground window in development mode This feature can be disabled by passingfalse
One of:String
Boolean
playgroundTitle
(type:String
) - Title of GraphiQL PlaygroundtrustProxy
(type:String
) - Configure Express Proxy Handling Learn morebatchingLimit
(type:Int
) - Enable and define a limit for Request Batching
Provide a standalone server implementation
Creation of own server with Mesh Gateway and its deployment is described in Deploy a Mesh Gateway