The router is a stateless component, allowing it to be scaled horizontally without requiring persistence. However, it needs to fetch the execution configuration from a storage source at startup and when new schema updates are published. This execution config provides the instructions for executing and planning GraphQL operations. The same approach applies to persisted operations (PO), which manage an allowlist of permitted GraphQL operations that can execute against the router. The router must download these operations once before they can be executed. For both mechanisms, different storage providers can be used:Documentation Index
Fetch the complete documentation index at: https://wundergraphinc-milinda-eng-8701-implement-cache-warmer-from.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
- CDN: The default provider used by Cosmo Cloud.
- Amazon S3: An object storage protocol. We support any S3 compatible object-storage e.g. Minio and AWS.
By removing the dependency on Cosmo Cloud, your router no longer relies on us for operations while still benefiting from all its features.
Define a provider
Before you can use a storage provider, you have to define it in thestorage_providers section of your config.yaml file.
secure has to be set to
true when you point to an S3 that uses https://node IAM roles you don’t need to provide an access_key or secret_key and the S3 client will handle this on your behalf.
Execution config
After configuring the storage provider, you can use it by referencing it in theprovider_id field.
object_path field points to the file in your bucket that is updated after each schema deployment in your CI/CD pipeline. The following snippet illustrates how it could look like:
Fallback storage
You can configure a fallback storage for fetching the execution config in the event the router cannot reach the primary storage. If enabled, it will default to using the Cosmo CDN but you can specify the provider as well. You cannot use the same provider for both primary and fallback storage.Best Practices
- Create different S3 credentials for READ and WRITE to reduce the attack surface.
Persisted Operations
After configuring the storage provider, you can use it by referencing it in theprovider_id field.
object_prefix field points to the location in the bucket where the persisted operations are uploaded. Each persisted operation needs to follow the naming convention: SHA256 of the file + .json as filename extension. A persisted operation is a JSON document and must follow the following structure:
-
version: The version of the persisted operation format. -
body: The actual content of the persistent operation.
Example
Given the following persisted operation:Best Practices
- We can cache persisted operations effectively only by using an immutable filename, such as the SHA-256 hash of the file.