PHPackages                             pawell67/graphql-formatter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. pawell67/graphql-formatter

ActiveLibrary

pawell67/graphql-formatter
==========================

Opinionated formatter for .gql and .graphql files

v0.1.6(1w ago)022↓100%1MITPHPPHP ^8.3CI passing

Since Mar 9Pushed 1w agoCompare

[ Source](https://github.com/pawell67/graphql-formatter)[ Packagist](https://packagist.org/packages/pawell67/graphql-formatter)[ RSS](/packages/pawell67-graphql-formatter/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (4)Versions (10)Used By (0)

graphql-formatter
=================

[](#graphql-formatter)

An opinionated formatter for `.gql` and `.graphql` files. Written in PHP, powered by `webonyx/graphql-php`.

Installation
------------

[](#installation)

```
composer require --dev pawell67/graphql-formatter
```

Usage
-----

[](#usage)

Add to your `composer.json` scripts:

```
"scripts": {
    "graphql-formatter:fix": "vendor/bin/graphql-formatter fix",
    "graphql-formatter:check": "vendor/bin/graphql-formatter check"
}
```

Then run:

```
composer graphql-formatter:fix    # format files in place
composer graphql-formatter:check  # exit 1 if any files need changes (CI)
```

Configuration
-------------

[](#configuration)

### Publish config (recommended)

[](#publish-config-recommended)

Use the built-in `publish-config` command to copy the example config to your project's `config/` directory:

```
vendor/bin/graphql-formatter publish-config
```

This copies `graphql-formatter.php` to `config/graphql-formatter.php` (Laravel convention).

If a config file already exists, you'll get a warning. Use `--force` to overwrite:

```
vendor/bin/graphql-formatter publish-config --force
```

To publish to a custom directory:

```
vendor/bin/graphql-formatter publish-config --target-dir /path/to/dir
```

### Config file location

[](#config-file-location)

The formatter looks for config in this order:

1. `config/graphql-formatter.php` (preferred — Laravel convention)
2. `graphql-formatter.php` in project root (legacy fallback)

If no config file is found, sensible defaults are used.

### Config options

[](#config-options)

Edit the published `config/graphql-formatter.php`:

```
