opendoor-labs / protoc-gen-graphql

Protobuf compiler plugin for GraphQL
46 stars 17 forks source link

No need to specify go_package option #5

Closed daimatz closed 2 years ago

daimatz commented 3 years ago

Hi,

I found this plugin assumes to develop in Go, since it fails with "unable to determine Go import path" message when I run protoc command without go_package option. But I want to use this plugin without Go (we use TypeScript for GraphQL BFF and Java for gRPC server). Is there any ways to run command without go_package option?

Reproduce steps:

// a.proto
syntax = "proto3";

// option go_package = './'; // without this line, the command fails

message Ping { }
$ protoc --version
libprotoc 3.12.1
$ protoc --graphql_out=. a.proto
protoc-gen-graphql: unable to determine Go import path for "a.proto"

Please specify either:
        • a "go_package" option in the .proto source file, or
        • a "M" argument on the command line.

See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

--graphql_out: protoc-gen-graphql: Plugin failed with status code 1.

I tried command with --go_out=. --go_opt=Ma.proto=./ but there was no luck. It seems that we need to specify go_package in proto source file.

daimatz commented 2 years ago

Hi, I managed to omit go_package option by specifying --graphql_opt=M option. For the example above, I could run the command by

$ protoc --graphql_out=. --graphql_opt=Ma.proto=a.proto a.proto