Coder Social home page Coder Social logo

protoc-gen-graphql's Introduction

protoc-gen-graphql

protoc-gen-graphql is a highly customizable Protobuf compiler plugin to generate GraphQL schema definition language (SDL) files.

Usage

First, download the plugin and place the executable in your path. Then, run the Protobuf compiler with the --graphql_out flag to enable this plugin. Set the value of this flag to the directory you want the SDL files to be generated into.

protoc -I . --graphql_out=output_dir path/to/file.proto ...

Parameters

The SDL generation can be customized by passing optional parameters to the plugin. Parameters are specified using a comma separated list of parameters before the output directory, separated by a colon. For example:

protoc -I . --graphql_out=root_type_prefix=GRPC,null_wrappers:output_dir path/to/file.proto ...

Note that parameter settings apply to all the generated GraphQL types and files. For settings that apply to single Protobuf objects, like messages and fields, refer to the Protobuf options section below.

Available parameters are:

Key Values Default Description
field_name lower_camel_case, preserve lower_camel_case Transformation from Protobuf field names to GraphQL field names. Default is lowerCamelCase. Use preserve to use the Protobuf name as-is.
trim_prefix string Trims the provided prefix from all generated GraphQL type names. Useful if your Protobuf package names have a common prefix you want to omit.
root_type_prefix string If set, a gRPC service's mapped query and mutation types will extend some custom root type with name given by the provided prefix plus Query or Mutation. Set to empty string to extend the root Query and Mutation types.
input_mode all, service, none service The input mode determines what GraphQL input objects will be generated. all will generate an input object for each Protobuf message. service will only generate inputs for messages that are transitively used in each gRPC methods' request messages. none will not generate any input objects.
null_wrappers bool false If true, well known wrapper types (e.g. google.protobuf.StringValue) will be mapped to nullable GraphQL scalar types instead of the corresponding object type.
js_64bit_type string, number number Whether to use a String or Float scalar type when mapping 64bit Protobuf types (int64, uint64, sint64, fixed64, sfixed64).
timestamp string GraphQL type name to use for the well known google.protobuf.Timestamp type.
duration string GraphQL type name to use for the well known google.protobuf.Duration type.
struct string GraphQL type name to use for the well known google.protobuf.Struct type.

Protobuf options

Protobuf options file

TODO

Protobuf to GraphQL mapping

TODO

Messages

Maps

Oneofs

Enums

Services

protoc-gen-graphql's People

Contributors

martinxsliu avatar apalchys avatar stpnvntn avatar trunnelben avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.