npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rachelallyson/prisma-pothos-inputs

v1.2.0

Published

Generate Pothos schema types from your Prisma schema — scalars, enums, WhereInput, OrderBy, FindManyArgs; Prisma-typed refs so you can pass args straight to the client.

Readme

@rachelallyson/prisma-pothos-inputs

npm version License: MIT

Generate Pothos schema types from your Prisma schema.
Scalars, enums, filters, OrderBy, FindManyArgs, Create/Update inputs — with optional Prisma-typed refs so you can pass args straight to the client. Built for Prisma v7 (works with v5/v6).


What it does

@rachelallyson/prisma-pothos-inputs reads your Prisma schema and emits TypeScript that registers types with your Pothos SchemaBuilder. You get:

  • Scalars — e.g. DateTime (extensible for JSON, etc.)
  • Enums — every Prisma enum plus a shared SortOrder (asc / desc)
  • Per-model input typesWhereInput, WhereUniqueInput (including compound uniques and compound primary keys @@id([a, b])), OrderByInput (object shape matching Prisma), FindManyArgs (where, orderBy, skip, take), CreateInput, UpdateInput
  • Relation-style create inputs (optional) — With useRelationInputs: true, create inputs use Prisma-style nested relations: author: { connect: { id } }, create: { ... }, connectOrCreate: { where, create } instead of raw FK fields like authorId. Ref types become Prisma.PostCreateInput when prismaClientPath is set.
  • Filter inputsStringFilter, IntFilter, DateTimeFilter, enum filters, list/relation filters so WhereInput matches Prisma’s shape

When you pass --prisma-client-path (or prismaClientPath in the API), the generated refs are typed as Prisma.UserCreateInput, Prisma.PostFindManyArgs, etc., so resolvers get correct types and you can spread args directly into the Prisma client.


Table of contents


Installation

npm install @rachelallyson/prisma-pothos-inputs

Requirements: Node.js 18+, a Prisma schema, and Pothos. The package uses @mrleebo/prisma-ast to parse your schema; no Prisma CLI is required at runtime.


Quick start

  1. Generate Pothos types (writes a single file that registers scalars, enums, and input types):
npx @rachelallyson/prisma-pothos-inputs --schema prisma/schema.prisma --output-pothos src/__generated__/pothos-inputs.ts
  1. Optional: type refs as Prisma so resolvers receive args.data / args.input as the correct Prisma types:
npx @rachelallyson/prisma-pothos-inputs --schema prisma/schema.prisma --output-pothos src/__generated__/pothos-inputs.ts --prisma-client-path ../../generated/prisma/client.js

Use a path relative to the generated file so the import resolves.

  1. In your Pothos schema: call registerPothosTypes(builder) and use the returned refs for args (e.g. refs.UserCreateInputType, refs.PostFindManyArgs). With prismaClientPath set, you can pass args straight to Prisma (e.g. prisma.post.findMany({ ...query, ...(args.input ?? {}) })).

Usage

CLI

| Option | Description | |--------|-------------| | --schema <path> | Path to Prisma schema file. Default: prisma/schema.prisma. | | --output-pothos <path> | Write Pothos types (scalars, enums, input types) to this file. | | --prisma-client-path <path> | Path to Prisma client for typed input refs. Use with --output-pothos. | | --use-relation-inputs | Use connect/create/connectOrCreate nested inputs instead of FK scalars. Use with --output-pothos. | | --output-pothos-enums <path> | Write Pothos enum registration only to this file. | | --help, -h | Print usage and exit. |

You must specify at least one of --output-pothos or --output-pothos-enums.

Examples:

# Full Pothos types
npx @rachelallyson/prisma-pothos-inputs --output-pothos src/__generated__/pothos-inputs.ts

# With Prisma-typed refs
npx @rachelallyson/prisma-pothos-inputs --output-pothos src/__generated__/pothos-inputs.ts --prisma-client-path ../../generated/prisma/client.js

# Enums only
npx @rachelallyson/prisma-pothos-inputs --output-pothos-enums src/__generated__/pothos-enums.ts

Programmatic API

One-shot: schema string → Pothos TypeScript

import { generatePothosFromSchema } from '@rachelallyson/prisma-pothos-inputs';
import { readFileSync } from 'fs';

