Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/graphql-linting.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,30 @@ The custom GraphQL linter includes the following built-in rules:
| `no-duplicate-fields` | error | Prevent duplicate field definitions |
| `require-description` | warn | Require descriptions for types/fields |
| `require-deprecation-reason` | warn | Require reason for deprecated fields |
| `field-naming-convention` | warn | Enforce camelCase field naming |
| `root-fields-nullable` | warn | Suggest nullable root field types |

### Pagination Rules

| Rule | Severity | Description |
| ------------------------------ | -------- | ---------------------------------------------- |
| `connection-structure` | error | Ensure Connection types have edges/pageInfo |
| `edge-structure` | error | Ensure Edge types have node/cursor fields |
| `connection-arguments` | warn | Suggest pagination arguments for connections |
| `pagination-argument-types` | error | Enforce correct types for pagination arguments |

### Rule Details

- **no-anonymous-operations**: Ensures all GraphQL operations (queries, mutations, subscriptions) have names
- **no-duplicate-fields**: Prevents duplicate field definitions within the same type
- **require-description**: Suggests adding descriptions to types and fields for better documentation
- **require-deprecation-reason**: Ensures deprecated fields include a reason for deprecation
- **field-naming-convention**: Enforces camelCase naming for field names (ignores special fields like `__typename`)
- **root-fields-nullable**: Suggests making root type fields nullable for better error handling
- **connection-structure**: Ensures Connection types follow the Relay pagination pattern with `edges` and `pageInfo` fields
- **edge-structure**: Ensures Edge types have the required `node` and `cursor` fields
- **connection-arguments**: Suggests adding `first` and `after` arguments to fields returning Connection types
- **pagination-argument-types**: Enforces correct types for pagination arguments (`first: Int!`, `after: String`)

## Usage

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
"watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"package": "npm run check-types && npm run lint && node esbuild.js --production",
"compile-tests": "tsc -p . --outDir out",
"compile-tests": "tsc -p . --outDir out && mkdir -p out/test/fixtures && cp -r src/test/fixtures/* out/test/fixtures/",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"check-types": "tsc --noEmit",
Expand Down
Loading