Socket
Socket
Sign inDemoInstall

graphql-prettier

Package Overview
Dependencies
2
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

36

lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _parser = require("graphql/language/parser");
var _printer = require("graphql/language/printer");
var _kinds = require("graphql/language/kinds");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

@@ -15,8 +26,2 @@

var parser = require('graphql/language/parser');
var printer = require('graphql/language/printer');
var kinds = require('graphql/language/kinds').Kind;
var isSelectionsEmpty = function isSelectionsEmpty(node) {

@@ -34,4 +39,4 @@ return !node.selectionSet || !node.selectionSet.selections || node.selectionSet.selections.length === 0;

newNode.selectionSet.selections = newNode.selectionSet.selections.filter(function (selection, index, self) {
return selection.kind !== kinds.FIELD || selection.selectionSet || index === self.findIndex(function (selection2) {
return selection2.kind === kinds.FIELD && selection.name.value === selection2.name.value;
return selection.kind !== _kinds.Kind.FIELD || selection.selectionSet || index === self.findIndex(function (selection2) {
return selection2.kind === _kinds.Kind.FIELD && selection.name.value === selection2.name.value;
});

@@ -61,3 +66,3 @@ }).map(removeDuplicatedLeafNodes);

newNode.selectionSet.selections = newNode.selectionSet.selections.filter(function (selection, index, self) {
if (selection.kind !== kinds.FIELD) {
if (selection.kind !== _kinds.Kind.FIELD) {
return true;

@@ -98,3 +103,3 @@ }

newNode.selectionSet.selections = newNode.selectionSet.selections.filter(function (selection) {
if (selection.kind !== kinds.FRAGMENT_SPREAD) {
if (selection.kind !== _kinds.Kind.FRAGMENT_SPREAD) {
return true;

@@ -130,5 +135,5 @@ }

var noDuplicates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var document = parser.parse(source);
var document = (0, _parser.parse)(source);
var fragments = document.definitions.filter(function (node) {
return node.kind === kinds.FRAGMENT_DEFINITION;
return node.kind === _kinds.Kind.FRAGMENT_DEFINITION;
}).map(function (node, _, self) {

@@ -138,3 +143,3 @@ return replaceFragments(node, self);

return document.definitions.filter(function (node) {
return node.kind === kinds.OPERATION_DEFINITION;
return node.kind === _kinds.Kind.OPERATION_DEFINITION;
}).map(function (operationNode) {

@@ -154,5 +159,6 @@ var newOperationNode = _objectSpread({}, operationNode);

return newOperationNode;
}).map(printer.print).join('\n');
}).map(_printer.print).join('\n');
};
exports.default = prettify;
var _default = prettify;
exports.default = _default;
{
"name": "graphql-prettier",
"version": "1.0.1",
"version": "1.0.2",
"description": "Prettify & simplify GraphQL query/mutation/subscription.",

@@ -10,3 +10,3 @@ "main": "./lib/index.js",

"prepublishOnly": "npm run build",
"test": "nyc mocha ./src"
"test": "nyc mocha ./src/**/*.test.js --require @babel/register"
},

@@ -26,2 +26,3 @@ "repository": "Emetrop/graphql-prettier",

"@babel/preset-env": "^7.3.4",
"@babel/register": "^7.4.0",
"eslint": "^5.15.1",

@@ -28,0 +29,0 @@ "mocha": "^6.0.2",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc