A static analysis tool for GraphQL projects.
npm install duplicate-operation-nameduplicate-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.
shell
npm install -g duplicate-operation-name
`Usage
The build tool binary is called
duplicate-operation-name. Running it with no other arguments should give:`
Usage: duplicate-operation-name [--graphql] [--js] [--ts]
`input_path: can be a directory or file path
flags: at least one must be passed in
$3
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.
`
$3
`shell
duplicate-operation-name queries.graphql --graphql
`$3
`shell
duplicate-operation-name src/index.ts --ts
`$3
`shell
duplicate-operation-name src/index.js --js
`
$3
It is also possible to analyze a directory containing .graphql, .ts., .tsx, .js and .jsx files:`shell
duplicate-operation-name src/ --graphql --ts --js
``