Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Protobuf compiler plugin for GraphQL

NotificationsYou must be signed in to change notification settings

LeapAC/protoc-gen-graphql

 
 

Repository files navigation

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:

KeyValuesDefaultDescription
field_namelower_camel_case,preservelower_camel_caseTransformation from Protobuf field names to GraphQL field names. Default is lowerCamelCase. Usepreserve to use the Protobuf name as-is.
trim_prefixstringTrims 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_prefixstringIf set, a gRPC service's mapped query and mutation types will extend some custom root type with name given by the provided prefix plusQuery orMutation. Set to empty string to extend the rootQuery andMutation types.
input_modeall,service,noneserviceThe 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_wrappersboolfalseIf 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_typestring,numbernumberWhether to use aString orFloat scalar type when mapping 64bit Protobuf types (int64,uint64,sint64,fixed64,sfixed64).
timestampstringGraphQL type name to use for the well knowngoogle.protobuf.Timestamp type.
durationstringGraphQL type name to use for the well knowngoogle.protobuf.Duration type.
structstringGraphQL type name to use for the well knowngoogle.protobuf.Struct type.
nullable_list_typesboolfalseIf true, list types will have a nullable type definition.

Protobuf options

Protobuf options file

TODO

Protobuf to GraphQL mapping

TODO

Messages

Maps

Oneofs

Enums

Services

About

Protobuf compiler plugin for GraphQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go98.8%
  • Makefile1.2%

[8]ページ先頭

©2009-2025 Movatter.jp