# protoc-gen-nexus

> Generate DSL for GraphQL Nexus from Protocol Buffers IDL

Latest version **0.8.3** (published 2026-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install protoc-gen-nexus
pnpm add protoc-gen-nexus
yarn add protoc-gen-nexus
bun add protoc-gen-nexus
```

Provides the command `protoc-gen-nexus`.

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.8.3 |
| Published | 2026-01-17 |
| First published | 2020-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 14.0.0 |
| Dependencies | 6 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | izumin5210 |
| Maintainers | izumin5210 |
| Keywords | graphql, grpc, nexus, protobuf, typescript |

## Links

- npm: https://www.npmjs.com/package/protoc-gen-nexus
- Repository: https://github.com/proto-graphql/proto-graphql-js
- Homepage: https://github.com/proto-graphql/proto-graphql-js#readme
- Issues: https://github.com/proto-graphql/proto-graphql-js/issues
- npm.io page: https://npm.io/package/protoc-gen-nexus

## Dependencies (6)

- [ts-poet](https://npm.io/package/ts-poet.md) ^6.3.0
- [change-case](https://npm.io/package/change-case.md) ^4.1.2
- [@bufbuild/protobuf](https://npm.io/package/@bufbuild/protobuf.md) 2.1.0
- [@bufbuild/protoplugin](https://npm.io/package/@bufbuild/protoplugin.md) 2.1.0
- [@proto-graphql/codegen-core](https://npm.io/package/@proto-graphql/codegen-core.md) 0.5.2
- [@proto-graphql/protoc-plugin-helpers](https://npm.io/package/@proto-graphql/protoc-plugin-helpers.md) 0.4.2

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.8.3 (latest) — 2026-01-17
- 0.8.2 — 2024-11-29
- 0.8.1 — 2024-06-11
- 0.7.0 — 2024-04-24
- 0.6.6 — 2024-02-07
- 0.6.5 — 2023-10-15
- 0.6.4 — 2023-10-08
- 0.6.2 — 2022-12-26
- 0.6.1 — 2022-12-21
- 0.6.0 — 2022-12-15
- 0.5.6 — 2022-11-25
- 0.5.5 — 2022-11-25
- 0.5.4 — 2022-11-14
- 0.5.3 — 2022-10-24
- 0.5.2 — 2022-10-23
- … 40 more at https://npm.io/package/protoc-gen-nexus/versions

## README

# ProtoNexus

> **⚠️ DEPRECATED**: This package is no longer maintained.
> GraphQL Nexus development has stopped.
> Please consider migrating to [protoc-gen-pothos](https://github.com/proto-graphql/proto-graphql-js/tree/main/packages/protoc-gen-pothos) with [protobuf-es](https://github.com/bufbuild/protobuf-es).

Protobuf-First GraphQL Schemas with [GraphQL Nexus](https://nexusjs.org/)

## Packages

| package | description | version |
| ------- | ----------- | ------- |
| [protoc-gen-nexus](./packages/protoc-gen-nexus) | `protoc` plugin for generating Nexus type definitions | [![npm version](https://badge.fury.io/js/protoc-gen-nexus.svg)](https://badge.fury.io/js/protoc-gen-nexus) |
| [@proto-nexus/google-protobuf](./packages/@proto-nexus/google-protobuf) | Runtime library | [![npm version](https://badge.fury.io/js/%40proto-nexus%2Fgoogle-protobuf.svg)](https://badge.fury.io/js/%40proto-nexus%2Fgoogle-protobuf) |
| [@proto-nexus/protobufjs](./packages/@proto-nexus/protobufjs) | Runtime library | [![npm version](https://badge.fury.io/js/%40proto-nexus%2Fprotobufjs.svg)](https://badge.fury.io/js/%40proto-nexus%2Fprotobufjs) |
| [@proto-nexus/proto-fields-plugin](./packages/@proto-nexus/proto-fields-plugin) | Nexus plugin for building subset types from proto-nexus's artifacts | [![npm version](https://badge.fury.io/js/%40proto-nexus%2Fproto-fields-plugin.svg)](https://badge.fury.io/js/%40proto-nexus%2Fproto-fields-plugin) |

## Installation

```sh
yarn add nexus graphql  # required as a peer dependency
yarn add --dev protoc-gen-nexus

# if you generate code with `protoc --js_out`
yarn add @proto-nexus/google-protobuf \
  google-protobuf @types/google-protobuf  # required as a peer dependency

# if you generate code with protobufjs
yarn add @proto-nexus/protobufjs \
  protobufjs  # required as a peer dependency
```

## Usage
### Generate GraphQL Types from Protobuf IDL

To generate Nexus type definitions from `.proto` files, you need to invoke following command:

```sh
protoc \
  -I ./node_modules/protoc-gen-nexus/include \
  -I <YOUR_PROTO_PATH> \
  --plugin=protoc-gen-nexus=`yarn bin protoc-gen-nexus` \
  --nexus_out=<DIST_DIR> \
  --nexus_opt="import_prefix=<YOUR_PROTO_PATH_OR_PACKAGE>" \
  path/to/file.proto
```

#### with protobufjs

proto-nexus supports protobufjs with static code generated by [protobufjs CLI](https://github.com/protobufjs/protobuf.js#command-line).

```sh
# `target`, `wrap` and `force-message` options are required.
# An output file name must be `index.js`.
pbjs \
  --target static-module \
  --wrap commonjs \
  --force-message \
  --path <YOUR_PROTO_PATH> \
  --out "<DIST_DIR>/index.js" \
  path/to/package/*.proto

# An output file name must be `index.d.ts`
pbts --out "<DIST_DIR>/index.d.ts" "<DIST_DIR>/index.js"
```

And `protoc-gen-nexus` requires `use_protobufjs` option.

```sh
  --nexus_opt="import_prefix=<YOUR_PROTO_PATH_OR_PACKAGE>,use_protobufjs" \
```


### Make schema
See also [Best Practices - GraphQL Nexus](https://nexusjs.org/docs/guides/best-practices#consistent-file-structure-for-graphql-type-imports).

```typescript
// src/schema/types/index.ts

// Export generated types
export * from "./path/to/generated_types/...";
export * from "./path/to/generated_types/...";
// ...
```

When `makeSchema`, `abstractTypeStrategies` must have `isTypeOf: true`.

```typescript
import { makeSchema } from "nexus";
import "@proto-nexus/google-protobuf";  //  should import runtime library
import * as allTypes from "./schema/types";

export const schema = makeSchema({
  types: alltypes,
  output: { /* ... */ },
  features: {
    abstractTypeStrategies: {
      isTypeOf: true,
    },
  },
})
```

## Author

- [Masayuki Izumi (@izumin5210)](https://github.com/izumin5210)

---
_Source: https://npm.io/package/protoc-gen-nexus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
