graphql-query-rewriter-rc
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -295,3 +295,3 @@ import { Kind, parse, print, isValueNode, parseType } from 'graphql'; | ||
/** @hidden */ | ||
var rewriteResultsAtPath = function (results, path, callback) { | ||
var rewriteResultsAtPath = function (results, path, callback, includesNonFieldPaths) { | ||
if (path.length === 0) | ||
@@ -314,12 +314,21 @@ return results; | ||
var remainingPath = path.slice(1); | ||
// if the path stops here, just return results without any rewriting | ||
if (curResults === undefined || curResults === null) | ||
if (curResults === undefined || curResults === null) { | ||
// If curResults is undefined or null, and includesNonFieldPaths, | ||
// its likely that curResults is undefined because curPathElm might not be a field path. | ||
if (remainingPath.length && includesNonFieldPaths) { | ||
// Call the callback in case the non-field paths is expected of a rewrite | ||
callback(results, curPathElm); | ||
// Then just continue with the next path | ||
return rewriteResultsAtPath(results, remainingPath, callback, includesNonFieldPaths); | ||
} | ||
// else, if the path stops here, just return results without any rewriting | ||
return results; | ||
} | ||
if (Array.isArray(curResults)) { | ||
newResults[curPathElm] = curResults.map(function (result) { | ||
return rewriteResultsAtPath(result, remainingPath, callback); | ||
return rewriteResultsAtPath(result, remainingPath, callback, includesNonFieldPaths); | ||
}); | ||
} | ||
else { | ||
newResults[curPathElm] = rewriteResultsAtPath(curResults, remainingPath, callback); | ||
newResults[curPathElm] = rewriteResultsAtPath(curResults, remainingPath, callback, includesNonFieldPaths); | ||
} | ||
@@ -403,3 +412,3 @@ return newResults; | ||
return rewriter.rewriteResponse(parentResponse, key, index, nodeMatchAndParents); | ||
}); | ||
}, rewriter.includeNonFieldPathsInMatch); | ||
}); | ||
@@ -406,0 +415,0 @@ }); |
@@ -299,3 +299,3 @@ (function (global, factory) { | ||
/** @hidden */ | ||
var rewriteResultsAtPath = function (results, path, callback) { | ||
var rewriteResultsAtPath = function (results, path, callback, includesNonFieldPaths) { | ||
if (path.length === 0) | ||
@@ -318,12 +318,21 @@ return results; | ||
var remainingPath = path.slice(1); | ||
// if the path stops here, just return results without any rewriting | ||
if (curResults === undefined || curResults === null) | ||
if (curResults === undefined || curResults === null) { | ||
// If curResults is undefined or null, and includesNonFieldPaths, | ||
// its likely that curResults is undefined because curPathElm might not be a field path. | ||
if (remainingPath.length && includesNonFieldPaths) { | ||
// Call the callback in case the non-field paths is expected of a rewrite | ||
callback(results, curPathElm); | ||
// Then just continue with the next path | ||
return rewriteResultsAtPath(results, remainingPath, callback, includesNonFieldPaths); | ||
} | ||
// else, if the path stops here, just return results without any rewriting | ||
return results; | ||
} | ||
if (Array.isArray(curResults)) { | ||
newResults[curPathElm] = curResults.map(function (result) { | ||
return rewriteResultsAtPath(result, remainingPath, callback); | ||
return rewriteResultsAtPath(result, remainingPath, callback, includesNonFieldPaths); | ||
}); | ||
} | ||
else { | ||
newResults[curPathElm] = rewriteResultsAtPath(curResults, remainingPath, callback); | ||
newResults[curPathElm] = rewriteResultsAtPath(curResults, remainingPath, callback, includesNonFieldPaths); | ||
} | ||
@@ -407,3 +416,3 @@ return newResults; | ||
return rewriter.rewriteResponse(parentResponse, key, index, nodeMatchAndParents); | ||
}); | ||
}, rewriter.includeNonFieldPathsInMatch); | ||
}); | ||
@@ -410,0 +419,0 @@ }); |
@@ -250,3 +250,3 @@ "use strict"; | ||
/** @hidden */ | ||
exports.rewriteResultsAtPath = function (results, path, callback) { | ||
exports.rewriteResultsAtPath = function (results, path, callback, includesNonFieldPaths) { | ||
if (path.length === 0) | ||
@@ -269,12 +269,21 @@ return results; | ||
var remainingPath = path.slice(1); | ||
// if the path stops here, just return results without any rewriting | ||
if (curResults === undefined || curResults === null) | ||
if (curResults === undefined || curResults === null) { | ||
// If curResults is undefined or null, and includesNonFieldPaths, | ||
// its likely that curResults is undefined because curPathElm might not be a field path. | ||
if (remainingPath.length && includesNonFieldPaths) { | ||
// Call the callback in case the non-field paths is expected of a rewrite | ||
callback(results, curPathElm); | ||
// Then just continue with the next path | ||
return exports.rewriteResultsAtPath(results, remainingPath, callback, includesNonFieldPaths); | ||
} | ||
// else, if the path stops here, just return results without any rewriting | ||
return results; | ||
} | ||
if (Array.isArray(curResults)) { | ||
newResults[curPathElm] = curResults.map(function (result) { | ||
return exports.rewriteResultsAtPath(result, remainingPath, callback); | ||
return exports.rewriteResultsAtPath(result, remainingPath, callback, includesNonFieldPaths); | ||
}); | ||
} | ||
else { | ||
newResults[curPathElm] = exports.rewriteResultsAtPath(curResults, remainingPath, callback); | ||
newResults[curPathElm] = exports.rewriteResultsAtPath(curResults, remainingPath, callback, includesNonFieldPaths); | ||
} | ||
@@ -281,0 +290,0 @@ return newResults; |
@@ -79,3 +79,3 @@ "use strict"; | ||
return rewriter.rewriteResponse(parentResponse, key, index, nodeMatchAndParents); | ||
}); | ||
}, rewriter.includeNonFieldPathsInMatch); | ||
}); | ||
@@ -82,0 +82,0 @@ }); |
@@ -55,3 +55,3 @@ import { ArgumentNode, ASTNode, DocumentNode, VariableDefinitionNode } from 'graphql'; | ||
/** @hidden */ | ||
export declare const rewriteResultsAtPath: (results: ResultObj, path: ReadonlyArray<string>, callback: (parentResult: any, key: string, position?: number | undefined) => any) => ResultObj; | ||
export declare const rewriteResultsAtPath: (results: ResultObj, path: ReadonlyArray<string>, callback: (parentResult: any, key: string, position?: number | undefined) => any, includesNonFieldPaths?: boolean | undefined) => ResultObj; | ||
export {}; |
{ | ||
"name": "graphql-query-rewriter-rc", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
398279
3890