Is there a way to generate a GraphQL schema from a protobuf?

Tobi picture Tobi · Jun 6, 2017 · Viewed 7.7k times · Source

I have a rather large/complex protobuf definition of an API, and I wonder if there's a convenient tool to automatically generate a textual GraphQL schema and its (nested) types from a subset of this protobuf?

I'm using Node.js normally, but I'm open for other languages to generate the schema.

Answer

mikep picture mikep · Jun 23, 2017

If you're willing to use GoLang, there's a protobuf to GraphQL converter at

https://github.com/opsee/protobuf

Current gadgets graphql

The graphql gadget will generate a graphql schema for protobuf messages for use with the go-graphql package. It defines extensions for use in files, messages, and fields. See examples for usage -- the files generated by the plugin are flavortown.pb.go and flavortownpb_test.go.