Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 1000
Tobi Avatar asked Jun 06 '17 19:06

Tobi


People also ask

Does GraphQL have a schema?

Your GraphQL server uses a schema to describe the shape of your available data. This schema defines a hierarchy of types with fields that are populated from your back-end data stores. The schema also specifies exactly which queries and mutations are available for clients to execute.

What is protobuf schema?

Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data.

What makes up GraphQL schema?

Your GraphQL server uses a schema to describe the shape of your data graph. This schema defines a hierarchy of types with fields that are populated from your back-end data stores. The schema also specifies exactly which queries and mutations are available for clients to execute against your data graph.


1 Answers

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.

like image 115
mikep Avatar answered Sep 17 '22 16:09

mikep