UNPKG

@pothos/plugin-sub-graph

Version:

A Pothos plugin for creating multiple variants or sub-selections of the same graph

27 lines (26 loc) 928 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "replaceType", { enumerable: true, get: function() { return replaceType; } }); const _core = require("@pothos/core"); const _graphql = require("graphql"); function replaceType(type, newTypes, referencedBy, subGraphs) { if (type instanceof _graphql.GraphQLNonNull) { return new _graphql.GraphQLNonNull(replaceType(type.ofType, newTypes, referencedBy, subGraphs)); } if (type instanceof _graphql.GraphQLList) { return new _graphql.GraphQLList(replaceType(type.ofType, newTypes, referencedBy, subGraphs)); } const newType = newTypes.get(type.name); if (!newType) { throw new _core.PothosSchemaError(`${type.name} (referenced by ${referencedBy}) does not exist in subGraph (${subGraphs})`); } return newType; } //# sourceMappingURL=util.js.map