UNPKG

@theguild/federation-composition

Version:

Open Source Composition library for Apollo Federation

26 lines (25 loc) 812 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSupergraphValidationContext = void 0; function createSupergraphValidationContext(subgraphStates) { let reportedErrors = []; return { subgraphStates, graphIdToName(id) { const found = subgraphStates.get(id); if (!found) { throw new Error(`Could not find subgraph with id ${id}`); } return found.graph.name; }, reportError(error) { reportedErrors.push(error); }, collectReportedErrors() { const errors = reportedErrors; reportedErrors = []; return errors; }, }; } exports.createSupergraphValidationContext = createSupergraphValidationContext;