UNPKG

graphql-mocks

Version:
41 lines (31 loc) 1.86 kB
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); }); }; } import { clone } from 'ramda'; import { embed } from '../resolver-map/embed.js'; import { embedPackOptionsWrapper } from './utils/embed-pack-options-wrapper.js'; import { normalizePackOptions, defaultPackOptions } from './utils/normalize-pack-options.js'; var pack = /*#__PURE__*/function () { var _pack = _asyncToGenerator(function* () { var initialResolversMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var middlewares = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var packOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultPackOptions; middlewares = [...middlewares, embed({ wrappers: [embedPackOptionsWrapper] })]; // make an initial copy var wrappedMap = clone(initialResolversMap); packOptions = normalizePackOptions(packOptions); for (var middleware of middlewares) { wrappedMap = yield middleware(wrappedMap, packOptions); } return { resolverMap: wrappedMap, state: packOptions.state }; }); function pack() { return _pack.apply(this, arguments); } return pack; }(); export { pack }; //# sourceMappingURL=pack.js.map