loading protos
Hi team. im trying to load some protos into the convex backend but couldnt figure out how
my directory looks sth like
tried a few variations but keep running into
i also tried moving the protos/client.proto into the convex dir/ but got an error like
i'd apprecate any tips on how to debug the error. thanks!
8 Replies
not sure if convex is doing some magic to the path 🤔
when i do
i get
Convex functions don’t have file system access, they’re serverless functions
And as you saw, non-js files can’t be imported. Maybe the team has a more creative solution, but my guess is any grpc use will need to happen in a separate service. I’ll also go ahead and ask: is it possible to use Convex without grpc to accomplish whatever you’re doing here?
@winsoroaks Indeed the way Convex bundles code won't include a file just mentioned as a string in a JS/TS file. Is there a codegen-oriented approach here? So you generate JS/TS code which can be bundled?
thanks, tom. i am not sure if i fully understand the question. it's not a codegen approach, as in it's always the same protos that i'd like to load to the server. is there an alternative i can try?
I'm wondering if there's another way to consume these .proto files where instead of loading them at runtime you generate JavaScript from the .proto file.
That sort if approach would definitely work.
You do have some other options, it would be great to figure out the recommended way to work with proto specs in convex.
"always the same protos" -> great, then codegen spunds reasonable?
Just googling I see https://github.com/stephenh/ts-proto
GitHub
GitHub - stephenh/ts-proto: An idiomatic protobuf generator for Typ...
An idiomatic protobuf generator for TypeScript. Contribute to stephenh/ts-proto development by creating an account on GitHub.
Convex currently bundles only .js, .jsx, .ts, .tsx, .wasm, and ither related files by following
import
statements in code. It does not follow filename strings, so it won't find this proto file.
Let me know what you think, I've only used these sorts of codegen approaches, never the dynamically load style so I don't know if there's something I'm missing about what you're trying to do.got it. will check it out, thanks 🙂