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

graphql-anywhere

Package Overview
Dependencies
Maintainers
7
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-anywhere - npm Package Compare versions

Comparing version 4.2.2 to 4.2.3

377

lib/bundle.cjs.js

@@ -1,199 +0,254 @@

'use strict';
exports.__esModule = true;
exports.check = check;
exports.filter = filter;
exports.propType = propType;
exports.default = void 0;
Object.defineProperty(exports, '__esModule', { value: true });
var _apolloUtilities = require("apollo-utilities");
var apolloUtilities = require('apollo-utilities');
var tsInvariant = require('ts-invariant');
var _tsInvariant = require("ts-invariant");
function graphql(resolver, document, rootValue, contextValue, variableValues, execOptions) {
if (variableValues === void 0) { variableValues = {}; }
if (execOptions === void 0) { execOptions = {}; }
var mainDefinition = apolloUtilities.getMainDefinition(document);
var fragments = apolloUtilities.getFragmentDefinitions(document);
var fragmentMap = apolloUtilities.createFragmentMap(fragments);
var resultMapper = execOptions.resultMapper;
var fragmentMatcher = execOptions.fragmentMatcher || (function () { return true; });
var execContext = {
fragmentMap: fragmentMap,
contextValue: contextValue,
variableValues: variableValues,
resultMapper: resultMapper,
resolver: resolver,
fragmentMatcher: fragmentMatcher,
};
return executeSelectionSet(mainDefinition.selectionSet, rootValue, execContext);
if (variableValues === void 0) {
variableValues = {};
}
if (execOptions === void 0) {
execOptions = {};
}
var mainDefinition = (0, _apolloUtilities.getMainDefinition)(document);
var fragments = (0, _apolloUtilities.getFragmentDefinitions)(document);
var fragmentMap = (0, _apolloUtilities.createFragmentMap)(fragments);
var resultMapper = execOptions.resultMapper;
var fragmentMatcher = execOptions.fragmentMatcher || function () {
return true;
};
var execContext = {
fragmentMap: fragmentMap,
contextValue: contextValue,
variableValues: variableValues,
resultMapper: resultMapper,
resolver: resolver,
fragmentMatcher: fragmentMatcher
};
return executeSelectionSet(mainDefinition.selectionSet, rootValue, execContext);
}
function executeSelectionSet(selectionSet, rootValue, execContext) {
var fragmentMap = execContext.fragmentMap, contextValue = execContext.contextValue, variables = execContext.variableValues;
var result = {};
selectionSet.selections.forEach(function (selection) {
if (variables && !apolloUtilities.shouldInclude(selection, variables)) {
return;
var fragmentMap = execContext.fragmentMap,
contextValue = execContext.contextValue,
variables = execContext.variableValues;
var result = {};
selectionSet.selections.forEach(function (selection) {
if (variables && !(0, _apolloUtilities.shouldInclude)(selection, variables)) {
return;
}
if ((0, _apolloUtilities.isField)(selection)) {
var fieldResult = executeField(selection, rootValue, execContext);
var resultFieldKey = (0, _apolloUtilities.resultKeyNameFromField)(selection);
if (fieldResult !== undefined) {
if (result[resultFieldKey] === undefined) {
result[resultFieldKey] = fieldResult;
} else {
merge(result[resultFieldKey], fieldResult);
}
if (apolloUtilities.isField(selection)) {
var fieldResult = executeField(selection, rootValue, execContext);
var resultFieldKey = apolloUtilities.resultKeyNameFromField(selection);
if (fieldResult !== undefined) {
if (result[resultFieldKey] === undefined) {
result[resultFieldKey] = fieldResult;
}
else {
merge(result[resultFieldKey], fieldResult);
}
}
}
} else {
var fragment = void 0;
if ((0, _apolloUtilities.isInlineFragment)(selection)) {
fragment = selection;
} else {
fragment = fragmentMap[selection.name.value];
if (!fragment) {
throw new Error("No fragment named " + selection.name.value);
}
else {
var fragment = void 0;
if (apolloUtilities.isInlineFragment(selection)) {
fragment = selection;
}
else {
fragment = fragmentMap[selection.name.value];
if (!fragment) {
throw new Error("No fragment named " + selection.name.value);
}
}
var typeCondition = fragment.typeCondition.name.value;
if (execContext.fragmentMatcher(rootValue, typeCondition, contextValue)) {
var fragmentResult = executeSelectionSet(fragment.selectionSet, rootValue, execContext);
merge(result, fragmentResult);
}
}
});
if (execContext.resultMapper) {
return execContext.resultMapper(result, rootValue);
}
var typeCondition = fragment.typeCondition.name.value;
if (execContext.fragmentMatcher(rootValue, typeCondition, contextValue)) {
var fragmentResult = executeSelectionSet(fragment.selectionSet, rootValue, execContext);
merge(result, fragmentResult);
}
}
});
if (execContext.resultMapper) {
return execContext.resultMapper(result, rootValue);
}
return result;
}
function executeField(field, rootValue, execContext) {
var variables = execContext.variableValues,
contextValue = execContext.contextValue,
resolver = execContext.resolver;
var fieldName = field.name.value;
var args = (0, _apolloUtilities.argumentsObjectFromField)(field, variables);
var info = {
isLeaf: !field.selectionSet,
resultKey: (0, _apolloUtilities.resultKeyNameFromField)(field),
directives: (0, _apolloUtilities.getDirectiveInfoFromField)(field, variables),
field: field
};
var result = resolver(fieldName, rootValue, args, contextValue, info);
if (!field.selectionSet) {
return result;
}
if (result == null) {
return result;
}
if (Array.isArray(result)) {
return executeSubSelectedArray(field, result, execContext);
}
return executeSelectionSet(field.selectionSet, result, execContext);
}
function executeField(field, rootValue, execContext) {
var variables = execContext.variableValues, contextValue = execContext.contextValue, resolver = execContext.resolver;
var fieldName = field.name.value;
var args = apolloUtilities.argumentsObjectFromField(field, variables);
var info = {
isLeaf: !field.selectionSet,
resultKey: apolloUtilities.resultKeyNameFromField(field),
directives: apolloUtilities.getDirectiveInfoFromField(field, variables),
field: field,
};
var result = resolver(fieldName, rootValue, args, contextValue, info);
if (!field.selectionSet) {
return result;
function executeSubSelectedArray(field, result, execContext) {
return result.map(function (item) {
if (item === null) {
return null;
}
if (result == null) {
return result;
if (Array.isArray(item)) {
return executeSubSelectedArray(field, item, execContext);
}
if (Array.isArray(result)) {
return executeSubSelectedArray(field, result, execContext);
}
return executeSelectionSet(field.selectionSet, result, execContext);
return executeSelectionSet(field.selectionSet, item, execContext);
});
}
function executeSubSelectedArray(field, result, execContext) {
return result.map(function (item) {
if (item === null) {
return null;
}
if (Array.isArray(item)) {
return executeSubSelectedArray(field, item, execContext);
}
return executeSelectionSet(field.selectionSet, item, execContext);
});
}
var hasOwn = Object.prototype.hasOwnProperty;
function merge(dest, src) {
if (src !== null && typeof src === 'object') {
Object.keys(src).forEach(function (key) {
var srcVal = src[key];
if (!hasOwn.call(dest, key)) {
dest[key] = srcVal;
}
else {
merge(dest[key], srcVal);
}
});
}
if (src !== null && typeof src === 'object') {
Object.keys(src).forEach(function (key) {
var srcVal = src[key];
if (!hasOwn.call(dest, key)) {
dest[key] = srcVal;
} else {
merge(dest[key], srcVal);
}
});
}
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
function filter(doc, data, variableValues) {
if (variableValues === void 0) { variableValues = {}; }
var resolver = function (fieldName, root, args, context, info) {
return root[info.resultKey];
};
return Array.isArray(data)
? data.map(function (dataObj) { return graphql(resolver, doc, dataObj, null, variableValues); })
: graphql(resolver, doc, data, null, variableValues);
if (variableValues === void 0) {
variableValues = {};
}
var resolver = function (fieldName, root, args, context, info) {
return root[info.resultKey];
};
return Array.isArray(data) ? data.map(function (dataObj) {
return graphql(resolver, doc, dataObj, null, variableValues);
}) : graphql(resolver, doc, data, null, variableValues);
}
function check(doc, data, variables) {
if (variables === void 0) { variables = {}; }
var resolver = function (fieldName, root, args, context, info) {
process.env.NODE_ENV === "production" ? tsInvariant.invariant(hasOwnProperty.call(root, info.resultKey) ||
(!variables && hasVariableInclusions(info.field.directives)), 1) : tsInvariant.invariant(hasOwnProperty.call(root, info.resultKey) ||
(!variables && hasVariableInclusions(info.field.directives)), info.resultKey + " missing on " + JSON.stringify(root));
return root[info.resultKey];
};
graphql(resolver, doc, data, {}, variables, {
fragmentMatcher: function () { return false; },
});
if (variables === void 0) {
variables = {};
}
var resolver = function (fieldName, root, args, context, info) {
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(hasOwnProperty.call(root, info.resultKey) || !variables && hasVariableInclusions(info.field.directives), 1) : (0, _tsInvariant.invariant)(hasOwnProperty.call(root, info.resultKey) || !variables && hasVariableInclusions(info.field.directives), info.resultKey + " missing on " + JSON.stringify(root));
return root[info.resultKey];
};
graphql(resolver, doc, data, {}, variables, {
fragmentMatcher: function () {
return false;
}
});
}
function hasVariableInclusions(directives) {
return apolloUtilities.getInclusionDirectives(directives).some(function (_a) {
var ifArgument = _a.ifArgument;
return ifArgument.value && ifArgument.value.kind === 'Variable';
});
return (0, _apolloUtilities.getInclusionDirectives)(directives).some(function (_a) {
var ifArgument = _a.ifArgument;
return ifArgument.value && ifArgument.value.kind === 'Variable';
});
}
var ANONYMOUS = '<<anonymous>>';
function PropTypeError(message) {
this.message = message;
this.stack = '';
this.message = message;
this.stack = '';
}
PropTypeError.prototype = Error.prototype;
var reactPropTypeLocationNames = {
prop: 'prop',
context: 'context',
childContext: 'child context',
prop: 'prop',
context: 'context',
childContext: 'child context'
};
function createChainableTypeChecker(validate) {
function checkType(isRequired, props, propName, componentName, location, propFullName) {
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (props[propName] == null) {
var locationName = reactPropTypeLocationNames[location];
if (isRequired) {
if (props[propName] === null) {
return new PropTypeError("The " + locationName + " `" + propFullName + "` is marked as required " +
("in `" + componentName + "`, but its value is `null`."));
}
return new PropTypeError("The " + locationName + " `" + propFullName + "` is marked as required in " +
("`" + componentName + "`, but its value is `undefined`."));
}
return null;
function checkType(isRequired, props, propName, componentName, location, propFullName) {
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (props[propName] == null) {
var locationName = reactPropTypeLocationNames[location];
if (isRequired) {
if (props[propName] === null) {
return new PropTypeError("The " + locationName + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
}
else {
return validate(props, propName, componentName, location, propFullName);
}
return new PropTypeError("The " + locationName + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
}
return null;
} else {
return validate(props, propName, componentName, location, propFullName);
}
var chainedCheckType = checkType.bind(null, false);
chainedCheckType.isRequired = checkType.bind(null, true);
return chainedCheckType;
}
var chainedCheckType = checkType.bind(null, false);
chainedCheckType.isRequired = checkType.bind(null, true);
return chainedCheckType;
}
function propType(doc, mapPropsToVariables) {
if (mapPropsToVariables === void 0) { mapPropsToVariables = function (props) { return null; }; }
return createChainableTypeChecker(function (props, propName) {
var prop = props[propName];
try {
if (!prop.loading) {
check(doc, prop, mapPropsToVariables(props));
}
return null;
}
catch (e) {
return e;
}
});
if (mapPropsToVariables === void 0) {
mapPropsToVariables = function (props) {
return null;
};
}
return createChainableTypeChecker(function (props, propName) {
var prop = props[propName];
try {
if (!prop.loading) {
check(doc, prop, mapPropsToVariables(props));
}
return null;
} catch (e) {
return e;
}
});
}
exports.check = check;
exports.default = graphql;
exports.filter = filter;
exports.propType = propType;
//# sourceMappingURL=bundle.cjs.js.map
var _default = graphql;
exports.default = _default;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("apollo-utilities"),r=require("ts-invariant");function t(r,t,i,a,u,l){void 0===u&&(u={}),void 0===l&&(l={});var o=e.getMainDefinition(t),s=e.getFragmentDefinitions(t),c={fragmentMap:e.createFragmentMap(s),contextValue:a,variableValues:u,resultMapper:l.resultMapper,resolver:r,fragmentMatcher:l.fragmentMatcher||function(){return!0}};return n(o.selectionSet,i,c)}function n(r,t,a){var u=a.fragmentMap,o=a.contextValue,s=a.variableValues,c={};return r.selections.forEach(function(r){if(!s||e.shouldInclude(r,s))if(e.isField(r)){var f=i(r,t,a),v=e.resultKeyNameFromField(r);void 0!==f&&(void 0===c[v]?c[v]=f:l(c[v],f))}else{var p=void 0;if(e.isInlineFragment(r))p=r;else if(!(p=u[r.name.value]))throw new Error("No fragment named "+r.name.value);var d=p.typeCondition.name.value;if(a.fragmentMatcher(t,d,o)){var m=n(p.selectionSet,t,a);l(c,m)}}}),a.resultMapper?a.resultMapper(c,t):c}function i(r,t,i){var u=i.variableValues,l=i.contextValue,o=(0,i.resolver)(r.name.value,t,e.argumentsObjectFromField(r,u),l,{isLeaf:!r.selectionSet,resultKey:e.resultKeyNameFromField(r),directives:e.getDirectiveInfoFromField(r,u),field:r});return r.selectionSet?null==o?o:Array.isArray(o)?a(r,o,i):n(r.selectionSet,o,i):o}function a(e,r,t){return r.map(function(r){return null===r?null:Array.isArray(r)?a(e,r,t):n(e.selectionSet,r,t)})}var u=Object.prototype.hasOwnProperty;function l(e,r){null!==r&&"object"==typeof r&&Object.keys(r).forEach(function(t){var n=r[t];u.call(e,t)?l(e[t],n):e[t]=n})}var o=Object.prototype.hasOwnProperty;function s(e,r,n){void 0===n&&(n={});var i=function(e,r,t,n,i){return r[i.resultKey]};return Array.isArray(r)?r.map(function(r){return t(i,e,r,null,n)}):t(i,e,r,null,n)}function c(e,n,i){void 0===i&&(i={});t(function(e,t,n,a,u){return r.invariant(o.call(t,u.resultKey)||!i&&f(u.field.directives),1),t[u.resultKey]},e,n,{},i,{fragmentMatcher:function(){return!1}})}function f(r){return e.getInclusionDirectives(r).some(function(e){var r=e.ifArgument;return r.value&&"Variable"===r.value.kind})}var v="<<anonymous>>";function p(e){this.message=e,this.stack=""}p.prototype=Error.prototype;var d={prop:"prop",context:"context",childContext:"child context"};function m(e){function r(r,t,n,i,a,u){if(i=i||v,u=u||n,null==t[n]){var l=d[a];return r?null===t[n]?new p("The "+l+" `"+u+"` is marked as required in `"+i+"`, but its value is `null`."):new p("The "+l+" `"+u+"` is marked as required in `"+i+"`, but its value is `undefined`."):null}return e(t,n,i,a,u)}var t=r.bind(null,!1);return t.isRequired=r.bind(null,!0),t}function y(e,r){return void 0===r&&(r=function(e){return null}),m(function(t,n){var i=t[n];try{return i.loading||c(e,i,r(t)),null}catch(e){return e}})}exports.check=c,exports.default=t,exports.filter=s,exports.propType=y;
exports.__esModule=!0,exports.check=o,exports.filter=function(e,r,n){void 0===n&&(n={});var i=function(e,r,t,n,i){return r[i.resultKey]};return Array.isArray(r)?r.map(function(r){return t(i,e,r,null,n)}):t(i,e,r,null,n)},exports.propType=function(e,r){void 0===r&&(r=function(e){return null});return function(e){function r(r,t,n,i,a,u){if(i=i||s,u=u||n,null==t[n]){var o=f[a];return r?null===t[n]?new c("The "+o+" `"+u+"` is marked as required in `"+i+"`, but its value is `null`."):new c("The "+o+" `"+u+"` is marked as required in `"+i+"`, but its value is `undefined`."):null}return e(t,n,i,a,u)}var t=r.bind(null,!1);return t.isRequired=r.bind(null,!0),t}(function(t,n){var i=t[n];try{return i.loading||o(e,i,r(t)),null}catch(e){return e}})},exports.default=void 0;var e=require("apollo-utilities"),r=require("ts-invariant");function t(r,t,i,a,u,o){void 0===u&&(u={}),void 0===o&&(o={});var l=(0,e.getMainDefinition)(t),s=(0,e.getFragmentDefinitions)(t),c={fragmentMap:(0,e.createFragmentMap)(s),contextValue:a,variableValues:u,resultMapper:o.resultMapper,resolver:r,fragmentMatcher:o.fragmentMatcher||function(){return!0}};return n(l.selectionSet,i,c)}function n(r,t,i){var u=i.fragmentMap,o=i.contextValue,l=i.variableValues,s={};return r.selections.forEach(function(r){if(!l||(0,e.shouldInclude)(r,l))if((0,e.isField)(r)){var c=function(r,t,i){var a=i.variableValues,u=i.contextValue,o=i.resolver,l=r.name.value,s=(0,e.argumentsObjectFromField)(r,a),c={isLeaf:!r.selectionSet,resultKey:(0,e.resultKeyNameFromField)(r),directives:(0,e.getDirectiveInfoFromField)(r,a),field:r},f=o(l,t,s,u,c);if(!r.selectionSet)return f;if(null==f)return f;if(Array.isArray(f))return function e(r,t,i){return t.map(function(t){return null===t?null:Array.isArray(t)?e(r,t,i):n(r.selectionSet,t,i)})}(r,f,i);return n(r.selectionSet,f,i)}(r,t,i),f=(0,e.resultKeyNameFromField)(r);void 0!==c&&(void 0===s[f]?s[f]=c:a(s[f],c))}else{var v=void 0;if((0,e.isInlineFragment)(r))v=r;else if(!(v=u[r.name.value]))throw new Error("No fragment named "+r.name.value);var p=v.typeCondition.name.value;if(i.fragmentMatcher(t,p,o)){var d=n(v.selectionSet,t,i);a(s,d)}}}),i.resultMapper?i.resultMapper(s,t):s}var i=Object.prototype.hasOwnProperty;function a(e,r){null!==r&&"object"==typeof r&&Object.keys(r).forEach(function(t){var n=r[t];i.call(e,t)?a(e[t],n):e[t]=n})}var u=Object.prototype.hasOwnProperty;function o(e,n,i){void 0===i&&(i={});t(function(e,t,n,a,o){return(0,r.invariant)(u.call(t,o.resultKey)||!i&&l(o.field.directives),1),t[o.resultKey]},e,n,{},i,{fragmentMatcher:function(){return!1}})}function l(r){return(0,e.getInclusionDirectives)(r).some(function(e){var r=e.ifArgument;return r.value&&"Variable"===r.value.kind})}var s="<<anonymous>>";function c(e){this.message=e,this.stack=""}c.prototype=Error.prototype;var f={prop:"prop",context:"context",childContext:"child context"};var v=t;exports.default=v;
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-utilities'), require('ts-invariant')) :
typeof define === 'function' && define.amd ? define(['exports', 'apollo-utilities', 'ts-invariant'], factory) :
(global = global || self, factory(global.graphqlAnywhere = {}, global.apollo.utilities, global.invariant));
}(this, function (exports, apolloUtilities, tsInvariant) { 'use strict';
if (typeof define === "function" && define.amd) {
define(["exports", "apollo-utilities", "ts-invariant"], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require("apollo-utilities"), require("ts-invariant"));
} else {
var mod = {
exports: {}
};
factory(mod.exports, global.apolloUtilities, global.tsInvariant);
global.unknown = mod.exports;
}
})(this, function (_exports, _apolloUtilities, _tsInvariant) {
function graphql(resolver, document, rootValue, contextValue, variableValues, execOptions) {
if (variableValues === void 0) { variableValues = {}; }
if (execOptions === void 0) { execOptions = {}; }
var mainDefinition = apolloUtilities.getMainDefinition(document);
var fragments = apolloUtilities.getFragmentDefinitions(document);
var fragmentMap = apolloUtilities.createFragmentMap(fragments);
var resultMapper = execOptions.resultMapper;
var fragmentMatcher = execOptions.fragmentMatcher || (function () { return true; });
var execContext = {
fragmentMap: fragmentMap,
contextValue: contextValue,
variableValues: variableValues,
resultMapper: resultMapper,
resolver: resolver,
fragmentMatcher: fragmentMatcher,
};
return executeSelectionSet(mainDefinition.selectionSet, rootValue, execContext);
_exports.__esModule = true;
_exports.check = check;
_exports.filter = filter;
_exports.propType = propType;
_exports.default = void 0;
function graphql(resolver, document, rootValue, contextValue, variableValues, execOptions) {
if (variableValues === void 0) {
variableValues = {};
}
function executeSelectionSet(selectionSet, rootValue, execContext) {
var fragmentMap = execContext.fragmentMap, contextValue = execContext.contextValue, variables = execContext.variableValues;
var result = {};
selectionSet.selections.forEach(function (selection) {
if (variables && !apolloUtilities.shouldInclude(selection, variables)) {
return;
}
if (apolloUtilities.isField(selection)) {
var fieldResult = executeField(selection, rootValue, execContext);
var resultFieldKey = apolloUtilities.resultKeyNameFromField(selection);
if (fieldResult !== undefined) {
if (result[resultFieldKey] === undefined) {
result[resultFieldKey] = fieldResult;
}
else {
merge(result[resultFieldKey], fieldResult);
}
}
}
else {
var fragment = void 0;
if (apolloUtilities.isInlineFragment(selection)) {
fragment = selection;
}
else {
fragment = fragmentMap[selection.name.value];
if (!fragment) {
throw new Error("No fragment named " + selection.name.value);
}
}
var typeCondition = fragment.typeCondition.name.value;
if (execContext.fragmentMatcher(rootValue, typeCondition, contextValue)) {
var fragmentResult = executeSelectionSet(fragment.selectionSet, rootValue, execContext);
merge(result, fragmentResult);
}
}
});
if (execContext.resultMapper) {
return execContext.resultMapper(result, rootValue);
}
return result;
if (execOptions === void 0) {
execOptions = {};
}
function executeField(field, rootValue, execContext) {
var variables = execContext.variableValues, contextValue = execContext.contextValue, resolver = execContext.resolver;
var fieldName = field.name.value;
var args = apolloUtilities.argumentsObjectFromField(field, variables);
var info = {
isLeaf: !field.selectionSet,
resultKey: apolloUtilities.resultKeyNameFromField(field),
directives: apolloUtilities.getDirectiveInfoFromField(field, variables),
field: field,
};
var result = resolver(fieldName, rootValue, args, contextValue, info);
if (!field.selectionSet) {
return result;
var mainDefinition = (0, _apolloUtilities.getMainDefinition)(document);
var fragments = (0, _apolloUtilities.getFragmentDefinitions)(document);
var fragmentMap = (0, _apolloUtilities.createFragmentMap)(fragments);
var resultMapper = execOptions.resultMapper;
var fragmentMatcher = execOptions.fragmentMatcher || function () {
return true;
};
var execContext = {
fragmentMap: fragmentMap,
contextValue: contextValue,
variableValues: variableValues,
resultMapper: resultMapper,
resolver: resolver,
fragmentMatcher: fragmentMatcher
};
return executeSelectionSet(mainDefinition.selectionSet, rootValue, execContext);
}
function executeSelectionSet(selectionSet, rootValue, execContext) {
var fragmentMap = execContext.fragmentMap,
contextValue = execContext.contextValue,
variables = execContext.variableValues;
var result = {};
selectionSet.selections.forEach(function (selection) {
if (variables && !(0, _apolloUtilities.shouldInclude)(selection, variables)) {
return;
}
if ((0, _apolloUtilities.isField)(selection)) {
var fieldResult = executeField(selection, rootValue, execContext);
var resultFieldKey = (0, _apolloUtilities.resultKeyNameFromField)(selection);
if (fieldResult !== undefined) {
if (result[resultFieldKey] === undefined) {
result[resultFieldKey] = fieldResult;
} else {
merge(result[resultFieldKey], fieldResult);
}
}
if (result == null) {
return result;
} else {
var fragment = void 0;
if ((0, _apolloUtilities.isInlineFragment)(selection)) {
fragment = selection;
} else {
fragment = fragmentMap[selection.name.value];
if (!fragment) {
throw new Error("No fragment named " + selection.name.value);
}
}
if (Array.isArray(result)) {
return executeSubSelectedArray(field, result, execContext);
var typeCondition = fragment.typeCondition.name.value;
if (execContext.fragmentMatcher(rootValue, typeCondition, contextValue)) {
var fragmentResult = executeSelectionSet(fragment.selectionSet, rootValue, execContext);
merge(result, fragmentResult);
}
return executeSelectionSet(field.selectionSet, result, execContext);
}
});
if (execContext.resultMapper) {
return execContext.resultMapper(result, rootValue);
}
function executeSubSelectedArray(field, result, execContext) {
return result.map(function (item) {
if (item === null) {
return null;
}
if (Array.isArray(item)) {
return executeSubSelectedArray(field, item, execContext);
}
return executeSelectionSet(field.selectionSet, item, execContext);
});
return result;
}
function executeField(field, rootValue, execContext) {
var variables = execContext.variableValues,
contextValue = execContext.contextValue,
resolver = execContext.resolver;
var fieldName = field.name.value;
var args = (0, _apolloUtilities.argumentsObjectFromField)(field, variables);
var info = {
isLeaf: !field.selectionSet,
resultKey: (0, _apolloUtilities.resultKeyNameFromField)(field),
directives: (0, _apolloUtilities.getDirectiveInfoFromField)(field, variables),
field: field
};
var result = resolver(fieldName, rootValue, args, contextValue, info);
if (!field.selectionSet) {
return result;
}
var hasOwn = Object.prototype.hasOwnProperty;
function merge(dest, src) {
if (src !== null && typeof src === 'object') {
Object.keys(src).forEach(function (key) {
var srcVal = src[key];
if (!hasOwn.call(dest, key)) {
dest[key] = srcVal;
}
else {
merge(dest[key], srcVal);
}
});
}
if (result == null) {
return result;
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
function filter(doc, data, variableValues) {
if (variableValues === void 0) { variableValues = {}; }
var resolver = function (fieldName, root, args, context, info) {
return root[info.resultKey];
};
return Array.isArray(data)
? data.map(function (dataObj) { return graphql(resolver, doc, dataObj, null, variableValues); })
: graphql(resolver, doc, data, null, variableValues);
if (Array.isArray(result)) {
return executeSubSelectedArray(field, result, execContext);
}
function check(doc, data, variables) {
if (variables === void 0) { variables = {}; }
var resolver = function (fieldName, root, args, context, info) {
process.env.NODE_ENV === "production" ? tsInvariant.invariant(hasOwnProperty.call(root, info.resultKey) ||
(!variables && hasVariableInclusions(info.field.directives)), 1) : tsInvariant.invariant(hasOwnProperty.call(root, info.resultKey) ||
(!variables && hasVariableInclusions(info.field.directives)), info.resultKey + " missing on " + JSON.stringify(root));
return root[info.resultKey];
};
graphql(resolver, doc, data, {}, variables, {
fragmentMatcher: function () { return false; },
});
return executeSelectionSet(field.selectionSet, result, execContext);
}
function executeSubSelectedArray(field, result, execContext) {
return result.map(function (item) {
if (item === null) {
return null;
}
if (Array.isArray(item)) {
return executeSubSelectedArray(field, item, execContext);
}
return executeSelectionSet(field.selectionSet, item, execContext);
});
}
var hasOwn = Object.prototype.hasOwnProperty;
function merge(dest, src) {
if (src !== null && typeof src === 'object') {
Object.keys(src).forEach(function (key) {
var srcVal = src[key];
if (!hasOwn.call(dest, key)) {
dest[key] = srcVal;
} else {
merge(dest[key], srcVal);
}
});
}
function hasVariableInclusions(directives) {
return apolloUtilities.getInclusionDirectives(directives).some(function (_a) {
var ifArgument = _a.ifArgument;
return ifArgument.value && ifArgument.value.kind === 'Variable';
});
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
function filter(doc, data, variableValues) {
if (variableValues === void 0) {
variableValues = {};
}
var ANONYMOUS = '<<anonymous>>';
function PropTypeError(message) {
this.message = message;
this.stack = '';
var resolver = function (fieldName, root, args, context, info) {
return root[info.resultKey];
};
return Array.isArray(data) ? data.map(function (dataObj) {
return graphql(resolver, doc, dataObj, null, variableValues);
}) : graphql(resolver, doc, data, null, variableValues);
}
function check(doc, data, variables) {
if (variables === void 0) {
variables = {};
}
PropTypeError.prototype = Error.prototype;
var reactPropTypeLocationNames = {
prop: 'prop',
context: 'context',
childContext: 'child context',
var resolver = function (fieldName, root, args, context, info) {
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(hasOwnProperty.call(root, info.resultKey) || !variables && hasVariableInclusions(info.field.directives), 1) : (0, _tsInvariant.invariant)(hasOwnProperty.call(root, info.resultKey) || !variables && hasVariableInclusions(info.field.directives), info.resultKey + " missing on " + JSON.stringify(root));
return root[info.resultKey];
};
function createChainableTypeChecker(validate) {
function checkType(isRequired, props, propName, componentName, location, propFullName) {
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (props[propName] == null) {
var locationName = reactPropTypeLocationNames[location];
if (isRequired) {
if (props[propName] === null) {
return new PropTypeError("The " + locationName + " `" + propFullName + "` is marked as required " +
("in `" + componentName + "`, but its value is `null`."));
}
return new PropTypeError("The " + locationName + " `" + propFullName + "` is marked as required in " +
("`" + componentName + "`, but its value is `undefined`."));
}
return null;
}
else {
return validate(props, propName, componentName, location, propFullName);
}
graphql(resolver, doc, data, {}, variables, {
fragmentMatcher: function () {
return false;
}
});
}
function hasVariableInclusions(directives) {
return (0, _apolloUtilities.getInclusionDirectives)(directives).some(function (_a) {
var ifArgument = _a.ifArgument;
return ifArgument.value && ifArgument.value.kind === 'Variable';
});
}
var ANONYMOUS = '<<anonymous>>';
function PropTypeError(message) {
this.message = message;
this.stack = '';
}
PropTypeError.prototype = Error.prototype;
var reactPropTypeLocationNames = {
prop: 'prop',
context: 'context',
childContext: 'child context'
};
function createChainableTypeChecker(validate) {
function checkType(isRequired, props, propName, componentName, location, propFullName) {
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (props[propName] == null) {
var locationName = reactPropTypeLocationNames[location];
if (isRequired) {
if (props[propName] === null) {
return new PropTypeError("The " + locationName + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
}
return new PropTypeError("The " + locationName + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
}
var chainedCheckType = checkType.bind(null, false);
chainedCheckType.isRequired = checkType.bind(null, true);
return chainedCheckType;
return null;
} else {
return validate(props, propName, componentName, location, propFullName);
}
}
function propType(doc, mapPropsToVariables) {
if (mapPropsToVariables === void 0) { mapPropsToVariables = function (props) { return null; }; }
return createChainableTypeChecker(function (props, propName) {
var prop = props[propName];
try {
if (!prop.loading) {
check(doc, prop, mapPropsToVariables(props));
}
return null;
}
catch (e) {
return e;
}
});
var chainedCheckType = checkType.bind(null, false);
chainedCheckType.isRequired = checkType.bind(null, true);
return chainedCheckType;
}
function propType(doc, mapPropsToVariables) {
if (mapPropsToVariables === void 0) {
mapPropsToVariables = function (props) {
return null;
};
}
exports.check = check;
exports.default = graphql;
exports.filter = filter;
exports.propType = propType;
return createChainableTypeChecker(function (props, propName) {
var prop = props[propName];
Object.defineProperty(exports, '__esModule', { value: true });
try {
if (!prop.loading) {
check(doc, prop, mapPropsToVariables(props));
}
}));
//# sourceMappingURL=bundle.umd.js.map
return null;
} catch (e) {
return e;
}
});
}
var _default = graphql;
_exports.default = _default;
});
{
"name": "graphql-anywhere",
"version": "4.2.2",
"version": "4.2.3",
"description": "Run GraphQL queries with no schema and just one resolver",

@@ -44,7 +44,7 @@ "main": "./lib/bundle.cjs.js",

"dependencies": {
"apollo-utilities": "^1.3.0",
"apollo-utilities": "^1.3.1",
"ts-invariant": "^0.3.2",
"tslib": "^1.9.3"
},
"gitHead": "6838c5b11efb7c12abe0a37ae45061bf4f28c134"
"gitHead": "4db0a7394649d8b21eaa8d5ba06dc2c3b9ee2b3a"
}

Sorry, the diff of this file is not supported yet

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