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