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

@graphql-tools/documents

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/documents - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1-rc-20240527102513-c1d3920eae85fae308bbb764ae936a2827436d8e

26

cjs/sort-executable-document.js

@@ -10,2 +10,5 @@ "use strict";

function sortExecutableDocument(document) {
const ignoredNodes = new WeakSet();
const ignoredSelectionsArr = new Set();
const ignoredFragments = new Set();
return (0, graphql_1.visit)(document, {

@@ -19,2 +22,6 @@ Document(node) {

OperationDefinition(node) {
if (node.operation === 'mutation') {
ignoredNodes.add(node.selectionSet);
ignoredSelectionsArr.add(node.selectionSet.selections);
}
return {

@@ -26,2 +33,6 @@ ...node,

SelectionSet(node) {
if (ignoredNodes.has(node)) {
ignoredSelectionsArr.add(node.selections);
return node;
}
return {

@@ -32,3 +43,6 @@ ...node,

},
FragmentSpread(node) {
FragmentSpread(node, _key, parent) {
if (Array.isArray(parent) && ignoredSelectionsArr.has(parent)) {
ignoredFragments.add(node.name.value);
}
return {

@@ -39,3 +53,8 @@ ...node,

},
InlineFragment(node) {
InlineFragment(node, _key, parent) {
if (Array.isArray(parent) && ignoredSelectionsArr.has(parent)) {
ignoredNodes.add(node.selectionSet);
ignoredSelectionsArr.add(node.selectionSet.selections);
return node;
}
return {

@@ -47,2 +66,5 @@ ...node,

FragmentDefinition(node) {
if (ignoredFragments.has(node.name.value)) {
return node;
}
return {

@@ -49,0 +71,0 @@ ...node,

@@ -7,2 +7,5 @@ import { visit } from 'graphql';

export function sortExecutableDocument(document) {
const ignoredNodes = new WeakSet();
const ignoredSelectionsArr = new Set();
const ignoredFragments = new Set();
return visit(document, {

@@ -16,2 +19,6 @@ Document(node) {

OperationDefinition(node) {
if (node.operation === 'mutation') {
ignoredNodes.add(node.selectionSet);
ignoredSelectionsArr.add(node.selectionSet.selections);
}
return {

@@ -23,2 +30,6 @@ ...node,

SelectionSet(node) {
if (ignoredNodes.has(node)) {
ignoredSelectionsArr.add(node.selections);
return node;
}
return {

@@ -29,3 +40,6 @@ ...node,

},
FragmentSpread(node) {
FragmentSpread(node, _key, parent) {
if (Array.isArray(parent) && ignoredSelectionsArr.has(parent)) {
ignoredFragments.add(node.name.value);
}
return {

@@ -36,3 +50,8 @@ ...node,

},
InlineFragment(node) {
InlineFragment(node, _key, parent) {
if (Array.isArray(parent) && ignoredSelectionsArr.has(parent)) {
ignoredNodes.add(node.selectionSet);
ignoredSelectionsArr.add(node.selectionSet.selections);
return node;
}
return {

@@ -44,2 +63,5 @@ ...node,

FragmentDefinition(node) {
if (ignoredFragments.has(node.name.value)) {
return node;
}
return {

@@ -46,0 +68,0 @@ ...node,

6

package.json
{
"name": "@graphql-tools/documents",
"version": "1.0.0",
"version": "1.0.1-rc-20240527102513-c1d3920eae85fae308bbb764ae936a2827436d8e",
"description": "Utilities for GraphQL documents.",

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

"dependencies": {
"tslib": "^2.4.0",
"lodash.sortby": "^4.7.0"
"lodash.sortby": "^4.7.0",
"tslib": "^2.4.0"
},

@@ -14,0 +14,0 @@ "repository": {

@@ -15,5 +15,4 @@ # `@graphql-tools/documents`

A stable way to print a GraphQL document.
All executable/fragment variable definitions, fields are printed in a stable way.
Useful for stuff like persisted GraphQL operations.
A stable way to print a GraphQL document. All executable/fragment variable definitions, fields are
printed in a stable way. Useful for stuff like persisted GraphQL operations.

@@ -48,3 +47,4 @@ #### Usage

console.assert(
outputStr === 'fragment B on Query { c } query A { ... on Query { a { a ...B } } ... on Query { a { b ...B } } }',
outputStr ===
'fragment B on Query { c } query A { ... on Query { a { a ...B } } ... on Query { a { b ...B } } }',
'Stuff is not equal.'

@@ -59,2 +59,3 @@ )

- Arguments (Directive, Fields) are sorted alphabetical
- Selections sets are sorted Field, FragmentSpread, InlineFragmentSpread (sorted based on TypeCondition, inner SelectionSet)
- Selections sets are sorted Field, FragmentSpread, InlineFragmentSpread (sorted based on
TypeCondition, inner SelectionSet)
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