danielvladco/go-proto-gql

Support tag to specify field name in graphql schema

Closed this issue · 3 comments

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.

Hi @MadhumitaChakraborty,
At the moment it is not possible, but I believe i it is not hard to implement.

Will label it as enhancement for future releases.

gurre commented

This would help a lot when transforming back to gRPC from graphql, e.g. userId to user_id.

Added graphql name option fo fields, services and RPCs in version v0.8.3