Giter Site home page Giter Site logo

danielvladco / go-proto-gql Goto Github PK

View Code? Open in Web Editor NEW
210.0 4.0 50.0 800 KB

Protobuf plugins for generating graphql schema and golang to graphql bindings. Also supports a graphql gateway (Alpha)

License: Apache License 2.0

Go 97.58% Makefile 1.73% Shell 0.63% Dockerfile 0.07%
go graphql-server graphql generate gateway grpc graphql-schema grpc-servers protoc-plugins protocol-buffers

go-proto-gql's People

Contributors

appleboy avatar danielvladco avatar snikch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-proto-gql's Issues

FileUpload GraphQL Schema

Hello! Thanks for a great repo!

From what I can see there is no support for the scalar type Upload?

Please see this example from 99designs.

Please let me know if I have made an error or if this is an opportunity for a PR :)

protobuf.struct issues generating input

syntax = "proto3";

package test;

import "google/protobuf/struct.proto";

message Foo {
  string id = 1;
  google.protobuf.Struct bar = 2;
}

message FooRequest {
  Foo foo = 1;
}

message FooResponse {}

service AuditService {
  rpc Baz(FooRequest) returns (FooResponse) {}
}

It seems that the ListValueInput generated from ListValue has trouble compiling to graphql (I stripped away the comments for readability)

directive @AuditService on FIELD_DEFINITION
directive @ValueKind on INPUT_FIELD_DEFINITION
input FooInput {
	id: String
	bar: StructInput
}
input FooRequestInput {
	foo: FooInput
}
input ListValueInput
type Mutation {
	auditServiceBaz(in: FooRequestInput): Boolean
}
enum NullValue {
	NULL_VALUE
}
type Query {
	dummy: Boolean
}
input StructInput {
	fields: [Struct_FieldsEntryInput!]
}
input Struct_FieldsEntryInput {
	key: String
	value: ValueInput
}
input ValueInput {
	nullValue: NullValue @ValueKind
	numberValue: Float @ValueKind
	stringValue: String @ValueKind
	boolValue: Boolean @ValueKind
	listValue: ListValueInput @ValueKind
}

installation error: cannot find package "github.com/vektah/gqlparser/v2/ast" in any of:

when I run go install github.com/danielvladco/go-proto-gql/protoc-gen-gql and go install github.com/danielvladco/go-proto-gql/protoc-gen-gogql, the terminal will return errors:

../go/src/github.com/danielvladco/go-proto-gql/pkg/generator/descriptors.go:7:2: cannot find package "github.com/vektah/gqlparser/v2/ast" in any of:
../go/src/github.com/danielvladco/go-proto-gql/pkg/generator/descriptors.go:6:2: cannot find package "github.com/jhump/protoreflect/desc" in any of:
../go/src/github.com/danielvladco/go-proto-gql/protoc-gen-gql/main.go:13:2: cannot find package "github.com/vektah/gqlparser/v2/formatter" in any of:

Any idea about solving it?

Can't install gql and gogql due to mod replace

I tried to install the binary using the command provided in README.md, but got this error

 > [ 2/17] RUN go install github.com/danielvladco/go-proto-gql/[email protected]:                                                                                 
#6 0.225 go: downloading github.com/danielvladco/go-proto-gql v0.8.3                                                                                                  
#6 2.103 go install: github.com/danielvladco/go-proto-gql/[email protected] (in github.com/danielvladco/[email protected]):                                     
#6 2.103        The go.mod file for the module providing named packages contains one or
#6 2.103        more replace directives. It must not contain directives that would cause
#6 2.103        it to be interpreted differently than if it were the main module.

found this page. can we do something about it so everything in README.md works as expected and intended?

Relay - Global Object Identification specification

Hello! Thanks for a great library!

I'm looking to create a front facing 99design/gqlgen server that interacts with my internal grpc service. I'm looking to create a graphql server to fulfill https://graphql.org/learn/global-object-identification/ (GOI)

I use this library to autobind my base types but I don't use the resolvers at all, I use gqlgen for that. I still would like to use both go, go-grpc, gogql and gpl.

