How to use GraphCDN in Development

Since the release of version 1.3.0 of the GraphCDN CLI , you can proxy requests to your local development GraphQL backend via GraphCDN. This allows you to test the behavior of your app with GraphCDN enabled, as well as your GraphCDN configuration.

To give this a try you'll need to have an account with GraphCDN. If you're new, please sign up first and then run graphcdn login to sign in to your account.

Next, you'll either need to pull your graphcdn.yml configuration (via the graphcdn pull command) or create a scaffolding configuration that looks like this:

# Skeleton graphcdn.yml
name: local-dev
app: local-dev
schema: http://graphql.local
originUrl: http://graphql.local

Also, make sure your development GraphQL server is up and running and accepting requests.

Once you're ready, you can create the development environment via the following command:

graphcdn serve --backend-port <port> --service <service name>

As service name use the same value provided in your graphcdn.yml file. In the example configuration above we'd use local-dev as the service name.

The serve command supports the following options:

  • --backend-port, the port on your local host your GraphQL server is running on
  • --service, the name of the service if not specified in the graphcdn.yml file
  • --serve-port, the port you want to have the GraphCDN environment available on, defaults to the first free port greater than 3000 (Optional)
  • --watch, whether to watch the graphcdn.yml file for changes.
  • --path, the path your GraphQL API is available on, e.g. /graphql

This will make debugging your GraphCDN setups, as well as giving GraphCDN a try, a lot easier.


Did this page help you?