Skip to content

jane/gql-compress

Repository files navigation

gql-compress

Shrink your GraphQL

npm version](https://npm.im/gql-compress) CircleCI Coverage Status


Installation

npm i gql-compress

Usage

import compress from 'gql-compress'

const uncompressed = `
  query {
    repository(owner:"octocat", name:"Hello-World") {
      issues(last:20, states:CLOSED) {
        edges {
          node {
            title
            url
            labels(first:5) {
              edges {
                node {
                  name
                }
              }
            }
          }
        }
      }
    }
  }
` // 357 bytes

const compressed = compress(uncompressed) // 147 bytes
// outputs: "query{repository(owner:\"octocat\",name:\"Hello-World\"){issues(last:20,states:CLOSED){edges{node{title url labels(first:5){edges{node{name}}}}}}}}"

Example from GitHub.

MIT