1 | import { Kind } from '../language/kinds';
|
2 | import { visit, visitWithTypeInfo } from '../language/visitor';
|
3 | import { ValuesOfCorrectType } from '../validation/rules/ValuesOfCorrectType';
|
4 | import { ValidationContext } from '../validation/ValidationContext';
|
5 | import { GraphQLSchema } from '../type/schema';
|
6 | import { TypeInfo } from './TypeInfo';
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | export function isValidLiteralValue(type, valueNode) {
|
16 | var emptySchema = new GraphQLSchema({});
|
17 | var emptyDoc = {
|
18 | kind: Kind.DOCUMENT,
|
19 | definitions: []
|
20 | };
|
21 | var typeInfo = new TypeInfo(emptySchema, undefined, type);
|
22 | var context = new ValidationContext(emptySchema, emptyDoc, typeInfo);
|
23 | var visitor = ValuesOfCorrectType(context);
|
24 | visit(valueNode, visitWithTypeInfo(typeInfo, visitor));
|
25 | return context.getErrors();
|
26 | }
|