The graphql schema I'm trying to replicate can be found here: https://relay.dev/docs/guides/graphql-server-specification/

There are some issues I run into that could be solved:

  1. Graphql "type Ship implements Node"
    Issue: I would like to extend my proto types but it's not possible.
    Solution: a message option could be made like this:
    message Ship {
    option (danielvladco.protobuf.graphql.message) = {implements: "Node"};
    string id = 1;
    }
    Expected:
    The gogql outputs: type Node interface { IsNode() } func (*Ship) IsNode() {}
    The gpl outputs following graphql: type Ship implements Node {}
    Considerations: if node was a type / message Node {} then it would be a struct generated by go/go-grpc that would collide with a possilbe interface Node {}. Another question is how and where the Node definition should be, perhaps there is a nested option structure that can be applied as a file option?.

  2. gql generator, generates "dummy" query for "definition" proto files that contain only types (message Ship, etc.).
    Issue: If I only want types to be generated in the .graphql, it's not possible right now. It only output types that are traversed from a service then method and then field. There is a svc=false config that only applies to the directive.

  3. change the type of id to ID.
    Issue: Creating a custom type creates a nested like structure in proto which is not ideal.
    Solution: a field option that changes the type of graphql.
    string id = 1 [(danielvladco.protobuf.graphql.field) = {required: true, type: "ID"}];
    Expected:
    The gpl outputs following graphql: type Ship { id: ID! }

Go install fails

I'm using Go 1.16.2 go install requires me to run go get and go get fails.

> go install github.com/danielvladco/go-proto-gql/protoc-gen-gql
no required module provides package github.com/danielvladco/go-proto-gql/protoc-gen-gql; to add it:
	go get github.com/danielvladco/go-proto-gql/protoc-gen-gql


> go get github.com/danielvladco/go-proto-gql/protoc-gen-gql
# github.com/danielvladco/go-proto-gql/pkg/generator
go/pkg/mod/github.com/danielvladco/[email protected]/pkg/generator/generator.go:634:68: cannot use gql.E_Field (type *"github.com/gogo/protobuf/proto".ExtensionDesc) as type protoreflect.ExtensionType in argument to "google.golang.org/protobuf/proto".GetExtension:
	*"github.com/gogo/protobuf/proto".ExtensionDesc does not implement protoreflect.ExtensionType (missing InterfaceOf method)
go/pkg/mod/github.com/danielvladco/[email protected]/pkg/generator/utils.go:16:67: cannot use gql.E_RpcType (type *"github.com/gogo/protobuf/proto".ExtensionDesc) as type protoreflect.ExtensionType in argument to "google.golang.org/protobuf/proto".GetExtension:
	*"github.com/gogo/protobuf/proto".ExtensionDesc does not implement protoreflect.ExtensionType (missing InterfaceOf method)
go/pkg/mod/github.com/danielvladco/[email protected]/pkg/generator/utils.go:27:68: cannot use gql.E_SvcType (type *"github.com/gogo/protobuf/proto".ExtensionDesc) as type protoreflect.ExtensionType in argument to "google.golang.org/protobuf/proto".GetExtension:
	*"github.com/gogo/protobuf/proto".ExtensionDesc does not implement protoreflect.ExtensionType (missing InterfaceOf method)

Any idea on how to solve this?

Directive prefix option

The npm package @graphql-tools does not support importing a schema where there is a shared name between a Directive and a Union Type. Would it be possible to pass an option to prefix directives to prevent any naming conflicts?

reference

Support tag to specify field name in graphql schema

Is it possible to generate a field in graphql schema with custom name, different from the name in .proto file using some tag like "json_name"?

For example, my protobuf file looks like

message SampleMessage {
string message_id = 1;
}

If I run protoc --gql_out=paths=source_relative:. -I=. -I=./vendor/ -I=./myProtoBuf.proto

it generates the following graphql

type SampleMessage {
messageId: String
}

But I want to have a different name of the field "messageId" in the graphql schema.

Adapt OpenAPI to GraphQL

Build tools to translate OpenAPI spec to GraphQL and also generate the go bindings.

Please add a thumbs up if there is interest in this feature. This will signal me if I should prioritise it.

Rename the project to something else

go-proto-gql is no longer suitable for this project as it has a bigger scope now.

Also gql and graphql are not the same so it is important to change all occurrences to graphql

Directives in options.graphql

In your example
example/codegen/pb/options.graphql
There are the directives of the services

directive @Query on FIELD_DEFINITION
directive @Service on FIELD_DEFINITION
directive @Test on FIELD_DEFINITION

This is automatically added with your generator. But the individual serviceNames don't get the @service automatically or do they?
For Example in line 84
serviceMutate1(in: DataInput): Data @Service
Is there a reason of this directives in general? And would it be helpful for you to automatically add this Directives to the specific services?

Protobuf with 'oneof' creates invalid schema with directive.

Given this protobuf I'm not able to create a valid schema file.

syntax = "proto2";

package user.Profile;

message Value {
  oneof _propertyReference {
    string   propertyId = 2;
    Property property   = 3;
  }

  optional string id    = 1;
  required string value = 4;
}

message Property {
  optional string id      = 1;
  required string label   = 2;
}

message UserProfileExtended {
  repeated Value items = 1;
}

message UserProfile {
  optional UserProfileExtended  extended  = 4;
}

service UserProfileService {
    rpc upsert (UserProfileUpsertRequest) returns (UserProfile);
}

message UserProfileUpsertRequest {
    required UserProfile profile  = 3;
}

With this protobuf I was able to generate the schema below

directive @UserProfileService on FIELD_DEFINITION
directive @Value_PropertyReference on INPUT_FIELD_DEFINITION
type Mutation {
	userProfileServiceUpsert(in: UserProfileUpsertRequestInput): UserProfile
}
type Property {
	id: String
	label: String
}
input PropertyInput {
	id: String
	label: String
}
type Query {
	dummy: Boolean
}
type UserProfile {
	extended: UserProfileExtended
}
type UserProfileExtended {
	items: [Value!]
}
input UserProfileExtendedInput {
	items: [ValueInput!]
}
input UserProfileInput {
	extended: UserProfileExtendedInput
}
input UserProfileUpsertRequestInput {
	profile: UserProfileInput
}
type Value {
	xPropertyReference: Value_PropertyReference
	id: String
	value: String
}
input ValueInput {
	propertyId: String @Value_PropertyReference
	property: PropertyInput @Value_PropertyReference
	id: String
	value: String
}
type Value_Property {
	property: Property
}
type Value_PropertyId {
	propertyId: String
}
union Value_PropertyReference = Value_PropertyId | Value_Property

Being that UserProfile is the request object for userProfileServiceUpsert wouldn't the ValueInput also only expect either propertyId or the property type. It's not clear what the directive is doing or trying to do.

Add sensible scalar types for well-known types (wkts) especially google.protobuf.Struct

Currently the GraphQL generated for google.protobuf.Struct (which represents JSON in protobuf) is a recursive type which introduces depth and cycle issues.

Proposal: Create a GraphQL scalar type scalar JSON to represent JSON (google.protobuf.Struct) as a leaf value. It would then be a good idea to ship an implementation in gqlgen.

Similarly other wkts could have reconsidered scalar types, such as google.protobuf.Timestamp as scalar Time for which there is already a gqlgen implementation.

Request - prevent renaming of protobuf message fields

Would it be possible to have an option to prevent renaming of protobuf message fields? With a message like the one below.

message Company {
    optional string _id = 10;
}

the generated graphql has a different property name

type Company {
    xId: String
}

This creates an issue with our service expecting a message to be identical to what is defined in the protobuf

Empty output

Hi,

I tried to generate some graphql schemas but so far I'm getting (nearly) empty output.

Input definition:

syntax = "proto3";

package metadata;

message Example {
  string msg = 1;
  string source = 2;
  string provider = 4;
}

Output:

# Code generated by protoc-gen-gogql. DO NOT EDIT
# source: metadata-definitions/protobuf/example.proto

Command used:
protoc --gql_out=paths=source_relative:. -I=${GOPATH}/pkg/mod/ -I=. -I=metadata-definitions/protobuf/ metadata-definitions/protobuf/example.proto

Versions:

$ protoc --version
libprotoc 3.6.1
$ go version
go version go1.11.5 darwin/amd64

Running this on my mac with zsh. Any ideas what could be wrong?

Trying to understand how the example codegen works

Running the example codegen I get directive Query is not implemented when running:

query {
  queryQuery2(in: {
    stringX: "hello",
    foo: {
      param1: "bar"
    }
    double: 32
  }) {
    string2
  }
}

Am I missing something here?

Organize GQL Queries & Mutations by Proto Service

If I have the following proto file:

service AuthorAPI {
  rpc GetAuthorById (GetAuthorByIdRequest) returns (GetAuthorByIdResponse) {
    option (gql.rpc_type) = QUERY;
  }
}

The generated GraphQL schema will be:

type Query {
  authorAPIGetAuthorById(in: GetAuthorByIdRequestInput): GetAuthorByIdResponse
}

However, I think the generated GraphQL schema is much clearer by nesting queries by proto services (rather than prefixing query rpc method names with the service name):

type AuthorAPI {
  GetAuthorById(in: GetAuthorByIdRequestInput): GetAuthorByIdResponse
}

type Query {
  AuthorApi: AuthorAPI
}

Is it possible to forward headers in the unified Gateway?

I would like to forward authentication headers from my unified GraphQL gateway to my backend gRPC services. Normally, I would register a request middleware in Nautilus. Will this library translate the HTTP headers to gRPC metadata?

How to generate to Pascal case style?

hi all,
before the question thanks for develop this generator. but how to generate to Pascal case style? because now generated camelCase
thanks before

Python generation breaking python client

Hi, im use your module to generate a custom graphql scheme, im very satisfied how it work in conection with go, bou wnen im try to generate python client from same proto files, python client not work

try to understand why, and find something:

  1. in python appear a import like :
    from danielvladco.go_proto_gql import graphql_pb2 as danielvladco_dot_go__proto__gql_dot_graphql__pb2
    but this module cannot exist

  2. when im inversigate a problem one im create a "empty" module just to resolve a import exception, but appear second problem, few rows after in py file appear a row like

DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x13wallet/common.proto\x12\x06wallet\x1a'danielvladco/go-proto-gql/graphql.proto"\x1e\n\x06UserID\x12\x14\n\x04uuid\x18\x01 \x01(\tB\x06\xb2\xe0\x1f\x02\x08\x01"\x17\n\x07\x42\x61lance\x12\x0c\n\x04\x63\x61sh\x18\x01 \x01(\x02"G\n\tMultiLang\x12\x12\n\x02ro\x18\x01 \x01(\tB\x06\xb2\xe0\x1f\x02\x08\x01\x12\x12\n\x02ru\x18\x02 \x01(\tB\x06\xb2\xe0\x1f\x02\x08\x01\x12\x12\n\x02\x65n\x18\x03 \x01(\tB\x06\xb2\xe0\x1f\x02\x08\x01"\xd6\x01\n\x1aUpsertPaymentMethodRequest\x12\x0f\n\x02id\x18\x01 \x01(\tH\x00\x88\x01\x01\x12(\n\x05title\x18\x02 \x01(\x0b\x32\x11.wallet.MultiLangB\x06\xb2\xe0\x1f\x02\x08\x01\x12.\n\x0b\x64\x65scription\x18\x03 \x01(\x0b\x32\x11.wallet.MultiLangB\x06\xb2\xe0\x1f\x02\x08\x01\x12\x15\n\x05image\x18\x04 \x01(\tB\x06\xb2\xe0\x1f\x02\x08\x01\x12/\n\x04type\x18\x05 \x01(\x0e\x32\x19.wallet.PaymentMethodTypeB\x06\xb2\xe0\x1f\x02\x08\x01\x42\x05\n\x03_id"0\n\x1a\x44\x65letePaymentMethodRequest\x12\x12\n\x02id\x18\x01 \x01(\tB\x06\xb2\xe0\x1f\x02\x08\x01"N\n\x15PaymentMethodsRequest\x12,\n\x04type\x18\x01 \x01(\x0e\x32\x19.wallet.PaymentMethodTypeH\x00\x88\x01\x01\x42\x07\n\x05_type"H\n\x16PaymentMethodsResponse\x12.\n\x0fpayment_methods\x18\x01 \x03(\x0b\x32\x15.wallet.PaymentMethod"\xb1\x01\n\rPaymentMethod\x12\n\n\x02id\x18\x01 \x01(\t\x12 \n\x05title\x18\x02 \x01(\x0b\x32\x11.wallet.MultiLang\x12&\n\x0b\x64\x65scription\x18\x03 \x01(\x0b\x32\x11.wallet.MultiLang\x12\r\n\x05image\x18\x04 \x01(\t\x12'\n\x04type\x18\x05 \x01(\x0e\x32\x19.wallet.PaymentMethodType\x12\x12\n\nmin_amount\x18\x06 \x01(\x03*=\n\x11PaymentMethodType\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\n\n\x06ONLINE\x10\x01\x12\x0b\n\x07OFFLINE\x10\x02\x42\x35H\x01Z1git.simpals.com/Simpals/simpalsapis/gen_go/walletb\x06proto3')

and this row raise a error:

TypeError: Couldn't build proto file into descriptor pool: Depends on file 'danielvladco/go-proto-gql/graphql.proto', but it has not been loaded

Two questions:

  1. How i can resolve this? I can "cover" eror one , but second... remain open
  2. You not check a python generation? ( im understand you module in go oriented )... but how about a another languages?
    Thanks

Does the gateway support grpc streams ?

I tried running a subscription for a (server) grpc stream with the graphql playground but I get the following error:

{
  "error": "Could not connect to websocket endpoint ws://localhost:8080/playground. Please check if the endpoint url is correct."
}

Proxy GraphQL to GraphQL

Pass GraphQL endpoints to federate to other services GraphQL.

Please add a thumbs up if there is interest in this feature. This will signal me if I should prioritise it.

Only `exec.go` gets generated

In my simple example gRPC service (see this repo), I'm trying to make use of this library. However, after using it as specified with the following go generate instruction:

//go:generate bash -c "protoc --go_out=plugins=grpc,paths=source_relative:../ --gqlgencfg_out=paths=source_relative:../ --gql_out=svcdir=true,paths=source_relative:../ --gogqlgen_out=paths=source_relative,gogoimport=false:../ -I=../ -I=/usr/local/include -I=`go list -m -f \"{{.Dir}}\" github.com/danielvladco/go-proto-gql/pb` ../proto/math.proto"

I try to generate the files for gqlgen:

[pojntfx@thinkpadx1c3 grpc-go-math]$ tree lib/proto/
lib/proto/
└── math.proto

0 directories, 1 file
[pojntfx@thinkpadx1c3 grpc-go-math]$ go generate ./...
go: finding github.com/pojntfx/grpc-go-math/lib latest
go: finding github.com/pojntfx/grpc-go-math/lib/proto latest
[pojntfx@thinkpadx1c3 grpc-go-math]$ tree lib/proto/
lib/proto/
├── math.gqlgen.pb.go
├── math.gqlgen.pb.yml
├── math.pb.go
├── math.pb.graphqls
└── math.proto

0 directories, 5 files
[pojntfx@thinkpadx1c3 grpc-go-math]$ cd lib/proto/
[pojntfx@thinkpadx1c3 proto]$ go run github.com/99designs/gqlgen -v -c ./math.gqlgen.pb.yml 
[pojntfx@thinkpadx1c3 proto]$ tree .
.
├── exec.go
├── math.gqlgen.pb.go
├── math.gqlgen.pb.yml
├── math.pb.go
├── math.pb.graphqls
└── math.proto

0 directories, 6 files

As you can see, only the exec.go file gets generated; models.go etc. is missing. Here is the math.gqlgen.pb.yml (which looks fine to me):

schema:
- math.pb.graphqls
exec:
  filename: exec.go
model:
  filename: models.go
models:
  Int64:
    model:
    - github.com/danielvladco/go-proto-gql/pb.Int64
  MathAddArgsInput:
    model:
    - github.com/pojntfx/grpc-go-math/lib/proto.MathAddArgs
  MathAddReply:
    model:
    - github.com/pojntfx/grpc-go-math/lib/proto.MathAddReply
  MathSubtractArgsInput:
    model:
    - github.com/pojntfx/grpc-go-math/lib/proto.MathSubtractArgs
  MathSubtractReply:
    model:
    - github.com/pojntfx/grpc-go-math/lib/proto.MathSubtractReply

The following proto is the basis:

syntax = "proto3";

package math;
import "gql.proto";
option go_package = "github.com/pojntfx/grpc-go-math/lib/proto";

// Service math adds and subtracts numbers
service Math {
  rpc Add(MathAddArgs) returns (MathAddReply) {
    option (gql.rpc_type) = QUERY;
  };
  rpc Subtract(MathSubtractArgs) returns (MathSubtractReply) {
    option (gql.rpc_type) = QUERY;
  };
}

// MathAddArgs are the arguments for an addition
message MathAddArgs {
  int64 First = 1;
  int64 Second = 2;
}

// MathAddReply is the reply for an addition
message MathAddReply { int64 Result = 3; }

// MathSubtractArgs are the arguments for a subtraction
message MathSubtractArgs {
  int64 First = 1;
  int64 Second = 2;
}

// MathSubtractReply is the reply for a subtraction
message MathSubtractReply { int64 Result = 3; }

The generated .graphqls looks fine to me as well:

# Code generated by protoc-gen-gogql. DO NOT EDIT
# source: proto/math.proto

directive @Math(name: String) on FIELD_DEFINITION

scalar Int64

input MathAddArgsInput {
	first: Int64  
	second: Int64  
}

input MathSubtractArgsInput {
	first: Int64  
	second: Int64  
}

type MathAddReply {
	result: Int64 
}

type MathSubtractReply {
	result: Int64 
}

type Query {
	mathAdd(in: MathAddArgsInput): MathAddReply @Math
	mathSubtract(in: MathSubtractArgsInput): MathSubtractReply @Math
}

To summarize, it appears as though only the exec.go file gets generated; this however is not sufficient enough to build an actual GraphQL server. I'm still quite new to Golang, so there might be something obvious wrong here; sorry if that is the case.

Go install error when installing v0.10.0

Hello! Good to see such a good repo which helps me a lot in my work.

However, when I try to run cmd like
go install github.com/danielvladco/go-proto-gql/protoc-gen-gogql@latest

Terminal showes
go: github.com/danielvladco/go-proto-gql/protoc-gen-gogql@latest (in github.com/danielvladco/[email protected]): The go.mod file for the module providing named packages contains one or more replace directives. It must not contain directives that would cause it to be interpreted differently than if it were the main module.

I think go.mod should not contain replace directives like

replace github.com/nautilus/graphql v0.0.20 => github.com/nautilus/graphql v0.0.22

Tmp soluion:
go install github.com/danielvladco/go-proto-gql/[email protected]

Nested message type with oneof creates duplicate name

package company;

message Company {
  message ImageCollection {
    optional Image logo   = 1;
  }

  optional string          id      = 1;
  optional ImageCollection images  = 3;
}

message Image {
  oneof _type {
    string url    = 1;
    Upload upload = 2;
  }

  message Upload {
    required bytes    bytes    = 1;
    required string   mimeType = 2;
  }
}

service CompanyService {
    rpc fetch (CompanyFetchRequest) returns (Company);
}

message CompanyFetchRequest {
    required string id = 1;
}

With this protobuf I am getting a circular reference for Image_Upload. Below is the generated schema

scalar Bytes
type Company {
	id: String
	images: Company_ImageCollection
}
input CompanyFetchRequestInput {
	id: String
}
type Company_ImageCollection {
	logo: Image
}
type Image {
	xType: Image_Type
}
union Image_Type = Image_Url | Image_Upload
type Image_Upload {
	upload: Image_Upload
}
type Image_Url {
	url: String
}
type Mutation {
	companyServiceFetch(in: CompanyFetchRequestInput): Company
}
type Query {
	dummy: Boolean
}

dependencies doesn't work when we give output directories different for --gogqlgen_out and --go_out

First of all I would like to thank you for your work.

While I was using your library I see dependency disconnect when we give output directories different for --gogqlgen_out and --go_out. Will it be possible to look into this issue?

I am using below command in my case.

protoc
--go_out=plugins=grpc,paths=source_relative:./example/pb
--dart_out=grpc:./example/dart_pb
--gqlgencfg_out=paths=source_relative:./example/yml_files
--gql_out=svcdir=true,paths=source_relative:./example/schemas
--gogqlgen_out=paths=source_relative,gogoimport=false:./example/services
-I=. -I=./example/ example/proto/*.proto

Fresh install - ambiguous import

Tried a fresh install:

go version go1.16.3 darwin/amd64

➜  go install github.com/danielvladco/go-proto-gql/protoc-gen-gql

no required module provides package github.com/danielvladco/go-proto-gql/protoc-gen-gql; to add it:
    go get github.com/danielvladco/go-proto-gql/protoc-gen-gql

➜   go get github.com/danielvladco/go-proto-gql/protoc-gen-gql

go: downloading github.com/vektah/gqlparser v1.3.1
github.com/danielvladco/go-proto-gql/protoc-gen-gql imports
    github.com/danielvladco/go-proto-gql/pkg/generator imports
    github.com/danielvladco/go-proto-gql/pb: ambiguous import: found package github.com/danielvladco/go-proto-gql/pb in multiple modules:
    github.com/danielvladco/go-proto-gql v0.8.3 (~/go/pkg/mod/github.com/danielvladco/[email protected]/pb)
    github.com/danielvladco/go-proto-gql/pb v0.6.0 (~/go/pkg/mod/github.com/danielvladco/go-proto-gql/[email protected])

Setting GO111MODULE to off works as expected:

GO111MODULE=off go get -v \
    github.com/danielvladco/go-proto-gql/protoc-gen-gql \
    github.com/danielvladco/go-proto-gql/protoc-gen-gogql

protoc-gen-gql only uses mutations?

I decided to give this plugin a try. When the RPC services are transpiled into GQL, why does it only use Mutation?

Here is my generated code

# Code generated by protoc-gen-gogql. DO NOT EDIT
# source: foo/bar/author/v1/author_api.proto

scalar Int32

input GetAuthorByIdRequestInput {
	id: Int32  
}

type GetAuthorByIdResponse {
	author: Author 
}

type Author {
	id: Int32 
}

type Mutation {
	authorAPIGetAuthorById(in: GetAuthorByIdRequestInput): GetAuthorByIdResponse
}

type Query { dummy: Boolean }

And here is my proto file

syntax = "proto3";

package foo.bar.author.v1;

option csharp_namespace = "Foo.Bar.Author.V1";
option go_package = "authorv1";
option java_multiple_files = true;
option java_outer_classname = "AuthorApiProto";
option java_package = "com.foo.bar.author.v1";
option objc_class_prefix = "WHP";
option php_namespace = "Foo\\Bar\\Author\\V1";


// AuthorApi is a service.
service AuthorAPI {
  // GetAuthorById is a service all.
  rpc GetAuthorById (GetAuthorByIdRequest) returns (GetAuthorByIdResponse);
}

// GetAuthorByIdRequest is a request.
message GetAuthorByIdRequest {
  int32 id = 1;
}

// GetAuthorByIdResponse is a response.
message GetAuthorByIdResponse {
  Author author = 1;
}

// GetAuthorByIdResponse is a data model.
message Author {
  int32 id = 1;
}

Adapt OpenRPC to GraphQL

Build tools to translate OpenRPC spec to GraphQL and also generate the go bindings.

Please add a thumbs up if there is interest in this feature. This will signal me if I should prioritise it.

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.