The Guild LogoThe Guild Monogram

Search docs

Search icon

Products by The Guild


Hive logoHive blurred logo


Schema Registry for your GraphQL Workflows

Skip to main content

Snapshot Transform

The snapshot transform allow you to apply snapshot for development usage.

The snapshot transform writes the responses of your remote data source to your file-system and then uses it instead of re-fetching it every time. It's alse useful because you can easily manipulate your data manually, and see how your API mesh responds to it.

To get started with this transform, install it from npm:

yarn add @graphql-mesh/transform-snapshot

How to use?#

Add the following configuration to your Mesh config file:

- snapshot:
if: "process.env.NODE_ENV != 'production'"
- Query.*
outputDir: __snapshots__

The following snapshot will work if you are in development environment (see the if command).

To modify your snapshots and change the responses, go to __snapshots__ and modify the responses under those files.

Codesandbox Example#

You can check out our example that uses SOAP Handler with snapshot transform.

Config API Reference#

  • if - - Expression for when to activate this extension. Value can be a valid JS expression string or a boolean One of:
    • String
    • Boolean
  • apply (type: Array of String, required) - Resolver to be applied For example; apply:
    - Query.* <- * will apply this extension to all fields of Query type
    - Mutation.someMutationButProbablyYouWontNeedIt
  • outputDir (type: String, required) - Path to the directory of the generated snapshot files
  • respectSelectionSet (type: Boolean) - Take snapshots by respecting the requested selection set. This might be needed for the handlers like Postgraphile or OData that rely on the incoming GraphQL operation.