UNPKG

graphql-mocks

Version:
43 lines (30 loc) 1 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var graphql = require('graphql'); var constants = require('./constants.js'); class InterfaceHighlighter { constructor(targets) { if (targets.length === 0) { targets = [constants.HIGHLIGHT_ALL]; } this.targets = targets; } mark(schema) { return InterfaceHighlighter.expandTargets(schema, this.targets); } static expandTargets(schema, targets) { const interfaceTypeNames = Object.values(schema.getTypeMap()).filter(graphql.isInterfaceType).map(i => i.name); if (targets.includes(constants.HIGHLIGHT_ALL)) { return interfaceTypeNames; } return interfaceTypeNames.filter(interfaceName => targets.includes(interfaceName)); } } const interfaces = function type(...interfaceNames) { return new InterfaceHighlighter(interfaceNames); }; exports.InterfaceHighlighter = InterfaceHighlighter; exports.interfaces = interfaces; //# sourceMappingURL=interfaces.js.map