Socket
Socket
Sign inDemoInstall

graphql-prettier

Package Overview
Dependencies
2
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    graphql-prettier

Prettify & simplify GraphQL query/mutation/subscription.


Version published
Weekly downloads
4K
increased by184.12%
Maintainers
1
Install size
1.85 MB
Created
Weekly downloads
 

Readme

Source

GraphQL Prettier Codacy Badge Codacy Badge Build Status

Prettify & simplify GraphQL query/mutation/subscription.

Description

Package exports a default function which accepts two parameters:

prettify(source: string, noDuplicates = true): string

source is a string with GraphQL query/mutation/subscription to prettify

noDuplicates is a boolean value which set up to false turns out function to leaving duplicated fields

Install

npm install graphql-prettier

Usage

import gqlPrettier from 'graphql-prettier';

const query = `
query ViewerQuery {
  viewer {
    user {
      id
      name
      ...userFragment
    }
  }
}
fragment userFragment on User {
  id
  name
  email
}
`;

const prettifiedQuery = gqlPrettier(query); // returns string

Example

query ViewerQuery {
  viewer {
    user {
      id
      name
      id
      ...userFragment
      name
    }
  }
}
fragment userFragment on User {
  id
  name
  email
  name
}

Is transformed to:

query ViewerQuery {
  viewer {
    user {
      id
      name
      email
    }
  }
}

License

GraphQL Prettier is MIT-licensed.

Keywords

FAQs

Last updated on 04 Jul 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc