1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.isValidLiteralValue = isValidLiteralValue;
|
7 |
|
8 | var _TypeInfo = require('./TypeInfo');
|
9 |
|
10 | var _kinds = require('../language/kinds');
|
11 |
|
12 | var _visitor = require('../language/visitor');
|
13 |
|
14 | var _schema = require('../type/schema');
|
15 |
|
16 | var _ValuesOfCorrectType = require('../validation/rules/ValuesOfCorrectType');
|
17 |
|
18 | var _validate = require('../validation/validate');
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | function isValidLiteralValue(type, valueNode) {
|
35 | var emptySchema = new _schema.GraphQLSchema({});
|
36 | var emptyDoc = { kind: _kinds.DOCUMENT, definitions: [] };
|
37 | var typeInfo = new _TypeInfo.TypeInfo(emptySchema, undefined, type);
|
38 | var context = new _validate.ValidationContext(emptySchema, emptyDoc, typeInfo);
|
39 | var visitor = (0, _ValuesOfCorrectType.ValuesOfCorrectType)(context);
|
40 | (0, _visitor.visit)(valueNode, (0, _visitor.visitWithTypeInfo)(typeInfo, visitor));
|
41 | return context.getErrors();
|
42 | } |
\ | No newline at end of file |