Registry / web-framework / ponder-enrich-gql-docs-middleware

ponder-enrich-gql-docs-middleware

JSON →
library0.1.3jsnpmunverified

This package, `ponder-enrich-gql-docs-middleware`, provides a middleware for Ponder-based GraphQL APIs, enabling developers to augment their GraphQL documentation with detailed docstrings for types, fields, and queries. Currently at version `0.1.3`, it is in active development with a consistent release of minor versions, indicating potential breaking changes between `0.x.x` releases as it approaches a stable 1.0. Its core value lies in enhancing API discoverability and usability by enriching introspection query results with human-readable descriptions, without modifying the underlying GraphQL schema or affecting runtime performance. Key differentiators include its seamless integration into the Ponder ecosystem, comprehensive TypeScript support, zero runtime overhead due to its introspection-only processing, and a suite of helper functions for automatically generating common documentation patterns like pagination and filtering, significantly reducing manual documentation effort.

npm install ponder-enrich-gql-docs-middleware
INSTALL
IMPORT
SIG · PONDER-ENRICH-GQL-
P
ponder-enrich-gql-docs-middleware
web-frameworkjavascriptv0.1.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createDocumentationMiddleware
import { createDocumentationMiddleware } from 'ponder-enrich-gql-docs-middleware';
const { createDocumentationMiddleware } = require('ponder-enrich-gql-docs-middleware');
Primary export for initializing the middleware. Prefer ESM imports given the package's TypeScript nature.
extendWithBaseDefinitions
import { extendWithBaseDefinitions } from 'ponder-enrich-gql-docs-middleware';
import extendWithBaseDefinitions from 'ponder-enrich-gql-docs-middleware/extendWithBaseDefinitions';
Helper function for applying common GraphQL definitions. This is a named export, not a default.
generatePageDocs
import { generatePageDocs } from 'ponder-enrich-gql-docs-middleware';
import * as docHelpers from 'ponder-enrich-gql-docs-middleware'; docHelpers.generatePageDocs();
Helper function to generate documentation for pagination. Destructuring directly is cleaner.
generateFilterDocs
import { generateFilterDocs } from 'ponder-enrich-gql-docs-middleware';
Helper function for generating documentation for filter arguments.

Demonstrates how to initialize the documentation middleware with custom and generated docstrings and apply it to a Ponder GraphQL endpoint. It includes basic type definitions and dynamic pagination documentation.

import { createDocumentationMiddleware, extendWithBaseDefinitions, generatePageDocs } from "ponder-enrich-gql-docs-middleware"; import { ponder } from "ponder:registry"; import { graphql } from "ponder"; // Define your documentation object with base definitions and generated pagination docs const docs = extendWithBaseDefinitions({ // Define specific type and field descriptions User: "Represents a user in the system", "User.email": "The user's email address", "User.name": "The user's full name", // Dynamically generate documentation for pagination on the 'User' type ...generatePageDocs("User", "user"), }); // Initialize the documentation middleware with the defined documentation const docMiddleware = createDocumentationMiddleware(docs, { debug: false }); // Apply the documentation middleware and then the Ponder GraphQL handler to your /graphql endpoint // The order is important: middleware first, then the actual GraphQL handler ponder.use("/graphql", docMiddleware); ponder.use("/graphql", graphql()); console.log('Ponder GraphQL endpoint enriched with documentation middleware.');
Debug
Known issues
breakingAs a 0.x.x package, `ponder-enrich-gql-docs-middleware` may introduce breaking changes in minor versions (e.g., 0.1.x to 0.2.x) without prior major version increments. Users should pin exact versions or review changelogs carefully during upgrades.
fix
Review release notes before updating minor versions; consider pinning exact versions (`~0.1.x` instead of `^0.1.x`) in production to prevent unexpected breaking changes.
affects: >=0.1.0
gotchaIncorrect versions of `graphql` or `hono` (peer dependencies) can lead to runtime errors or unexpected behavior due to API mismatches. Ensure your project's installed versions satisfy the specified peer dependency ranges.
fix
Check your `package.json` for `graphql` and `hono` and ensure they match the peer dependency requirements of `ponder-enrich-gql-docs-middleware` and Ponder itself. Run `npm install` or `pnpm install` after modifying dependencies.
affects: >=0.1.0
gotchaThis middleware exclusively modifies the documentation returned by introspection queries; it does not alter your `schema.graphql` file or affect the runtime behavior of your GraphQL API. Applications relying on runtime schema modifications or code generation from a modified schema will not see these documentation changes.
fix
Understand that the documentation enhancements are only visible in GraphQL tools like GraphiQL or Playground that utilize introspection. If you require schema changes, you must modify your `schema.graphql` directly.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'use')
The `ponder` object from `ponder:registry` is not correctly imported or initialized, or the `ponder` instance is not available in the current scope when the middleware is applied.
fix
Ensure `import { ponder } from "ponder:registry";` is present and `ponder` is correctly configured and available before calling `ponder.use()`.
Error: Cannot find module 'ponder:registry'
This error typically means the Ponder project setup is incomplete, or the bundler/runtime cannot resolve Ponder's virtual modules. Ponder relies on a specific project structure and runtime environment.
fix
Verify your Ponder installation and configuration. Ensure your `ponder.config.ts` is valid and the `ponder` CLI has been run to generate necessary files. This often happens if Ponder is not running or misconfigured, or if your build system doesn't support Ponder's virtual modules.
Error: GraphQL Schema validation error: Unknown type "MyCustomType" (or similar 'field not found' errors)
The documentation middleware attempts to add documentation for a type or field name that does not exist in the actual Ponder GraphQL schema.
fix
Review your `docs` object passed to `createDocumentationMiddleware` and ensure all type and field names (e.g., `"User"`, `"User.email"`) precisely match the definitions within your `schema.graphql` and the schema Ponder generates at runtime.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
graphqlrequiredRequired for GraphQL schema introspection and manipulation. This is a peer dependency of the middleware.
honorequiredPonder uses Hono for its HTTP server. This middleware integrates with Hono's middleware system as a peer dependency.
Agent activity
2 hits · last 30 days
node
2
Resources
ponder-enrich-gql-docs-middleware — npm install ponder-enrich-gql-docs-middleware · libregistry