# duplicate-operation-name

> A static analysis tool for GraphQL projects.

Latest version **1.0.0** (published 2021-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install duplicate-operation-name
pnpm add duplicate-operation-name
yarn add duplicate-operation-name
bun add duplicate-operation-name
```

Provides the command `duplicate-operation-name`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-04-29 |
| First published | 2019-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 5 |
| Unpacked size | 37 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | nathan-schwartz |

## Links

- npm: https://www.npmjs.com/package/duplicate-operation-name
- Repository: https://github.com/Nathan-Schwartz/duplicate-operation-name
- Homepage: https://github.com/Nathan-Schwartz/duplicate-operation-name#readme
- Issues: https://github.com/Nathan-Schwartz/duplicate-operation-name/issues
- npm.io page: https://npm.io/package/duplicate-operation-name

## Dependencies (5)

- [yargs](https://npm.io/package/yargs.md) ^16.2.0
- [graphql](https://npm.io/package/graphql.md) ^15.5.0
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.11.0
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2
- [@types/lodash.merge](https://npm.io/package/@types/lodash.merge.md) ^4.6.6

## Recent versions

- 1.0.0 (latest) — 2021-04-29
- 0.0.1 — 2019-02-06

## README

# Duplicate GraphQL Operation Names

`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.


# Installation
```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 <input_path> [--graphql] [--js] [--ts]
```

**input_path**: can be a directory or file path

**flags**: at least one must be passed in

### Results

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.
```


### Analyzing Queries in GraphQL files (.graphql)

```shell
duplicate-operation-name queries.graphql --graphql
```

### Analyzing Queries in TypeScript files (.ts, .tsx)

```shell
duplicate-operation-name src/index.ts --ts
```

### Analyzing Queries in JavaScript files (.js, .jsx)

```shell
duplicate-operation-name src/index.js --js
```


### Analyzing Queries from Folders
It is also possible to analyze a directory containing `.graphql`, `.ts.`, `.tsx`, `.js` and `.jsx` files:

```shell
duplicate-operation-name src/ --graphql --ts --js
```

# Acknowledgements
This is really just a repurposed version of https://github.com/apollographql/persistgraphql. Thanks to everyone who helped make that project happen.

---
_Source: https://npm.io/package/duplicate-operation-name · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
