Stellate Configuration File (stellate.ts
)
To configure your Stellate service, you’ll work with a configuration file that is called stellate.<ts|js|mjs>
.
It’s the central file to configure your service. From caching, over origin url to rate limiting (coming soon), this is the place to adjust your service.
To read more about rate limiting and how to configure that, check out the rate limiting api reference.
- Name
schema
- Type
- Description
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
- A URL like
- Name
queryDepthLimit
- Type
- Description
An integer that indicates how deeply nested a query can be. A value of
0
disables the limit and is the default if the property is not provided. See Depth Limiting for more information.
- Name
mutationPolicy
- Type
- Description
Defining how Stellate automatically purges cached queries. See the mutation-policies documentation for more information on configuring mutation-policies.
- Name
bypassCacheHeaders
- Type
- Description
A list of headers to include if you want to bypass Stellate Edge Cache and always query your backend service. Including any one of those headers will trigger a cache pass.
- Name
rules
- Type
- Description
The core of the Stellate Edge Cache configuration. Read more about this in the Cache Rules documentation.
- Name
scopes
- Type
- Description
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.
- Name
retries
- Type
- Description
Defining when Stellate should automatically retry requests to your origin server. See the Retries documentation for more information on configuring retries.
- Name
environments
- Type
- Description
A key-value map of environments to push to, e.g. “staging”. See the Environments documentation for more information.
- Name
ignoreOriginCacheControl
- Type
- Description
Whether to ignore the origin
Cache-Control
response header or not. (default:true
) If this is set tofalse
, Stellate’s GraphQL Edge Cache will cache query results based on the responseCache-Control
header.This setting will be ignored and default to
true
in case you have Partial Query Caching enabled. For PQC to properly work,Cache-Control
headers set by your origin can’t be taken into account.
- Name
schemaView
( beta)- Type
- Description
Following commands will apply the
schemaView
configuration:Note: As this feature is still in beta:
- Queries will not be validated
- Schema will only be applied via the CLI commands mentioned above
The
schemaView
property is used to configure a subset of a GraphQL schema that should be exposed to clients. The property accepts an object with two properties:include
andexclude
.The
include
property accepts an array of strings that specifies the GraphQL types that should be included in the subset. If left empty, then all types will be included by default.The
exclude
property is also array of strings that specifies the GraphQL types that should be excluded from the subset. If exclude is left empty, no types will be excluded from the schema.The rules for schema views are inspired by Hive Contracts and follow the same rule set outlined in their documentation. The rules are based on the Federation v1 standard.
For more information see
subset
in the CLI documentation.
- Name
customAttributes
- Type
- Description
A map that defines Custom Attributes which are extracted for each request and made available in our GraphQL Metrics.
import { Config } from 'stellate'
const config: Config = {
config: {
name: 'my-app',
schema: 'https://end.point',
originUrl: 'https://end.point',
passThroughOnly: false,
queryDepthLimit: 0,
injectHeaders: false,
mutationPolicy: 'Entity',
graphiql: { enabled: false },
headers: {
'x-gcdn-password': 'my-password',
},
bypassCacheHeaders: [{ name: 'x-preview-token' }],
scopes: {
AUTHENTICATED: 'header:authorization|cookie:session',
},
nonCacheable: ['User'],
rules: [
{
description: 'cache all queries',
maxage: 900,
swr: 900,
scope: 'AUTHENTICATED',
types: ['Query'],
},
],
keyfields: {
types: {
['<type>']: ['id', '<field>'],
},
},
retries: {
networkerrors: {
isenabled: true,
whengraphqlresponse: false,
},
servererrors: {
isenabled: false,
},
},
ignoreOriginCacheControl: true,
customAttributes: {
userId: { header: 'x-user-id' },
},
removeCookies: [
'_cfuvid',
'__cf*'
],
environments: {
staging: {
name: 'my-app-staging',
schema: 'https://staging.end.point',
originurl: 'https://staging.end.point',
},
},
},
schemaView: {
include: [],
exclude: ['private'],
},
}
export default config