duplicate-operation-name
is a simple cli tool that makes it easy to check if there are any duplicate operation names in GraphQL projects that use static GraphQL queries.
It can be called on individual files, or recurisvely step through directories. It is compatible with .graphql
, .ts
, .tsx
, .js
, and .jsx
files.
npm install -g duplicate-operation-name
The build tool binary is called duplicate-operation-name
. Running it with no other arguments should give:
Usage: duplicate-operation-name <input_path> [--graphql] [--js] [--ts]
input_path: can be a directory or file path
flags: at least one must be passed in
If any duplicate operation names are found, the script will exit with an error and print:
Error: Found duplicate operation names:
3 x myOperationName1
2 x myOperationName2
If no duplicate operation names are found, the script will exit without error and print:
No duplicates found!
If no queries are found, the script will exit without error and print:
No queries found.
duplicate-operation-name queries.graphql --graphql
duplicate-operation-name src/index.ts --ts
duplicate-operation-name src/index.js --js
It is also possible to analyze a directory containing .graphql
, .ts.
, .tsx
, .js
and .jsx
files:
duplicate-operation-name src/ --graphql --ts --js
This is really just a repurposed version of https://github.com/apollographql/persistgraphql. Thanks to everyone who helped make that project happen.