2 minutes
Testing and Staging a Subgraph
Before you publish a Subgraph to The Graph Network, check that it indexes without errors and returns the data you expect. Publishing is an onchain transaction, and each new version costs gas, so it pays to catch problems first.
You can use any combination of the options below. None of them is required to publish.
Unit Tests
Matchstick runs unit tests against your mapping handlers, with mocked events and contract calls, in seconds and with no Graph Node. Use it to test handler logic and edge cases as you write them.
Run Your Subgraph Locally
Graph Node Dev Mode (gnd) runs your Subgraph on your own machine against an RPC endpoint, and redeploys it each time you rebuild. You query it at a local endpoint, check its logs, and iterate without deploying anywhere.
Debug a Failing Subgraph with Forking
If a Subgraph fails at a block deep in its history, Subgraph forking lets you reproduce and fix the failure locally, without syncing to that block first.
Use a Provider’s Staging Environment
Some providers index a Subgraph that you deploy to them before it is published, and give you a development endpoint to test it in your application. What each one offers differs, so check the provider’s own docs.
-
Subgraph Studio, operated by The Graph Foundation: deploy a version with
graph deploy, test it in the playground, check its indexing logs, and query it at a development query URL. See Subgraph Studio. Subgraph Studio indexes deployed versions with the Upgrade Indexer, which supports only some networks. Supported Networks shows which ones. On a network it doesn’t support, a deployment doesn’t sync in Studio, so the playground and development query URL return no data. Test the Subgraph locally with Graph Node Dev Mode instead, then publish it to The Graph Network and add curation signal so Indexers pick it up. -
Other providers: see Subgraph Gateway Providers for the Gateway Operators that serve The Graph Network and links to their docs.
Check Your Subgraph Before Publishing
Whichever option you use, check that:
- The Subgraph syncs to the chain head with no indexing errors.
- Queries return the entities you expect, from the start block onward.
- The
startBlockin your manifest is the block your contract was deployed in. - The Subgraph indexes a supported network, and uses only features that Indexers support.
When you are ready, publish your Subgraph.