1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | function validateOrThrow(document, schema, rules) {
|
13 | var validationErrors = require("graphql").validate(schema, document, rules);
|
14 |
|
15 | if (validationErrors && validationErrors.length > 0) {
|
16 | var formattedErrors = validationErrors.map(require("graphql").formatError);
|
17 | var errorMessages = validationErrors.map(function (e) {
|
18 | return e.toString();
|
19 | });
|
20 | var error = new Error(require("util").format('You supplied a GraphQL document with validation errors:\n%s', errorMessages.join('\n')));
|
21 | error.validationErrors = formattedErrors;
|
22 | throw error;
|
23 | }
|
24 | }
|
25 |
|
26 | module.exports = {
|
27 | GLOBAL_RULES: [require("graphql").KnownArgumentNamesRule,
|
28 | |
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | require("graphql").NoUnusedVariablesRule, require("graphql").UniqueArgumentNamesRule, require("graphql").UniqueFragmentNamesRule, require("graphql").UniqueInputFieldNamesRule, require("graphql").UniqueOperationNamesRule, require("graphql").UniqueVariableNamesRule],
|
43 | LOCAL_RULES: [
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | require("graphql").FragmentsOnCompositeTypesRule, require("graphql").KnownTypeNamesRule, require("graphql").LoneAnonymousOperationRule, require("graphql").PossibleFragmentSpreadsRule, require("graphql").ValuesOfCorrectTypeRule, require("graphql").VariablesAreInputTypesRule, require("graphql").VariablesInAllowedPositionRule],
|
53 | validate: require("./GraphQLCompilerProfiler").instrument(validateOrThrow, 'GraphQLValidator.validate')
|
54 | }; |
\ | No newline at end of file |