@proto-nexus/proto-fields-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.5.3 • Public • Published

@proto-nexus/proto-fields-plugin

npm version |

Nexus plugin for building subset types from proto-nexus's artifacts

// profile.proto

message Profile {
  // Required. User's first name.
  string first_name = 1;
  // Required. User's middle name.
  string middle_name = 2;
  // Required. User's last name.
  string last_name = 3;

  // Required.
  string introduction = 4;
}
import { makeSchema, inputObjectType } from "nexus";
import { protoFieldsPlugin } from "@proto-nexus/proto-fields-plugin";

import { ProfileInput } from "./path/to/protoc-gen-plugin-artifacts/profile_pb_nexus.ts";

const NameInput = inputObjectType({
  name: "NameInput",
  definition(t) {
    t.fromProto(ProfileInput, ["firstName", "middleName", "lastName"]);
  }
})

export schema = makeSchema({
  types: [ProfileInput, NameInput],
  plugins: [protoFieldsPlugin()],
})

// # Types will be generated:
//
// input NameInput {
//   """Required. User's first name."""
//   firstName: String!
//
//   """Required. User's middle name."""
//   middleName: String!
//
//   """Required. User's last name."""
//   lastName: String!
// }
//
// input ProfileInput {
//   """Required. User's first name."""
//   firstName: String!
//
//   """Required. User's middle name."""
//   middleName: String!
//
//   """Required. User's last name."""
//   lastName: String!
//
//   """Required."""
//   introduction: String!
// }

Package Sidebar

Install

npm i @proto-nexus/proto-fields-plugin

Weekly Downloads

0

Version

0.5.3

License

MIT

Unpacked Size

8.36 kB

Total Files

16

Last publish

Collaborators

  • izumin5210