Links

Satsuma CLI

The Satsuma Querier CLI allows you to build, test and deploy custom queries. It provides several commands for initializing files, generating types, validating code, running a local server, and deployi

Quickstart

This should be in the directory of your subgraph. If you have multiple subgraphs, you'll want custom queries for each of them.
cd <your-subgraph-directory>
npx @satsuma/cli init # Initializes the necessary files for custom queries.
npx @satsuma/cli codegen --subgraph-name=<Subgraph-name> --version-name=<Subgraph Version Name> --deploy-key=<Deploy Key> # Generates types and schema.
npx @satsuma/cli local --subgraph-name=<Subgraph Name> --version-name=<Subgraph Version Name> --deploy-key=<Deploy Key> # Runs a local server.

Setup

To get started with the CLI, you can use npx to run the init command. This will initialize the necessary files for custom queries. Here's how you do it:
npx @satsuma/cli init
This command creates a custom-queries folder (or another folder specified by the user), and downloads and extracts files from the satsuma-custom-queries-skeleton repository.

Commands

codegen

To generate TypeScript types and GraphQL schema, use the codegen command:
npx @satsuma/cli codegen --subgraph-name=<Subgraph-name> --version-name=<Subgraph Version Name> --deploy-key=<Deploy Key>

validate

You can validate your custom queries by running the validate command:
npx @satsuma/cli validate --subgraph-name=<Subgraph Name> --version-name=<Subgraph Version Name> --deploy-key=<Deploy Key>

local

To run a local GraphQL server for development, use the local command:
npx @satsuma/cli local --subgraph-name=<Subgraph Name> --version-name=<Subgraph Version Name> --deploy-key=<Deploy Key>

deploy

When you're ready to deploy your custom queries, you can use the deploy command.
npx @satsuma/cli deploy --subgraph-name=<Subgraph Name> --version-name=<Subgraph Version Name> --deploy-key=<Deploy Key>