UNPKG

@theguild/federation-composition

Version:
28 lines (27 loc) • 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeprecatedInterfaceFieldImplementationRule = DeprecatedInterfaceFieldImplementationRule; const graphql_1 = require("graphql"); function DeprecatedInterfaceFieldImplementationRule(context, supergraph) { function check(typeState, fieldState) { if (!fieldState.deprecated) { return; } for (const interfaceName of typeState.interfaces) { const interfaceField = supergraph.interfaceTypes .get(interfaceName) ?.fields.get(fieldState.name); if (interfaceField && !interfaceField.deprecated) { context.reportError(new graphql_1.GraphQLError(`Interface field ${interfaceName}.${fieldState.name} is not deprecated, so implementation field ${typeState.name}.${fieldState.name} must not be deprecated.`, { extensions: { code: "INVALID_GRAPHQL", }, })); } } } return { ObjectTypeField: check, InterfaceTypeField: check, }; }