graphql-introspection-filtering
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -16,67 +16,24 @@ "use strict"; | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
var _default = function _default(subject, filter) { | ||
var originalResolver = subject.resolve || _graphql.defaultFieldResolver; | ||
subject.resolve = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(root, args, context, info) { | ||
var result; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return originalResolver(root, args, context, info); | ||
subject.resolve = function (root, args, context, info) { | ||
var result = originalResolver(root, args, context, info); | ||
case 2: | ||
result = _context.sent; | ||
if (Object.prototype.hasOwnProperty.call(info.schema, _symbol.default)) { | ||
if (Array.isArray(result)) { | ||
return result.reduce(function (acc, field) { | ||
if (filter(field, root, args, context, info)) { | ||
acc.push(field); | ||
} | ||
if (!Object.prototype.hasOwnProperty.call(info.schema, _symbol.default)) { | ||
_context.next = 10; | ||
break; | ||
} | ||
return acc; | ||
}, []); | ||
} else if (result && _typeof(result) === 'object' && !filter(result, root, args, context, info)) { | ||
return null; | ||
} | ||
} | ||
if (!Array.isArray(result)) { | ||
_context.next = 8; | ||
break; | ||
} | ||
return _context.abrupt("return", result.reduce(function (acc, field) { | ||
if (filter(field, root, args, context, info)) { | ||
acc.push(field); | ||
} | ||
return acc; | ||
}, [])); | ||
case 8: | ||
if (!(result && _typeof(result) === 'object' && !filter(result, root, args, context, info))) { | ||
_context.next = 10; | ||
break; | ||
} | ||
return _context.abrupt("return", null); | ||
case 10: | ||
return _context.abrupt("return", result); | ||
case 11: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
return function (_x, _x2, _x3, _x4) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
return result; | ||
}; | ||
}; | ||
@@ -83,0 +40,0 @@ |
{ | ||
"name": "graphql-introspection-filtering", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "storybook.js addon generating documentation using react-docgen", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
27900
217