graphcdn.yml

When you use the graphcdn CLI, you'll work with one configuration file, which is called graphcdn.yml. Below is an example graphcdn.yml file:

name: my-app
schema: https://end.point
originUrl: https://end.point
injectHeaders: false
headers:
  x-gcdn-password: my-password
bypassCacheHeaders:
    - name: x-preview-token
    - name: some-other-token
scopes:
  AUTHENTICATED: header:Authorization|cookie:session

rules:
  - description: Cache all queries
    maxAge: 900
    swr: 900
    scope: AUTHENTICATED
    types:
      Query: true

keyFields:
  types:
    <TYPE>:
      - id
      - <FIELD>

retries:
  networkErrors:
    isEnabled: true
    whenGraphQLResponse: false
  serverErrors:
    isEnabled: false

environments:
  staging:
    name: my-app-staging
    schema: https://staging.end.point
    originUrl: https://staging.end.point

Reference

name

The name of your service

schema

A reference to your schema. It can be one of the following:

  • A URL like http://localhost:3000/graphql (only works if introspection is enabled)
  • A reference to a local schema.graphql file like ./api/schema.graphql
  • A reference to an SDL definition in your code like ./api/typeDefs.ts

originUrl

The URL of your production backend you want your service to proxy to.

injectHeaders

Should your GraphCDN service inject the headers you provided into the edge? This might be required if you have some default headers that are always needed. Use this with care though, as you might expose unwanted auth data with this.

headers

A key-value map of headers and their values.

bypassCacheHeaders

A list of headers to include if you want to bypass GraphCDNs cache and always query your backend service. Including any one of those headers will trigger a cache pass.

rules

The core of GraphCDN - the cache configuration. Read more about this in the cache configuration documentation.

keyFields

A list of all types and their respective key fields. Types will only show up in that list if their key fields have been modified from the default id or key.

scopes

A key-value map of custom cache scopes to scope cached data per user. See the documentation on Scopes for more information on setting up scopes.

retries

Defining when GraphCDN should automatically retry requests to your origin server. See the Retries documentation for more information on configuring retries.

environments

A key-value map of environments to push to, e.g. "staging". See the environments documentation for more information.


Did this page help you?