const schemaSource = readFileSync('prisma/schema.prisma', 'utf-8');
const ts = generatePothosFromSchema(schemaSource, {
  prismaClientPath: '../../generated/prisma/client.js', // optional
  useRelationInputs: true, // optional: connect/create/connectOrCreate instead of FK scalars
});

Two-step: parse then generate

import { parsePrismaSchema, generatePothosSchema } from '@rachelallyson/prisma-pothos-inputs';

const normalized = parsePrismaSchema(schemaSource);
const ts = generatePothosSchema(normalized, { prismaClientPath: '...' });

Exports:

  • generatePothosFromSchema(schemaSource, options?) — Parse + generate in one call.
  • Options (GeneratePothosSchemaOptions): prismaClientPath? — path to Prisma client for typed refs; useRelationInputs? (default false) — when true, CreateInput uses nested relation inputs (connect, create, connectOrCreate) and omits FK scalars, and refs are typed as Prisma.PostCreateInput etc.
  • writePothosInputs(options)Async. Read schema from disk, generate, and write the file. Use at server startup so you don’t need a separate generate script (see below).
  • parsePrismaSchema(schemaSource) — Parse only; returns NormalizedSchema (models + enums).
  • generatePothosSchema(normalized, options?) — Generate from a NormalizedSchema.
  • generatePothosEnums(normalized) — Enum registration only.
  • Types: NormalizedSchema, NormalizedModel, NormalizedEnum, GeneratePothosSchemaOptions, WritePothosInputsOptions, PothosEnumBuilder.
  • PRISMA_SCALAR_TO_GRAPHQL, CUSTOM_SCALARS — Mapping and scalar names.

Generate at server startup

Generate the Pothos inputs file when the server starts so you don’t need a separate script. Call writePothosInputs before importing your schema:

// server.ts or index.ts — entry point
import { writePothosInputs } from '@rachelallyson/prisma-pothos-inputs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';

const __dirname = dirname(fileURLToPath(import.meta.url));

await writePothosInputs({
  schemaPath: join(__dirname, 'prisma/schema.prisma'),
  outputPath: join(__dirname, 'src/__generated__/pothos-inputs.ts'),
  prismaClientPath: '../../generated/prisma/client.js',
  cwd: join(__dirname, '..'), // optional; defaults to process.cwd()
});

const { schema } = await import('./src/schema.js');
// Start your GraphQL server with schema...

Run the entry point with tsx (or similar) so the newly written file is loaded when the schema module is imported.


Build integration

Run after Prisma generate:

{
  "scripts": {
    "generate": "prisma generate && npx @rachelallyson/prisma-pothos-inputs --schema prisma/schema.prisma --output-pothos src/__generated__/pothos-inputs.ts --prisma-client-path ../../generated/prisma/client.js"
  }
}

See docs/EXAMPLES.md for the full Pothos example.


What gets generated

With --output-pothos you get a single file that exports registerPothosTypes(builder). It:

  • Registers scalars (e.g. DateTime).
  • Registers enums: each Prisma enum (e.g. Role) and a shared SortOrder (asc, desc).
  • Registers per-model input types:
    • OrderByInput — one optional SortOrder field per sortable column (same shape as Prisma; pass orderBy: args.orderBy).
    • FindManyArgs — optional where, orderBy, skip, take (single input so you can ...(args.input ?? {})).
    • WhereInput / WhereUniqueInput — AND/OR/NOT plus scalar and relation filters; compound uniques for @@unique([a, b]) and compound primary keys @@id([a, b]).
    • CreateInput / UpdateInput — scalar and enum fields (relations via foreign keys where applicable).

When --prisma-client-path is set, the return type of registerPothosTypes declares refs as InputTypeRef<..., Prisma.UserCreateInput>, etc., so Pothos infers correct types in resolvers.


Documentation

Full docs: rachelallyson.github.io/prisma-pothos-inputs

  • Getting started — Install, first run, wiring into your Pothos schema.
  • API reference — Programmatic API and options.
  • Examples — Scripts, direct args, generate at startup.
  • Type mapping — Prisma → GraphQL mapping.

Testing

npm test

Runs the test suite (Node’s built-in test runner) after building. Tests cover parsing, Pothos schema generation (with and without prismaClientPath), and enums.


License

MIT