Socket
Socket
Sign inDemoInstall

graphql-parse-resolve-info

Package Overview
Dependencies
5
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.4.1-alpha.0 to 4.4.1-alpha.1

build-turbo/index.d.ts

8

index.js
if (process.env.GRAPHILE_TURBO === "1") {
module.exports = require('./build-turbo/index.js');
const major = parseInt(process.version.replace(/\..*$/, ""), 10);
if (major < 12) {
throw new Error("Turbo mode requires Node v12 or higher");
}
module.exports = require("./build-turbo/index.js");
} else {
module.exports = require('./node8plus/index.js');
module.exports = require("./node8plus/index.js");
}

@@ -9,2 +9,3 @@ "use strict";

const debug = debugFactory("graphql-parse-resolve-info");
const DEBUG_ENABLED = debug.enabled;
function getArgVal(resolveInfo, argument) {

@@ -18,2 +19,5 @@ if (argument.kind === "Variable") {

}
function argNameIsIf(arg) {
return arg && arg.name ? arg.name.value === "if" : false;
}
function skipField(resolveInfo, { directives = [] }) {

@@ -24,3 +28,3 @@ let skip = false;

if (Array.isArray(directive.arguments)) {
const ifArgumentAst = directive.arguments.find(arg => arg.name && arg.name.value === "if");
const ifArgumentAst = directive.arguments.find(argNameIsIf);
if (ifArgumentAst) {

@@ -103,27 +107,34 @@ const argumentValueAst = ifArgumentAst.value;

const instance = iNum++;
debug("%s[%d] Entering fieldTreeFromAST with parent type '%s'", depth, instance, parentType);
if (DEBUG_ENABLED)
debug("%s[%d] Entering fieldTreeFromAST with parent type '%s'", depth, instance, parentType);
const { variableValues } = resolveInfo;
const fragments = resolveInfo.fragments || {};
const asts = Array.isArray(inASTs) ? inASTs : [inASTs];
initTree[parentType.name] = initTree[parentType.name] || {};
if (!initTree[parentType.name]) {
initTree[parentType.name] = {};
}
const outerDepth = depth;
return asts.reduce((tree, selectionVal, idx) => {
// tslint:disable-next-line no-shadowed-variable
const depth = `${outerDepth} `;
debug("%s[%d] Processing AST %d of %d; kind = %s", depth, instance, idx + 1, asts.length, selectionVal.kind);
const depth = DEBUG_ENABLED ? `${outerDepth} ` : null;
if (DEBUG_ENABLED)
debug("%s[%d] Processing AST %d of %d; kind = %s", depth, instance, idx + 1, asts.length, selectionVal.kind);
if (skipField(resolveInfo, selectionVal)) {
debug("%s[%d] IGNORING due to directive", depth, instance);
if (DEBUG_ENABLED)
debug("%s[%d] IGNORING due to directive", depth, instance);
}
else if (selectionVal.kind === "Field") {
const val = selectionVal;
const name = val.name && val.name.value;
const isReserved = name && name !== "__id" && name.substr(0, 2) === "__";
const name = val.name.value;
const isReserved = name[0] === "_" && name[1] === "_" && name !== "__id";
if (isReserved) {
debug("%s[%d] IGNORING because field '%s' is reserved", depth, instance, name);
if (DEBUG_ENABLED)
debug("%s[%d] IGNORING because field '%s' is reserved", depth, instance, name);
}
else {
const alias = val.alias && val.alias.value ? val.alias.value : val.name.value;
debug("%s[%d] Field '%s' (alias = '%s')", depth, instance, name, alias);
const alias = val.alias && val.alias.value ? val.alias.value : name;
if (DEBUG_ENABLED)
debug("%s[%d] Field '%s' (alias = '%s')", depth, instance, name, alias);
const field = getFieldFromAST(val, parentType);
if (!field) {
if (field == null) {
return tree;

@@ -155,3 +166,4 @@ }

const newParentType = fieldGqlType;
debug("%s[%d] Recursing into subfields", depth, instance);
if (DEBUG_ENABLED)
debug("%s[%d] Recursing into subfields", depth, instance);
fieldTreeFromAST(selectionSet.selections, resolveInfo, tree[parentType.name][alias].fieldsByTypeName, options, newParentType, `${depth} `);

@@ -161,3 +173,4 @@ }

// No fields to add
debug("%s[%d] Exiting (no fields to add)", depth, instance);
if (DEBUG_ENABLED)
debug("%s[%d] Exiting (no fields to add)", depth, instance);
}

@@ -169,3 +182,4 @@ }

const name = val.name && val.name.value;
debug("%s[%d] Fragment spread '%s'", depth, instance, name);
if (DEBUG_ENABLED)
debug("%s[%d] Fragment spread '%s'", depth, instance, name);
const fragment = fragments[name];

@@ -189,3 +203,4 @@ assert(fragment, 'unknown fragment "' + name + '"');

}
debug("%s[%d] Inline fragment (parent = '%s', type = '%s')", depth, instance, parentType, fragmentType);
if (DEBUG_ENABLED)
debug("%s[%d] Inline fragment (parent = '%s', type = '%s')", depth, instance, parentType, fragmentType);
if (fragmentType && graphql_1.isCompositeType(fragmentType)) {

@@ -197,3 +212,4 @@ const newParentType = fragmentType;

else {
debug("%s[%d] IGNORING because kind '%s' not understood", depth, instance, selectionVal.kind);
if (DEBUG_ENABLED)
debug("%s[%d] IGNORING because kind '%s' not understood", depth, instance, selectionVal.kind);
}

@@ -204,5 +220,6 @@ // Ref: https://github.com/graphile/postgraphile/pull/342/files#diff-d6702ec9fed755c88b9d70b430fda4d8R148

}
const hasOwnProperty = Object.prototype.hasOwnProperty;
function firstKey(obj) {
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (hasOwnProperty.call(obj, key)) {
return key;

@@ -209,0 +226,0 @@ }

{
"name": "graphql-parse-resolve-info",
"version": "4.4.1-alpha.0",
"version": "4.4.1-alpha.1",
"description": "Parse GraphQLResolveInfo (the 4th argument of resolve) into a simple tree",
"main": "node8plus/index.js",
"main": "index.js",
"types": "node8plus/index.d.ts",
"scripts": {
"test": "jest",
"prepack": "mkdir -p node8plus && tsc",
"prepack": "mkdir -p node8plus && tsc && tsc --target esnext --lib esnext --outDir build-turbo --declarationDir build-turbo",
"tslint": "prettier --list-different 'src/**/*' && tslint --config ../../tslint.json --project tsconfig.json",

@@ -53,3 +53,4 @@ "watch": "mkdir -p node8plus && tsc --watch"

"node8plus",
"index.js"
"index.js",
"build-turbo"
],

@@ -59,3 +60,3 @@ "engines": {

},
"gitHead": "400dc75714a17ae0c54bde75ea2a9d28228429db"
"gitHead": "b93ca25d5725b8d9b5c5d1faa3e1932e50b702c1"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc