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

elixir-document-nodes

v1.0.4

Published

GraphQL Code Generator plugin for generating Elixir modules with embedded GraphQL document nodes

Readme

Elixir Document Nodes Plugin

A GraphQL Code Generator plugin that generates Elixir modules with embedded GraphQL document nodes. This plugin helps you integrate GraphQL operations seamlessly into your Elixir codebase.

This plugin is a fork of GraphQL Code Generator with added support for Elixir document nodes generation. The original project is maintained by The Guild and has support for multiple languages and frameworks.

Installation

You can install the plugin using npm, yarn, or pnpm:

# npm
npm install --save-dev elixir-document-nodes

# yarn
yarn add -D elixir-document-nodes

# pnpm
pnpm add -D elixir-document-nodes

Requirements

  • Node.js >= 16
  • GraphQL >= 14.0.0
  • A running GraphQL server (for schema introspection)
  • Elixir/Mix (for formatting generated files)

Usage

Basic Setup

Create a codegen.ts configuration file in your project root:

import type { CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
  schema: "schema.graphql",
  documents: "graphql/**/*.graphql",
  generates: {
    "./lib/generated/graphql.ex": {
      plugins: ["elixir-document-nodes"],
    },
  },
};

export default config;

Advanced Configuration

Here's a more comprehensive example with all available options:

import type { CodegenConfig } from "@graphql-codegen/cli";
import { execSync } from "child_process";

const config: CodegenConfig = {
  overwrite: true,
  schema: "http://localhost:4000/graphql", // Your GraphQL schema endpoint
  documents: "graphql/**/*.graphql", // Path to your GraphQL operations
  generates: {
    // Generate schema for reference
    "./schema.graphql": {
      plugins: ["schema-ast"],
    },
    // Generate Elixir modules
    "./lib/generated/graphql.ex": {
      plugins: ["elixir-document-nodes"],
      config: {
        // Convert GraphQL names to snake_case (Elixir convention)
        namingConvention: "change-case-all#snakeCase",
        // Your target Elixir module name
        moduleName: "MyApp.GraphQL.Documents",
        // Add more configuration options here
      },
      // Format the generated Elixir code using mix format
      hooks: {
        afterOneFileWrite: (filePath) => {
          try {
            execSync(`mix format ${filePath}`);
            console.log(`✨ Formatted ${filePath}`);
          } catch (error) {
            console.error(`Error formatting file: ${error}`);
          }
        },
      },
    },
  },
};

export default config;

Configuration Options

| Option | Type | Default | Description | | ------------------ | ----------- | ----------------------------- | ----------------------------------------------- | | moduleName | string | "GraphQL.Documents" | The name of the generated Elixir module | | namingConvention | string | "change-case-all#snakeCase" | The naming convention for generated identifiers | | scalars | ScalarMap | {} | Custom scalar type mappings |

Example Output

For a GraphQL query like:

query GetUser($id: ID!) {
  user(id: $id) {
    id
    name
    email
  }
}

The plugin generates an Elixir module like:

defmodule MyApp.GraphQL.Documents do
  @moduledoc """
  Generated GraphQL document nodes.
  """

  def get_user do
    """
    query GetUser($id: ID!) {
      user(id: $id) {
        id
        name
        email
      }
    }
    """
  end
end

Running Code Generation

# Using npx
npx graphql-codegen

# Or if you have it in your package.json scripts
npm run codegen

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues

If you find a bug or have a feature request, please create an issue in the GitHub repository.