graphprotocol / graph-tooling

Monorepo for various tools used by subgraph developers.
https://thegraph.com/docs
Apache License 2.0
392 stars 209 forks source link

Support reading protobuf definitions contained within a Substreams package #1737

Open alex-pakalniskis opened 1 month ago

alex-pakalniskis commented 1 month ago

Discussed in https://github.com/graphprotocol/graph-tooling/discussions/1639

Originally posted by **alex-pakalniskis** April 22, 2024 ## Problem Even though Substreams packages contain relevant protobuf definitions, Substreams-powered subgraph developers are unable to reference those protobuf definitions when generating AssemblyScript types for their subgraph with `protoc`. See this example `protoc` command supporting wildcard matching of protobuf files. ``` bash protoc --plugin=./node_modules/protobuf-as/bin/protoc-gen-as --as_out=src/pb/ ./proto/*.proto ``` `protoc` does not natively parse Substreams packages, so users are left unable to proceed unless they source the required files. Furthermore, protobuf files are not easily found on the Substreams registry, so users must search GitHub and hope for the best. Locating the exactly correct protobuf definition files for a Substreams package adds unnecessary friction to the Substreams-powered subgraph developer experience. ## Potential solution Enable Graph CLI to generate AssemblyScript types from the `*.proto` files contained in a Substreams package (perhaps its just a nice wrapper for `protoc` + `protobuf-as`) ``` bash graph protogen #create a new command specific to protobuf files to look for `*.proto` files in `*.spkg` # or graph codegen #extend codegen to look for `*.proto` files in `*.spkg` if Substreams-powered subgraph ```
alex-pakalniskis commented 1 month ago

related to https://github.com/graphprotocol/graph-tooling/issues/1659