Skip to content

Using Reflection for Grpc source does not work as documented #4919

Open
@SonofNun15

Description

@SonofNun15

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):

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions