graph-tooling icon indicating copy to clipboard operation
graph-tooling copied to clipboard

Support reading protobuf definitions contained within a Substreams package

Open alex-pakalniskis opened this issue 1 year ago • 1 comments

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.

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)

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 avatar Oct 03 '24 23:10 alex-pakalniskis

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

alex-pakalniskis avatar Oct 15 '24 17:10 alex-pakalniskis