Prettify & simplify GraphQL queries, mutations, and subscriptions by removing duplicate fields and formatting the output. Version 1.0.6 is the current stable release, with no recent updates or defined release cadence. It offers a simple function-based API with an optional noDuplicates parameter to control deduplication. Compared to general formatters like prettier with graphql plugin, this package focuses only on deduplication and basic indentation. Lightweight with no runtime dependencies.
npm install graphql-prettierNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates importing the default function and using it to deduplicate fields in a GraphQL query with fragments.
Explicitly pass noDuplicates: true to ensure deduplication, or omit the second argument.
Validate your GraphQL string with a proper parser like graphql-tag before passing to gqlPrettier.
Consider using prettier with graphql plugin or graphql-schema-utilities for more robust formatting.
Use import gqlPrettier from 'graphql-prettier' instead of const gqlPrettier = require('graphql-prettier').Add type: module to package.json or use dynamic import: const gqlPrettier = (await import('graphql-prettier')).default;No dependency data recorded yet.