Substreams:Subgraph
Last updated
Last updated
It is possible to the send data the of a Substreams to a subgraph, thus creating a Substreams-powered Subgraph.
There are two ways of making Substreams interact with subgraphs:
Create a special graph_out module that emits an EntityChanges Protobuf. The subgraph will read the EntityChanges
object and consume the data.
Use the Substreams triggers to consume Substreams Protobuf directly inside your subgraph.
Both are valid options depending on the use case:
Use the graph_out
module is if your logic is entirely in the Substreams Rust code. You will create the subgraph entities in the Substreams and the subgraph will only read them. By putting your logic in the Substreams, you will benefit from parallelism and you will be able to handle a cursor to track the progress of the data. Read more about it in the Reliability Guarantees section.
Use the Substreams triggers if you want to use Substreams as an extraction layer for the data, but the logic of your application will be in the subgraph AssemblyScript code. By putting all your logic in the subgraph, you will deal with an easier programming language (AssemblyScript).