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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ponder-enrich-gql-docs-middleware

v0.1.3

Published

A middleware for Ponder that allows devs to enrich their GraphQL docs with docstrings

Downloads

1,486

Readme

Ponder GraphQL Documentation Middleware

A powerful middleware for enriching your Ponder GraphQL API documentation with detailed descriptions, making your API more discoverable and easier to use.

npm version License: MIT

Features

Easy Integration - Drop-in middleware for your Ponder GraphQL setup
📝 Rich Documentation - Add detailed descriptions to types, fields, and queries
🔄 Automatic Generation - Helper functions to generate common documentation patterns
🎯 Type Safety - Full TypeScript support with comprehensive type definitions
🚀 Zero Runtime Overhead - Only processes introspection queries
📦 Built-in Patterns - Common GraphQL patterns like pagination and filtering included

Installation

npm install ponder-enrich-gql-docs-middleware
# or
pnpm add ponder-enrich-gql-docs-middleware
# or
yarn add ponder-enrich-gql-docs-middleware

Quick Start

import {
  createDocumentationMiddleware,
  extendWithBaseDefinitions,
  generateFilterDocs,
  generatePageDocs,
} from "ponder-enrich-gql-docs-middleware";
import { ponder } from "ponder:registry";
import { graphql } from "ponder";

// Define your documentation
const docs = extendWithBaseDefinitions({
  // Define your types
  User: "Represents a user in the system",
  "User.email": "The user's email address",
  "User.name": "The user's full name",

  // Generate pagination documentation
  ...generatePageDocs("User", "user"),
});

// Add the middleware to your GraphQL endpoint
const middleware = createDocumentationMiddleware(docs);
ponder.use("/graphql", middleware);
ponder.use("/graphql", graphql());

Documentation Helpers

Base Definitions

The package includes common GraphQL definitions out of the box:

  • Standard scalar types (JSON, BigInt, Boolean, String, Int)
  • Pagination fields (hasNextPage, hasPreviousPage, startCursor, endCursor)
  • Query arguments (where, orderBy, orderDirection, before, after, limit)
  • Filter operators (equals, not, in, contains, starts_with, etc.)

Helper Functions

generatePageDocs(typeName, description)

Creates documentation for pagination-related fields:

const pageDocs = generatePageDocs("User", "system user");
// Generates docs for: UserPage, UserPage.items, UserPage.pageInfo, etc.

generateQueryDocs(typeName, description)

Generates documentation for standard query fields:

const queryDocs = generateQueryDocs("User", "system user");
// Generates docs for: User, Users, Users.where, Users.orderBy, etc.

generateTypeDocSet(typeName, description, fields)

Combines multiple documentation generators for a complete type:

const userDocs = generateTypeDocSet("User", "system user", {
  "User.email": "User email address",
  "User.name": "User full name",
});

Example Output

After adding the middleware, your GraphQL API documentation will be enriched in introspection queries, making it more readable in tools like GraphiQL:

# What tools like GraphiQL will show
type User {
  """
  The user's email address
  """
  email: String

  """
  The user's full name
  """
  name: String
}

Note: This middleware only affects the documentation returned in introspection queries. It does not modify your actual schema.graphql file or change any runtime behavior of your API.

Configuration Options

const middleware = createDocumentationMiddleware(docs, {
  debug: true, // Enable debug logging
  path: "/graphql", // GraphQL endpoint path
});

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development

  1. Clone the repository
  2. Install dependencies: pnpm install
  3. Run tests: pnpm test
  4. Check types: pnpm typecheck
  5. Lint code: pnpm lint

License

MIT © José Ribeiro