New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

duplicate-operation-name

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duplicate-operation-name

A static analysis tool for GraphQL projects.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-12.4%
Maintainers
1
Weekly downloads
 
Created
Source

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

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)

duplicate-operation-name queries.graphql --graphql

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

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

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

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:

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.

FAQs

Package last updated on 29 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc