snapshot plugin allows applying snapshot for development usage.
The snapshot plugin 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 also helpful because you can easily manipulate your data manually and see how your API mesh responds.
To get started with this plugin, install it:
yarn add @graphql-mesh/plugin-snapshot
Add the following configuration to your Mesh config file:
plugins: - snapshot: if: "process.env.NODE_ENV != 'production'" apply: - https://my-remote-api.com/* outputDir: __snapshots__
The following snapshot will work if you are in a development environment (see the
To modify your snapshots and change the responses, go to
__snapshots__ and modify the responses under those files.
You can check out our example that uses SOAP Handler with snapshot plugin.
if- - Expression for when to activate this extension. Value can be a valid JS expression string or a boolean One of:
Array of String, required) - HTTP URL pattern to be applied For example; apply:
- http://my-remote-api.com/* <- * will apply this extension to all paths of remote API
String, required) - Path to the directory of the generated snapshot files