ysugimoto / grpc-graphql-gateway

A protoc plugin that generates graphql execution code from Protocol Buffers.
MIT License
382 stars 50 forks source link

buf generate not working if google.protobuf.Timestamp field exists in protobuf #70

Open janmpo opened 5 months ago

janmpo commented 5 months ago

Dear @ysugimoto and other members,

I'm trying to use this superb package with buf (https://https://buf.build) and fields that are of type google.protobuf.Timestamp.

I have successfully executed the greeter example, and to achieve that, I added to greeter example HelloRequest a google.protobuf.Timestamp date = 2 [(graphql.field) = {}];

api.proto file

` // greeter.proto syntax = "proto3";

import "graphql/graphql.proto"; import "google/protobuf/timestamp.proto";

package graphql;

option go_package = "/greeter"; // option go_package = ".;pb";

service Greeter { // gRPC service information option (graphql.service) = { host: "localhost:50051" insecure: true };

rpc SayHello (HelloRequest) returns (HelloReply) { // Here is plugin definition option (graphql.schema) = { type: QUERY // declare as Query name: "hello" // query name }; }

rpc SayGoodbye (GoodbyeRequest) returns (GoodbyeReply) { // Here is plugin definition option (graphql.schema) = { type: QUERY // declare as Query name: "goodbye" // query name }; } }

message HelloRequest { // Below line means the "name" field is required in GraphQL argument string name = 1 [(graphql.field) = {required: true}]; google.protobuf.Timestamp date = 2 [(graphql.field) = { }]; }

message HelloReply { string message = 1; google.protobuf.Timestamp date_only = 2 ; string text_only = 3; }

message GoodbyeRequest { // Below line means the "name" field is required in GraphQL argument string name = 1 [(graphql.field) = {required: true}]; }

message GoodbyeReply { string message = 1; } `

I have buf installed and these are my config files:

buf.yaml

` version: v2 modules:

and

buf.gen.yaml

` version: v2 managed: enabled: true plugins:

Regards & thanks for this great graphQL <-> gRPC [gateway]

janmpo