A GraphQL SDL formatter that sorts definitions, fields, arguments, and enums alphabetically (version 1.5.0). It works as both a CLI tool and a Node.js API, with options to control which sorting aspects are applied. Designed for predictable schema organization in large GraphQL projects. Notable differentiator: defaults to sorting all elements alphabetically, unlike prettier which only does basic formatting. Stable release with no recent updates.
npm install format-graphqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates formatting a GraphQL SDL string with default sort options, showing alphabetical ordering of types and fields.
Install graphql: npm install graphql
Use --write=true or --write=false, not --write
Accepts current behavior or use pre-processing before formatting
Change import to: import { formatSdl } from 'format-graphql'Install graphql: npm install graphql
Use --write=true or --write=false