1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.validateWithCustomRules = void 0;
|
4 | const graphql_1 = require("graphql");
|
5 | const ExecutableDefinitions_1 = require("graphql/validation/rules/ExecutableDefinitions");
|
6 | function validateWithCustomRules(schema, ast, customRules, isRelayCompatMode) {
|
7 | const rules = graphql_1.specifiedRules.filter(rule => {
|
8 | if (rule === graphql_1.NoUnusedFragmentsRule || rule === ExecutableDefinitions_1.ExecutableDefinitions) {
|
9 | return false;
|
10 | }
|
11 | if (isRelayCompatMode && rule === graphql_1.KnownFragmentNamesRule) {
|
12 | return false;
|
13 | }
|
14 | return true;
|
15 | });
|
16 | if (customRules) {
|
17 | Array.prototype.push.apply(rules, customRules);
|
18 | }
|
19 | const errors = graphql_1.validate(schema, ast, rules);
|
20 | return errors.filter(error => {
|
21 | if (error.message.indexOf('Unknown directive') !== -1 && error.nodes) {
|
22 | const node = error.nodes[0];
|
23 | if (node && node.kind === graphql_1.Kind.DIRECTIVE) {
|
24 | const name = node.name.value;
|
25 | if (name === 'arguments' || name === 'argumentDefinitions') {
|
26 | return false;
|
27 | }
|
28 | }
|
29 | }
|
30 | return true;
|
31 | });
|
32 | }
|
33 | exports.validateWithCustomRules = validateWithCustomRules;
|
34 |
|
\ | No newline at end of file |