Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-inspector/audit-command

Package Overview
Dependencies
Maintainers
3
Versions
484
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-inspector/audit-command - npm Package Compare versions

Comparing version 0.0.0-canary.36b26d2 to 0.0.0-canary.86df6bb

17

index.js

@@ -10,2 +10,3 @@ 'use strict';

const core = require('@graphql-inspector/core');
const graphql = require('graphql');
const logger = require('@graphql-inspector/logger');

@@ -68,4 +69,6 @@ const Table = _interopDefault(require('cli-table3'));

const fragments = new Map();
const fragmentStrings = new Map();
const operations = new Map();
const getFragmentReference = (fragmentName) => fragments.get(fragmentName);
const getFragmentSource = (fragmentName) => fragmentStrings.get(fragmentName);
for (const record of args.documents) {

@@ -76,2 +79,3 @@ if (record.document) {

fragments.set(definition.name.value, definition);
fragmentStrings.set(definition.name.value, graphql.print(definition));
}

@@ -89,2 +93,3 @@ else if (definition.kind === 'OperationDefinition') {

let maxDirectives = 0;
let maxTokenCount = 0;
let maxComplexity = 0;

@@ -96,7 +101,12 @@ const results = [];

const directives = core.countDirectives(operation, getFragmentReference);
const tokenCount = core.calculateTokenCount({
source: graphql.print(operation),
getReferencedFragmentSource: getFragmentSource,
});
const complexity = core.calculateOperationComplexity(operation, args.complexityConfig, getFragmentReference);
results.push([name, depth, aliases, directives, complexity]);
results.push([name, depth, aliases, directives, tokenCount, complexity.toFixed(2)]);
maxDepth = Math.max(maxDepth, depth);
maxAliases = Math.max(maxAliases, aliases);
maxDirectives = Math.max(maxDirectives, directives);
maxTokenCount = Math.max(maxTokenCount, tokenCount);
maxComplexity = Math.max(maxComplexity, complexity);

@@ -106,3 +116,3 @@ }

const table = new Table({
head: ['Operation Name', 'Depth', 'Aliases', 'Directives', 'Complexity Score'],
head: ['Operation Name', 'Depth', 'Aliases', 'Directives', 'Token Count', 'Complexity Score'],
});

@@ -115,3 +125,4 @@ table.push(...results);

logger.Logger.log(`Maximum directive amount is ${logger.chalk.bold(maxDirectives)}`);
logger.Logger.log(`Maximum complexity score is ${logger.chalk.bold(maxComplexity)}`);
logger.Logger.log(`Maximum token count is ${logger.chalk.bold(maxTokenCount)}`);
logger.Logger.log(`Maximum complexity score is ${logger.chalk.bold(maxComplexity.toFixed(2))}`);
}

@@ -118,0 +129,0 @@

8

package.json
{
"name": "@graphql-inspector/audit-command",
"version": "0.0.0-canary.36b26d2",
"version": "0.0.0-canary.86df6bb",
"description": "Audit Documents in GraphQL Inspector",

@@ -10,5 +10,5 @@ "sideEffects": false,

"dependencies": {
"@graphql-inspector/commands": "0.0.0-canary.36b26d2",
"@graphql-inspector/core": "0.0.0-canary.36b26d2",
"@graphql-inspector/logger": "0.0.0-canary.36b26d2",
"@graphql-inspector/commands": "0.0.0-canary.86df6bb",
"@graphql-inspector/core": "0.0.0-canary.86df6bb",
"@graphql-inspector/logger": "0.0.0-canary.86df6bb",
"cli-table3": "0.6.2",

@@ -15,0 +15,0 @@ "tslib": "^2.0.0"

Sorry, the diff of this file is not supported yet

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