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

@ttoss/graphql-api-cli

v0.9.9

Published

A library for building GraphQL APIs types and schema.

Readme

@ttoss/graphql-api-cli

CLI tool that generates GraphQL schemas and TypeScript types from your @ttoss/graphql-api schema composer, enabling seamless integration with Relay and providing type safety for your GraphQL operations.

Installation

pnpm add -D @ttoss/graphql-api-cli

Core Functionality

This CLI is essential for GraphQL development workflows using the ttoss ecosystem, providing automated generation of:

  • GraphQL Schema (SDL): Creates schema/schema.graphql file required for Relay introspection queries
  • TypeScript Types: Generates schema/types.ts with strongly-typed interfaces for your GraphQL schema
  • Development Integration: Seamlessly integrates with your build pipeline and development workflow

The tool operates by importing your schemaComposer.ts file, extracting the schema definition, and generating both the SDL schema file and corresponding TypeScript types using GraphQL Code Generator.

Basic Usage

ttoss-graphql-api build-schema

Add the build script to your package.json for easy integration:

{
  "scripts": {
    "build-schema": "ttoss-graphql-api build-schema"
  }
}

This command:

  1. Reads your src/schemaComposer.ts file
  2. Bundles it using esbuild to resolve all dependencies
  3. Extracts the schema definition using the schemaComposer
  4. Generates schema/schema.graphql in SDL format
  5. Creates schema/types.ts with TypeScript type definitions

Command Options

Schema Composer Directory (-d, --directory)

Specify a custom directory for your schemaComposer.ts file:

ttoss-graphql-api build-schema -d src/graphql
ttoss-graphql-api build-schema --directory tests

Default: src

External Dependencies (--external)

Control which additional dependencies are marked as external during the bundling process:

ttoss-graphql-api build-schema --external graphql-compose,@aws-sdk/client-dynamodb

Default behavior: Automatically excludes all package.json dependencies (except workspace packages and graphql) and appends any specified external dependencies to this list. Workspace dependencies (those with workspace: prefix) are automatically excluded from external handling to prevent bundling issues in monorepo environments. The graphql dependency is always bundled to avoid dynamic require errors.

Integration Examples

Basic Project Structure

my-graphql-api/
├── schema/                   # Generated files
│   ├── schema.graphql        # SDL schema
│   └── types.ts              # TypeScript types
├── src/
│   ├── schemaComposer.ts     # Your schema definition
│   └── modules/              # GraphQL modules
└── package.json

Schema Composer Example

// src/schemaComposer.ts
import { schemaComposer } from '@ttoss/graphql-api';
import './modules/User/composer';
import './modules/Post/composer';

export { schemaComposer };

Advanced Configuration

For complex projects requiring specific external handling:

# Custom directory with specific externals
ttoss-graphql-api build-schema \
  --directory src/api \
  --external graphql-compose,dataloader,aws-sdk

CI/CD Integration

{
  "scripts": {
    "build": "pnpm build-schema && pnpm compile",
    "build-schema": "ttoss-graphql-api build-schema",
    "dev": "pnpm build-schema && tsx watch server.ts"
  }
}

Technical Details

ESM Only: This package is ESM only and requires Node.js with ES modules support.

Bundling Process: Uses esbuild to bundle your schema composer and its dependencies, ensuring all imports are resolved correctly before schema extraction. Automatically excludes all package.json dependencies as external (except workspace packages and graphql), with support for additional external dependencies via the --external option. The graphql package is always bundled to prevent "Dynamic require of 'graphql' is not supported" errors.

Workspace Dependencies: Dependencies with workspace: prefix are automatically excluded from external handling to prevent TypeScript import errors in monorepo environments where workspace packages may export .ts files directly.

Type Generation: Leverages @graphql-codegen/typescript for precise TypeScript type generation with interface declarations and preserved naming conventions.

Related Packages