protoc-gen-gqls

command module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2021 License: MIT Imports: 6 Imported by: 0

README

protoc-gen-gqls

protoc-gen-gqls is a protoc plugin that generates graphql schema (.glaphqls) from Protocol Buffers.

Use

$ protoc --plugin=protoc-gen-gqls --gqls_out=DIR example/proto/*.proto

Output example

.proto

syntax = "proto3";

package example;

import "google/api/annotations.proto";
import "google/type/date.proto";

service ExampleService {
  rpc Ping(PingRequest) returns (PingResponse) {
    option (google.api.http) = {
      get: "*"
    };
  };
  rpc Sample(SampleRequest) returns (SampleResponse) {
    option (google.api.http) = {
      post: "*"
    };
  };
  rpc Noop(NoopRequest) returns (NoopResponse) {};
}

message PingRequest {}

message PingResponse {}

message SampleRequest {
  int32 id = 1;
  string name = 2;
  bool flag = 3;
  Environment env = 4;
  google.type.Date date = 5;
}

message SampleResponse {
  int32 id = 1;
  string name = 2;
  repeated ResponseContent contents = 3;
}

message ResponseContent {
  string name = 1;
  string data = 2;
  google.type.Date date = 3;
  bool active = 4;
}

enum Environment {
  ENVIRONMENT_UNKNOWN = 0;
  DEVELOPMENT = 1;
  STAGING = 2;
  PRODUCTION = 3;
}

message NoopRequest {}

message NoopResponse {}

.graphqls

# Generated by protoc-gen-gqls.
type Query {
    Ping(req: PingRequest): PingResponse
}

type Mutation {
    Sample(req: SampleRequest): SampleResponse
}

input PingRequest {
    _: Boolean # noop field
}

type PingResponse {
    _: Boolean # noop field
}

input SampleRequest {
    id: Int
    name: String
    flag: Boolean
    env: Environment
    date: String
}

type SampleResponse {
    id: Int
    name: String
    contents: [ResponseContent]
}

type ResponseContent {
    name: String
    data: String
    date: String
    active: Boolean
}

input NoopRequest {
    _: Boolean # noop field
}

type NoopResponse {
    _: Boolean # noop field
}

enum Environment {
    ENVIRONMENT_UNKNOWN
    DEVELOPMENT
    STAGING
    PRODUCTION
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL