Subgraph-entity sources are a legacy Mirror feature; Turbo pipelines don’t support them yet. For the single-subgraph version of this flow, see sync a subgraph to Postgres.
What you’ll need
-
One or more subgraphs in your project: a deployed subgraph or a no-code subgraph.
If more than one subgraph is desired, they need to have the same graphql schema. You can use this tool to compare schemas.
- A working database to sink into. PostgreSQL is the most common choice; see sync a subgraph to Postgres.
Walkthrough
1
Prepare a database
goldsky secret list will show you the database secrets available on your active project.If you need to setup a secret, you can use goldsky secret create -h. Here is an example.2
Select the subgraphs to combine
Open the Subgraphs Dashboard and find the deployment IDs of each subgraph you would like to use as a source.Run the following query against the subgraph to get the deployment ID.
3
Create the pipeline definition
Open a text editor create your definition, using the
subgraphEntity source. In this example we will use subgraphs on Optimism and on BSC:qidao-optimism(QmPuXT3poo1T4rS6agZfT51ZZkiN3zQr6n5F2o1v9dRnnr)qidao-bsc(QmWgW69CaTwJYwcSdu36mkXgwWY11RjvX1oMGykrxT3wDS)
account and event entities from each.4
Create the pipeline
5
Monitor the pipeline
Monitor the pipeline with
goldsky pipeline monitor qidao-crosschain. The status should change from STARTING to RUNNING in a minute or so, and data will start appearing in your postgresql database.6
Create API server
Once you have multiple subgraphs being written into one destination database, you can set up a GraphQL API server with this database as a source; there are many options to do this:
- Apollo Server
- Express GraphQL
- Hasura [recommended for quick-start]