You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From the discussion below, I uncovered that using reflection as the protobuf source for a Grpc endpoint does not seem to work as documented. The documentation indicates that reflection will be used if the source property is not defined on the handler.
Originally posted by SonofNun15 December 5, 2022
I have a GRPC service that has reflection enabled.
I am able to enumerate the schema via reflection in postman and make requests to this service.
I set up my mesh config like this (same port as postman uses):
sources:
- name: People
handler:
grpc:
endpoint: localhost:5059
useHTTPS: true
The service is setup to use HTTPS and postman is connecting via TLS.
When I run the mesh service via mesh dev, it runs successfully and brings up the graphql tools, but there is no schema generated. If I look at the schema.graphql files in the .mesh folder and try to open any of the exploration tools in the graphql tools, everything is completely empty.
Any ideas as to what I am doing wrong? Is there something extra you have to do to get reflection to work properly?
UPDATE:
Tried pulling in the proto file locally to see what the issue was and I'm seeing this in the console:
Configuration is not valid:
data/sources/0/handler/grpc must NOT have additional properties
UPDATE:
Here's the proto file I'm using. Maybe it's not compatible for some reason, possible because of the datetime fields?
syntax = "proto3";
package person;
import "google/protobuf/timestamp.proto";
option csharp_namespace = "Models.Person";
service People {
rpc List (PeopleRequest) returns (PersonListReply);
rpc Get(PersonRequest) returns (Person);
rpc Phones(PhonesRequest) returns (PhonesReply);
}
message PeopleRequest {
int32 limit = 1;
int32 page = 2;
oneof optional_query {
string query = 3;
}
}
message Person {
string id = 1;
string name = 2;
string email = 3;
google.protobuf.Timestamp date_of_birth = 4;
}
message PersonListReply {
int32 count = 1;
repeated Person people = 2;
int32 page_size = 3;
}
message PersonRequest {
string person_id = 1;
}
message PhonesRequest {
string person_id = 1;
}
enum PhoneType {
PRIMARY = 0;
HOME = 1;
WORK = 2;
MOBILE = 3;
OTHER = 4;
}
message PhonesReply {
string id = 1;
string person_id = 2;
string number = 3;
PhoneType type = 4;
}
```</div>
The text was updated successfully, but these errors were encountered:
I was considering to open a new issue but I'll add that on top of what you described, whenever I add an empty file path to make the reflection flow work, I get another error: Failed to generate the schema TypeError: Cannot read properties of undefined (reading 'Client') at GrpcHandler.processReflection (/~/Desktop/graphql-demo/mesh/node_modules/@graphql-mesh/grpc/cjs/index.js:68:67)
The problem is that the grpc handler uses @ardatan/grpc-reflection-js and uses default import, but @ardatan/grpc-reflection-js doesn't do default export, only named. Maybe a PR should be opened to fix that?
From the discussion below, I uncovered that using reflection as the protobuf source for a Grpc endpoint does not seem to work as documented. The documentation indicates that reflection will be used if the source property is not defined on the handler.
This block of code, however, fails if the source field is not supplied and does not have a file property on it:
https://github.com/Urigo/graphql-mesh/blob/master/packages/handlers/grpc/src/index.ts#L203-L212
Because of this, in order to get reflection for Grpc you have to use
source: { file: "" }
in order to use reflection.Either the documentation should be updated accordingly or ideally the source code updated to handle the missing source property.
Discussed in #4890
Originally posted by SonofNun15 December 5, 2022
I have a GRPC service that has reflection enabled.
I am able to enumerate the schema via reflection in postman and make requests to this service.
I set up my mesh config like this (same port as postman uses):
The service is setup to use HTTPS and postman is connecting via TLS.
When I run the mesh service via
mesh dev
, it runs successfully and brings up the graphql tools, but there is no schema generated. If I look at theschema.graphql
files in the.mesh
folder and try to open any of the exploration tools in the graphql tools, everything is completely empty.Any ideas as to what I am doing wrong? Is there something extra you have to do to get reflection to work properly?
UPDATE:
Tried pulling in the proto file locally to see what the issue was and I'm seeing this in the console:
UPDATE:
Here's the proto file I'm using. Maybe it's not compatible for some reason, possible because of the datetime fields?
The text was updated successfully, but these errors were encountered: