protoc-gen-pothos (v0.8.0) is a protoc plugin that generates Pothos GraphQL DSL code from Protocol Buffers IDL files. It integrates with ts-proto for TypeScript type definitions and requires Buf or protoc for code generation. Released roughly monthly, it supports custom scalar mappings, optional emission of imported file types, and configuration via Buf plugins. Unlike manual GraphQL schema building, it auto-generates Pothos builder calls corresponding to protobuf messages, enums, services, and fields, reducing boilerplate. Requires Pothos GraphQL and ts-proto as peer dependencies, and is designed for TypeScript server applications using GraphQL and gRPC.
npm install protoc-gen-pothosNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows full setup: install deps, configure Buf, create builder, generate code, and import generated Pothos objects.
Ensure pothos_builder_path is relative to the 'out' directory in buf.gen.yaml, e.g., if out=../src/__generated__/pothos, set pothos_builder_path=../../builder to point to src/builder.ts.
Set import_prefix to a path that resolves from the pothos output directory to the proto types output directory, e.g., if ts-proto out=../proto and pothos out=../pothos, then import_prefix=../proto.
Add these options to your ts-proto plugin config in buf.gen.yaml.
Update imports to match the new pattern: use named exports of type refs and schemas (e.g., User, UserSchema). Check release notes for migration guide.
Consider manually importing types from imported proto files or waiting for alternative support.
Export the builder as default: export default new SchemaBuilder({});Verify the relative path from the output directory to your builder file. Example: if output is src/__generated__/pothos and builder is src/builder.ts, then pothos_builder_path should be ../../builder.
Add '- outputTypeRegistry=true' to your ts-proto plugin options in buf.gen.yaml.
Ensure the builder file exports default new SchemaBuilder({}); and that @pothos/core is installed.Add '- import_prefix=../proto' (adjust path) to the pothos plugin options.