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.
Hi @emzeq,
and first of all thanks for this tool!
I am trying to generate a
graphqlschema starting from protobuf, and it works fine as long as the.protofile does not contain any import.I have a situation similar to this one:
If I run the compiler on
b.protoI get the expected output, if I run it ona.protoI get this message:Is there any plan to support local imports in the future?
I suspect that it might be something happening in
proto2graphql/src/converter.ts
Lines 11 to 17 in 78b7324