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

@tiagoboeing/gql-federation-schema-parser

v1.4.0

Published

CLI tool to parse GraphQL schemas and generate TypeScript definitions for use in a GraphQL Federation gateway.

Readme

GraphQL Federation Schema Parser

GitHub Release NPM Version

Table of Contents

Overview

This project provides a CLI tool to parse GraphQL schemas and generate federated GraphQL schemas for use in a GraphQL Federation gateway. All GraphQL types will be prefixed with the namespace and service name, allowing you to have multiple services under the same namespace without conflicts. Eg.: PlatformUsers__User, PlatformUsers__Post, etc.

Run it on a directory containing GraphQL schema files, and it will output a federated GraphQL schema to publish to Schema Registry. All schema files will be parsed and merged into a single schema scoped by a provided namespace and service name.

For what purpose should you use this tool?

  • Building a GraphQL supergraph: Use it to create a federated schema for a GraphQL gateway, allowing you to combine multiple services into a single schema and namespace them properly.

Quick Example

# Parse GraphQL schemas in the ./schemas directory
gql-federation-schema-parser parse -d ./schemas -s users -n platform

# This transforms your schemas into a federated format:
# User -> PlatformUsers__User
# Query.user -> Query.platform.users.user

Features

| Feature | Description | Supported | | -------------------------- | -------------------------------------------- | --------- | | Recursive schema parsing | Parses all .graphql files in a directory and its subdirectories | ✅ | | Type prefixing | Add namespace and service prefixes to types | ✅ | | Federation support | Generate federated query structures | ✅ | | Directive preservation | Maintain GraphQL directives in output | ✅ | | Multiple type support | Support for all GraphQL type kinds (scalars, enums, interfaces, unions, inputs, objects) | ✅ |

Usage

Commands

  • parse: Parses GraphQL schema files and generates federated GraphQL schemas.
  • help: Displays help information for the CLI tool.

Parse Command

The parse command requires the following parameters:

gql-federation-schema-parser parse [options]

Options:
  -d, --directory <path>     Directory containing GraphQL schema files
  -s, --service-name <name>  Service name for type prefixing
  -n, --namespace <name>     Namespace for grouping services
  -o, --output-file <file>   Output file name (optional)
  --write-to-file           Write output to file instead of stdout
  -D, --debug               Enable debug mode
  -S, --simple              Disable colors on terminal
  -h, --help                Display help for command

Example:

gql-federation-schema-parser parse -d ./schemas -s users -n platform

To get help on the CLI, run --help or -h on any command:

gql-federation-schema-parser --help
# or
gql-federation-schema-parser -h

# On a specific command
gql-federation-schema-parser parse --help
# or
gql-federation-schema-parser parse -h

Debug mode

You can enable debug mode to see detailed logs of the parsing process. This is useful for troubleshooting issues with schema files or understanding how the tool works.

Use -D or --debug on any command to enable global debug mode:

gql-federation-schema-parser parse -d ./schemas -s myService -n myScope -D
# or
gql-federation-schema-parser parse -d ./schemas -s myService -n myScope --debug

[!NOTE]

Debug mode is a global setting and will apply to all commands. It will log detailed information about the parsing process, including file paths, and other relevant information.

How it works

With the following schema files in a directory and these settings:

  • --service-name: users
  • --namespace: platform

The resulting GraphQL schema will be:

# Graphql root definitions
directive @oneOf on INPUT_OBJECT

scalar ID
scalar String
scalar Boolean

type PlatformUsers__Post {
  id: ID!
  content: String
  authorId: ID!
}

type PlatformUsers__User {
  id: ID!
  name: String
  email: String
}

type PlatformUsersQueries {
  posts: [PlatformUsers__Post!]!
  post(id: ID!): PlatformUsers__Post
  users: [PlatformUsers__User!]!
  getSubschemaData: String
}

type PlatformUsersMutations {
  createPost: PlatformUsers__Post!
}

type PlatformMutations {
  users: PlatformUsersMutations!
}

type PlatformQueries {
  users: PlatformUsersQueries!
}

type Mutation {
  platform: PlatformMutations!
}

type Query {
  platform: PlatformQueries!
}

In gateway you can query the schema like this:

query {
  platform {
    users {
      # Query, mutate or subscribe to your service operations
      ...
    }
  }
}

All GraphQL types will be prefixed with the namespace and service name, allowing you to have multiple services under the same namespace without conflicts. Eg.: PlatformUsers__User, PlatformUsers__Post, etc.

Installation

You can install the gql-federation-schema-parser CLI tool using one of the following methods:

  • Using NPM
  • On any platform with the pre-built binary

Using NPM

To install the CLI tool globally using NPM, run:

npm install -g @tiagoboeing/gql-federation-schema-parser
# or
pnpm install -g @tiagoboeing/gql-federation-schema-parser

After install, run:

gql-federation-schema-parser --help

Pre-built Binary

MacOS

On MacOS a warn will be shown when running the binary for the first time, indicating that it is from an unidentified developer. You can bypass this by following these steps:

# Download the latest release from the release page and unzip it
...

# Trust the binary and make it executable
xattr -d com.apple.quarantine gql-federation-schema-parser-macos
chmod +x gql-federation-schema-parser-macos

# Run the binary
./gql-federation-schema-parser-macos --help

Linux

On Linux, you can download the pre-built binary from the release page and run it directly:

# Download the latest release from the release page and unzip it
...
chmod +x gql-federation-schema-parser-macos

# Run the binary
./gql-federation-schema-parser-macos --help

Development

To develop this project, you will need Node.js and npm installed. Follow these steps to set up the development environment:

Testing CLI

To test the CLI, you can use tsx script on package.json to run the TypeScript code directly and debug in your IDE:

pnpm start:dev-ts src/index.ts [args]

[!NOTE]

On VSCode, run from a JavaScript Debug Terminal to enable debugging features like breakpoints and watch variables.

or you can use bun to run the TypeScript code (Bun debugger is buggy, so use it only if you don't need to debug):

pnpm start:dev 
# or
bun --watch src/index.ts

# Pass arguments to the script
pnpm start:dev ...args
# Example:
pnpm start:dev parse -d ./schemas -s users -n platform

Getting Help

For Users

  • Installation Issues: Check installation guide
  • Usage Questions: Review examples
  • CLI Help: Run gql-federation-schema-parser --help
  • Bug Reports: Create an issue on GitHub

For Developers

Example: on Yoga/Hive gateway, you can create a custom plugin to handle onFetch hook, capture the namespace and service name, and translate the query to the correct service operation overriding the setFetchFn() method.

Documentation

For more detailed information, check out the comprehensive documentation:

Quick links

Installation

You can install the gql-federation-schema-parser CLI tool using one of the following methods:

  • Using NPM
  • On any platform with the pre-built binary

Using NPM

To install the CLI tool globally using NPM, run:

npm install -g @tiagoboeing/gql-federation-schema-parser
# or
pnpm install -g @tiagoboeing/gql-federation-schema-parser

After install, run:

gql-federation-schema-parser --help

Pre-built Binary

MacOS

On MacOS a warn will be shown when running the binary for the first time, indicating that it is from an unidentified developer. You can bypass this by following these steps:

# Download the latest release from the release page and unzip it
...

# Trust the binary and make it executable
xattr -d com.apple.quarantine gql-federation-schema-parser-macos
chmod +x gql-federation-schema-parser-macos

# Run the binary
./gql-federation-schema-parser-macos --help

Linux

On Linux, you can download the pre-built binary from the release page and run it directly:

# Download the latest release from the release page and unzip it
...
chmod +x gql-federation-schema-parser-macos

# Run the binary
./gql-federation-schema-parser-macos --help

Development

To develop this project, you will need Node.js and npm installed. Follow these steps to set up the development environment:

Testing CLI

To test the CLI, you can use tsx script on package.json to run the TypeScript code directly and debug in your IDE:

pnpm start:dev-ts src/index.ts [args]

[!NOTE]

On VSCode, run from a JavaScript Debug Terminal to enable debugging features like breakpoints and watch variables.

or you can use bun to run the TypeScript code (Bun debugger is buggy, so use it only if you don't need to debug):

pnpm start:dev 
# or
bun --watch src/index.ts

# Pass arguments to the script
pnpm start:dev ...args
# Example:
pnpm start:dev parse -d ./schemas -s users -n platform

Getting Help

For Users

  • Installation issues: Check installation guide
  • Usage questions: Review examples
  • CLI help: Run gql-federation-schema-parser --help
  • Bug reports: Create an issue on GitHub

For Developers

Recent Changes

Check the CHANGELOG.md for recent updates and new features.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support