🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

polen

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polen

A framework for delightful GraphQL developer portals

0.9.0
latest
Source
npm
Version published
Weekly downloads
469
-35.75%
Maintainers
1
Weekly downloads
 
Created
Source

Polen

A framework for delightful GraphQL developer portals ✨.

Installation

npm add polen

Quickstart

  • Have a schema.graphql GraphQL schema file in your project directory.

    type Query {
      hello: String
    }
    
  • Build your developer portal.

    npx polen build
    
  • You now have a deployable developer portal. Try it locally (http://localhost:3001):

    node build/app.js
    

Live Demos

Experience Polen in action with our live documentation sites:

🌐 View All Demos

Featured examples:

  • Pokemon GraphQL API - Explore a fun GraphQL API with rich schema documentation
  • GitHub GraphQL API (Coming soon) - Browse GitHub's extensive GraphQL API documentation

Demo Versions

Our demos are available at different stability levels, matching npm's dist tags:

  • Stable Release (latest): /polen/latest/pokemon

    • The most recent stable version (e.g., 1.0.0)
    • Same as npm install polen
  • Pre-release (next): /polen/next/pokemon

    • The latest pre-release version (e.g., 1.1.0-beta.1)
    • Same as npm install polen@next
  • Tagged Versions: Access any specific release

[!TIP] The correspondence between demo URLs and npm versions makes it easy to test features before upgrading. If you're using polen@1.0.0, visit /polen/1.0.0/pokemon to see exactly how your docs will look!

Examples

Find the source code for these demos and more in the examples directory.

Guide

Schema Reference

If you provide Polen with a schema, Polen will automatically render reference documentation for it.

If you provide multiple versions of your schema then the reference is based on the schema with the latest date.

Schema Changelog

Polen can render a changelog for your schema.

This feature is automatically enabled when you provide multiple versions of your schema. Refer to Provide a Schema for details on how to do that.

Schema Augmentations

Descriptions

You can append/prepend/replace descriptions of types and fields in your schema.

Any Markdown syntax in your content will be automatically rendered.

import { Polen } from 'polen'

export default Polen.defineConfig({
  templateVariables: {
    title: `Pokemon Developer Portal`,
  },
  schemaAugmentations: [
    {
      type: `description`,
      on: {
        type: `TargetType`,
        name: `Query`,
      },
      placement: `over`,
      content:
        `**Content from [Polen](https://github.com/the-guild-org/polen)**.`,
    },
  ],
})

Providing a Schema

You can provide a GraphQL schema to Polen in various ways.

File

Have a single schema.graphql SDL file in your project directory. Example:

schema.graphql

Directory

Have a schema directory in your project directory with multiple versions of your schema as SDL files named using format: YYYY-MM-DD.graphql. Example:

schema/
  2023-01-13.graphql
  2020-09-26.graphql

This approach allows Polen to render a changelog for your schema. Refer to Changelog.

Memory

You can provide a schema to Polen in memory via configuration.

You have control to provide one or multiple schemas, with or without dates.

If no dates are given then the current time is assumed.

If you provide multiple versions then Polen can render a changelog for you. Refer to Changelog.

Basic example:

// polen.config.ts
import { Polen } from 'polen'

export default Polen.defineConfig({
  schema: {
    useDataSources: `memory`,
    dataSources: {
      memory: {
        versions: [
          {
            date: new Date('2023-01-13'),
            value: `type Query { hello: String }`,
          },
        ],
      },
    },
  },
})

Pages

You can add pages to your developer portal by adding markdown (.md) or MDX (.mdx) files to a pages directory.

Routing

  • A file becomes a page.
  • The relative (to pages directory) file path becomes the web path.
  • Navigation Bar
    • Top level pages are listed in the navigation bar.
  • Index Pages
    • A file named index is an index page.
    • The file name is elided in the route. For example foo/index.md becomes route /foo .
    • Details:
      • If both foo/index.md and foo.md exist, then the former is used, latter ignored, and a warning is raised.

Example:

FileRouteNavigation Bar Title
pages/foo.md/fooFoo
pages/foo.mdx/fooFoo
pages/foo/index.md/fooFoo
pages/foo/index.mdx/fooFoo
pages/foo/bar.md/foo/barFoo
pages/foo/bar.mdx/foo/barFoo

Page Ordering

You can control the order of pages in the sidebar by prefixing file names with numbers followed by _ or -. The numeric prefix affects only the sidebar ordering - it does not appear in the page URL or title.

  • Syntax
    • Format: <number>_<name>.md or <number>-<name>.md
    • Examples: 01_intro.md, 10_getting-started.md, 20-configuration.md
  • Ordering
    • Pages with numeric prefixes appear before pages without prefixes
    • Pages are sorted by their numeric value (not alphabetically)
    • Pages without prefixes are sorted alphabetically after numbered pages
  • Collisions
    • If multiple files have the same name after removing the prefix (e.g., 10_about.md and 20_about.md), the file with the higher number is used
    • A warning is shown for collision conflicts

Example:

FileRouteSidebar TitleOrder
pages/10_getting-started.md/getting-startedGetting Started1st
pages/20_configuration.md/configurationConfiguration2nd
pages/30_advanced.md/advancedAdvanced3rd
pages/api-reference.md/api-referenceApi Reference4th
pages/troubleshooting.md/troubleshootingTroubleshooting5th

Markdown

Markdown files (.md) are supported using remark. This is the same underlying engine as MDX thus you can rely on consistent behavior between your .md and .mdx files.

Polen supports:

In the future you will be able to extend Polen in your project with additional Remark plugins. Track this feature in #64.

If you're new to Markdown, here are some great resources to get started:

Syntax features available to you include:

Via CommonMark:

  • Headers, paragraphs, and line breaks
  • Bold, italic, and code formatting
  • Lists (ordered and unordered)
  • Links and images
  • Code blocks with syntax highlighting
  • Blockquotes
  • Horizontal rules

Via GitHub Flavored Markdown:

  • Tables
  • Task lists
  • Strikethrough text
  • Autolinks

MDX

MDX begins where Markdown ends. So everything stated there such as regarding supported Markdown flavours applies here too.

MDX files (.mdx) allow you to use JSX/React components within your markdown content. This enables interactive documentation with live examples, custom components, and more.

Example MDX page:

# Interactive Documentation

import { Button } from "@radix-ui/themes";

This page demonstrates MDX features.

<Button onClick={() => alert("Hello from MDX!")}>Click me!</Button>

## Code Examples

You can mix markdown with React components for powerful documentation:

export const CodeExample = ({ language, code }) => (
  <pre>
    <code className={`language-${language}`}>{code}</code>
  </pre>
);

<CodeExample
  language="graphql"
  code={`
    query GetUser($id: ID!) {
      user(id: $id) {
        name
        email
      }
    }
  `}
/>

Build

When you build you may choose between SSG and SSR. The default is SSG.

SSG

npx polen build --type ssg

Deploy the contents of the ./build directory on your favourite static site provider.

SSR

In the future Polen will have features that motivate using a server, but for now there is no particular benefit. Use SSG instead.

Base Path Configuration

Polen supports deploying to subdirectories through the build.base configuration option. This is useful for:

  • GitHub Pages project sites (e.g., /my-project/)
  • PR preview deployments (e.g., /pr-123/)
  • Hosting multiple Polen sites on one domain
// polen.config.ts
import { Polen } from 'polen'

export default Polen.defineConfig({
  build: {
    base: '/my-project/', // Must start and end with /
  },
})

When configured, Polen will output differently:

  • For SSG architecture:
    • Generate static files that work in the subdirectory
  • For SSR architecture:
    • A server that serves static assets from the correct path

You can also set the base path via CLI:

npx polen build --base /my-project/
npx polen dev --base /my-project/

The CLI flag takes precedence over the config file setting.

Package

ESM

Polen is an ESM only package. If you are using CJS, then you need NodeJS version >=22.0.0 to require it.

Exports

You can import a Polen namespace from polen. You can import its bare exports from polen/polen.

import { Polen } from 'polen'
import { defineConfig } from 'polen/polen'

console.log(Polen.defineConfig === defineConfig) // true

Instant Schema Explorer

Polen comes with a light-weight command to instantly view any GraphQL schema.

Example:

npx polen open --name github

See docs for more details

npx polen open --help

Other

Changelog

Refer to releases on this repo.

Development

If you are working on Polen itself, then refer to DEVELOPMENT.md for details about workflow, testing, etc.

Keywords

graphql

FAQs

Package last updated on 13 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts