@theguild/federation-composition
Version:
Open Source Composition library for Apollo Federation
21 lines (20 loc) • 751 B
JavaScript
import { GraphQLError } from "graphql";
export function InterfaceObjectUsageErrorRule(context) {
return {
InterfaceType(interfaceState) {
if (!interfaceState.hasInterfaceObject) {
return;
}
for (const [_, interfaceStateInGraph] of interfaceState.byGraph) {
if (!interfaceStateInGraph.isInterfaceObject) {
return;
}
}
context.reportError(new GraphQLError(`Type "${interfaceState.name}" is declared with in all the subgraphs in which is is defined`, {
extensions: {
code: "INTERFACE_OBJECT_USAGE_ERROR",
},
}));
},
};
}