gqlfix
v1.0.5
Published
CLI to fix deprecated GraphQL fields using schema guidance
Readme
gqlfix
A CLI tool that automatically replaces deprecated GraphQL fields in your code based on your schema, and optionally scans for deprecated usage.
What it does
- Scans
.ts,.tsx, and.graphqlfiles using glob patterns - Detects fields marked as
@deprecated(reason: "Use xyz instead")in your schema - Replaces or reports deprecated fields with their recommended alternatives
Installation
yarn add -D gqlfixOr with npm:
npm install --save-dev gqlfixUsage
🔧 Fix Deprecated Fields
npx gqlfix schema=path/to/schema.graphqlThis will:
- Parse the schema and identify fields with deprecation warnings that contain "Use XYZ instead"
- Search your project for
gqltemplate literals or.graphqlfiles - Automatically replace deprecated fields with their suggested alternatives
🔍 Check Deprecated Usages (No Edits)
npx gqlcheckThis will:
- Parse the same schema at
graphql/schema.graphql - List all deprecated field usages across your codebase with file and line information
- Exit with code 1 if any deprecated usage is found
Customizing Paths
If your GraphQL files live outside of src/, you can specify custom glob patterns using a config file.
Supported Config Formats
gqlfix.config.jsgqlfix.config.jsongqlfix.config.yaml.gqlfixrc- Or inside
package.json:
"gqlfix": {
"includePaths": ["src/**/*.ts", "queries/**/*.graphql"]
}Notes
- Works only for deprecations with a clear "Use X instead" reason
- Skips aliased fields to avoid breaking custom behavior
- Designed for codebases using
gqltemplate literals or.graphqlfiles
Example
Schema
type Product {
title: String @deprecated(reason: "Use displayName instead")
displayName: String
}Before
titleAfter
displayNameLicense
ISC
