UNPKG

graphql-mocks

Version:

Tools for setting up graphql test resolvers

33 lines (32 loc) 1.48 kB
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } import { getTypeForReference } from './get-type-for-reference.mjs'; import { getFieldForReference } from './get-field-for-reference.mjs'; function walk(_x, _x2, _x3) { return _walk.apply(this, arguments); } function _walk() { _walk = _asyncToGenerator(function* (graphqlSchema, references, callback) { for (var reference of references) { if (!Array.isArray(references)) { throw new Error("Expected an array of references, got ".concat(typeof references)); } if (typeof callback !== 'function') { throw new Error("Expected callback to be a function, got ".concat(typeof callback)); } var type = getTypeForReference(graphqlSchema, reference); var field = getFieldForReference(graphqlSchema, reference); if (!type) { continue; } yield callback({ reference, type, field }); } }); return _walk.apply(this, arguments); } export { walk }; //# sourceMappingURL=walk.mjs.map