google / rejoiner

Generates a unified GraphQL schema from gRPC microservices and other Protobuf sources
https://google.github.io/rejoiner/
Apache License 2.0
3.67k stars 139 forks source link

Inconsistency between input field and output field name conversion #47

Closed wangyuesong closed 6 years ago

wangyuesong commented 6 years ago

We are using rejoiner in production and found that there is an inconsistency between generated output field's GraphqlFieldDefinition and input field's field GraphqlInputObjectField. For example, for a message like: message Account { string account_p_code = 1 } The input graphql type generated will be Input_qapi_Account { account_p_code: string } The output graphql type generated will be qapi_Account { accountPCode: string } This seems to be an inconsistency. The logic generating fullName to GraphqlType map is here in ProtoRegistry.java And it generates input type here in GqlInputConverter.java, which lacks camel case conversion

generates output type here in ProtoToGql.java

Is this intentional? And i don't see there is a way to configure it.

I can submit a PR with tests to (1) Fix this inconsistency, but this might break existing user's behavior (2) Configure this behavior somewhere? I haven't looked carefully and not sure if we already have some machanisms to configure the mapping between protobuf field names and graphql field names.

Let me know if this make sense and if i can help on that :) thanks!

siderakis commented 6 years ago

I think consistently using camelcase is the best option.

If someone can’t upgrade because they need underscore case field names we can release an update that’s configurable at that time.