UNPKG

graphql-mocks

Version:
38 lines (28 loc) 922 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var getTypeForReference = require('./get-type-for-reference.js'); var getFieldForReference = require('./get-field-for-reference.js'); async function walk(graphqlSchema, references, callback) { for (const reference of references) { if (!Array.isArray(references)) { throw new Error(`Expected an array of references, got ${typeof references}`); } if (typeof callback !== 'function') { throw new Error(`Expected callback to be a function, got ${typeof callback}`); } const type = getTypeForReference.getTypeForReference(graphqlSchema, reference); const field = getFieldForReference.getFieldForReference(graphqlSchema, reference); if (!type) { continue; } await callback({ reference, type, field }); } } exports.walk = walk; //# sourceMappingURL=walk.js.map