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

print current schema #79

Closed jmangold closed 5 years ago

jmangold commented 5 years ago

HI - I am stoked about rejoiner, thank you... I am trying to debug my first implementation of a grpc service fronted by graphql and I am having some trouble figuring out what parameters are expected. I did what I thought was right. It is having an issue with the return value, I believe. Proto file and curl calls below...

Proto file: service MathTest { rpc MyAverage (MathRequest) returns (MathReply) {} rpc MySum (MathRequest) returns (MathReply) {}
} message MathRequest { int32 x = 1; int32 y = 2; } message MathReply { int32 retVal = 1; }

***curl call to service through rejoiner implementation without denoting return val name:

curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ myAverage (input: {x : 3, y : 4}) }" }' http://127.0.0.1:8081/graphql

reply snippet: "data":null,"errors":[{"message":"Validation error of type SubSelectionRequired: Sub selection required for type grpc_MathReply of field myAverage"

*** curl call with return value name: curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ myAverage (input: {x : 3, y : 4}) { retVal } }" }' http://127.0.0.1:8081/graphql

reply snippet: "message":"Validation error of type FieldUndefined: Field \u0027retVal\u0027 in type \u0027grpc_MathReply\u0027 is undefined"

It does not complain about the X and Y, just the return value... Any help would be appreciated. Thank you.

siderakis commented 5 years ago

With GraphQL you need to pick the fields for all object types.

GraphiQL is a great tool to debug queries.

curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ myAverage (input: {x : 3, y : 4}){retVal} }" }' http://127.0.0.1:8081/graphql Sent from my iPhone

On Jun 14, 2019, at 8:49 AM, jmangold notifications@github.com wrote:

curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ myAverage (input: {x : 3, y : 4}) }" }' http://127.0.0.1:8081/graphql

siderakis commented 5 years ago

I hope that helped, please reopen if there are other question.