@theguild/federation-composition
Version:
Open Source Composition library for Apollo Federation
22 lines (21 loc) • 611 B
JavaScript
export 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;
},
};
}