Skip to content

GraphQL CLI to prune, filter, pick, select, and distill a sub-schema when given a Schema Definition Language (SDL) file. 🪛

License

Notifications You must be signed in to change notification settings

kevinmichaelchen/graphql-schema-picker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-schema-picker

GoReportCard example version Code Climate maintainability

A CLI for selectively pruning your GraphQL schemas.

The CLI accepts a Schema Definition Language file, and then selectively picks (or filters out) certain elements.

Motivation

This tool was born out of a desire to reuse Hasura's schema in upstream microservices. In my case, it meant discarding the tens of thousands of lines in the schema that was introspected from Hasura, and really only paying attention to the few types I cared about.

Example

For a realistic example of what a Hasura GraphQL schema looks like, check out our example SDL file (Schema Definition Language).

Getting Started

Installing

Eventually, I may package this up in pkgx and maybe even Homebrew (via Goreleaser).

With go install

go install github.com/kevinmichaelchen/graphql-schema-picker@latest

With Docker

docker pull ghcr.io/kevinmichaelchen/graphql-schema-picker
docker run --rm ghcr.io/kevinmichaelchen/graphql-schema-picker --help

docker run --rm \
  -v $(pwd)/examples:/examples \
  ghcr.io/kevinmichaelchen/graphql-schema-picker \
    --debug \
    pick \
      --output /examples/pruned.sdl.graphqls \
      --sdl-file /examples/hasura.sdl.graphqls \
      --definitions Aircrafts

Similar Tools

Contributing

Building

go run cmd/graphql-schema-picker/main.go \
  --debug \
  pick \
    --config examples/config.toml \
    --sdl-file examples/hasura.sdl.graphqls \
    --output examples/pruned.sdl.graphqls \
    --definitions Aircrafts,AircraftsInsertInput

Releasing

Follow Conventional Commits and SemVer releases should happen automatically via GitHub Actions.

Tasks

build

Builds the Go program into a local binary.

pkgx goreleaser build --clean --single-target

About

GraphQL CLI to prune, filter, pick, select, and distill a sub-schema when given a Schema Definition Language (SDL) file. 🪛

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •  

Languages