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

@vyrel/morph

v0.0.8

Published

Vyrel morph

Readme

@vyrel/morph

Bridge Zod row schemas to Pothos GraphQL fields, args, and inputs.

Use it to derive GraphQL object fields, list filters, and input shapes from Zod models without hand-mapping every column.

Install

bun install @vyrel/morph

Peer dependencies:

bun install @pothos/core @pothos/plugin-validation @pothos/plugin-with-input zod

Quick start

import SchemaBuilder from "@pothos/core";
import ValidationPlugin from "@pothos/plugin-validation";
import WithInputPlugin from "@pothos/plugin-with-input";
import { initializeDrizzleGraphqlBridge } from "@vyrel/morph";
import { z } from "zod/v4";

const builder = new SchemaBuilder({
  plugins: [ValidationPlugin, WithInputPlugin],
});

const bridge = initializeDrizzleGraphqlBridge(builder, {
  defaultIdFields: ["id", "orgId"],
  unmappedFields: "throw",
});

const userRowSchema = z.object({
  id: z.string(),
  active: z.boolean(),
  role: z.enum(["admin", "member"]),
});

const userGraphql = bridge.model({
  objectName: "User",
  rowSchema: userRowSchema,
  listArgsSchema: {
    filters: z.object({
      role: z.enum(["admin", "member"]),
    }),
  },
});

const User = builder.objectRef<z.infer<typeof userRowSchema>>("User");

builder.objectType(User, {
  fields: (t) => userGraphql.exposeFields(t),
});

API

initializeDrizzleGraphqlBridge(builder, options?)

Creates a bridge bound to your Pothos builder.

Options:

  • defaultIdFields — columns exposed as GraphQL ID (default: none; bridge defaults to ["id", "orgId"] when omitted in model config)
  • defaultEnumName — naming strategy for generated enums
  • scalarTypes — extra scalar names registered on the builder
  • unmappedFields"throw", "warn", or "omit" when a Zod field cannot map to GraphQL

Returns:

  • bridge.model(config) — model helpers for a Zod row schema
  • bridge.fields(config) — alias of model
  • bridge.inputsFrom(schema, options?) — shared input mapper

bridge.model(config)

  • rowSchema — Zod object schema for the row
  • objectName — GraphQL type name used for enum registration
  • exclude — row keys omitted from GraphQL exposure
  • idFields — override ID columns for this model
  • listArgsSchema — named Zod schemas converted to query/list args
  • extraEnums / extraEnumsFrom — register additional enum sources
  • computedEnumFields — resolver-backed enum fields

Model helpers:

  • exposeFields(t, options?) — map row columns to Pothos object fields
  • inputsFrom(schema, options?) — map a Zod schema to input fields
  • argsFrom(schema, options?) — map a Zod schema to field args
  • args — pre-built args when listArgsSchema is configured

Mapping behavior

  • z.string()String, or ID when the key is listed in idFields
  • z.boolean()Boolean
  • z.enum() / z.literal() → generated GraphQL enums
  • nullable and optional Zod fields → nullable GraphQL fields
  • Zod .describe() → GraphQL field descriptions

Unmapped Zod types follow unmappedFields (throw by default).

License

MIT