-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(federation): Require user-defined @tag directive definition when @tag is used #882
fix(federation): Require user-defined @tag directive definition when @tag is used #882
Conversation
trevor-scheer
commented
Jul 16, 2021
•
edited
Loading
edited
- Document new error codes
Could this instead be structured as "require all used directives to be defined, with exceptions made for historical reasons for the Federation Spec directives"? |
Some good discussion spun out of @glasser's comment that resulted in us realizing a great way to do typical SDL validation of the subgraphs. We can perform most of the validations and just omit the rules that make a subgraph invalid + filter against our special federation directives. A snippet, which I'll capture in a separate issue as well. import { federationDirectives } from '../../../directives';
import { specifiedSDLRules } from 'graphql/validation/specifiedRules';
import { validateSDL } from 'graphql/validation/validate';
import { ServiceDefinition } from '../../types';
// import { errorWithCode, logDirective } from '../../utils';
const rulesToExclude = ['KnownTypeNamesRule', 'PossibleTypeExtensionsRule'];
const errorsToFilter = federationDirectives.map(directive => directive.name);
/**
* If there are tag usages in the service definition, check that the tag directive
* definition is included and correct.
*/
export const graphqlValidations = ({
name: _serviceName,
typeDefs,
}: ServiceDefinition) => {
const filteredRules = specifiedSDLRules.filter((rule) =>
!rulesToExclude.includes(rule.name),
);
const errors = validateSDL(typeDefs, undefined, filteredRules);
return errors.filter(({ message }) => {
return !errorsToFilter.some(keyWord => message.includes(keyWord));
});
}; Going to apply a similar approach (using graphql-js and specific rules) to accomplish some of this instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't necessarily think we need to add ad hoc "defined correctly" checks before we have a solid pattern but it doesn't hurt. I have a few suggestions below but otherwise looks good.
federation-js/src/composition/validate/preNormalization/tagDirective.ts
Outdated
Show resolved
Hide resolved
5609271
to
7596b53
Compare
Release * @apollo/gateway@0.34.0 * @apollo/federation@0.27.0 * @apollo/harmonizer@0.27 * @apollo/query-planner@0.3.0 PRs: * feat(gateway): Default to Uplink for composed supergraph managed federation (#881) * fix(federation): Require user-defined @tag directive definition (#882) * Remove @inaccessible elements when converting to API schema (#807) * Move toAPISchema call into try/catch block (#894) * fix(gateway): Prevent inaccessible type names from being leaked in error messages (#893) * docs: rm instruction to set APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT for Uplink (#899) * fix(gateway): Remove path, query and variables field from subgraph error responses (#900)