Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple .proto files #6

Open
teone opened this issue Apr 26, 2022 · 0 comments
Open

Support for multiple .proto files #6

teone opened this issue Apr 26, 2022 · 0 comments

Comments

@teone
Copy link

teone commented Apr 26, 2022

Hi @emzeq,
and first of all thanks for this tool!

I am trying to generate a graphql schema starting from protobuf, and it works fine as long as the .proto file does not contain any import.

I have a situation similar to this one:

// api/v1/a.proto
import "api/v1/b.proto";
message A {
  repeated b.B foo = 1;
}

// api/v1/b.proto
message B {
  string bar = 1;
}

If I run the compiler on b.proto I get the expected output, if I run it on a.proto I get this message:

proto2graphql --input api/v1/a.proto 
/usr/local/lib/node_modules/proto2graphql/node_modules/protobufjs/src/namespace.js:411
        throw Error("no such Type or Enum '" + path + "' in " + this);
        ^

Error: no such Type or Enum 'b.B' in Type .a.A

Is there any plan to support local imports in the future?

I suspect that it might be something happening in

// Provide resolver for protobuf's well-known types
root.resolvePath = function(origin, target) {
if (target.startsWith("google/protobuf/")) {
return path.join(protosDir, target);
}
return defaultResolver(origin, target);
};
but I'm not very familiar with protobuf in Javascript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant