1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.collectVariables = void 0;
|
4 | const graphql_1 = require("graphql");
|
5 | function collectVariables(schema, documentAST) {
|
6 | const variableToType = Object.create(null);
|
7 | documentAST.definitions.forEach(definition => {
|
8 | if (definition.kind === 'OperationDefinition') {
|
9 | const variableDefinitions = definition.variableDefinitions;
|
10 | if (variableDefinitions) {
|
11 | variableDefinitions.forEach(({ variable, type }) => {
|
12 | const inputType = graphql_1.typeFromAST(schema, type);
|
13 | if (inputType) {
|
14 | variableToType[variable.name.value] = inputType;
|
15 | }
|
16 | else if (type.kind === graphql_1.Kind.NAMED_TYPE) {
|
17 | if (type.name.value === 'Float') {
|
18 | variableToType[variable.name.value] = graphql_1.GraphQLFloat;
|
19 | }
|
20 | }
|
21 | });
|
22 | }
|
23 | }
|
24 | });
|
25 | return variableToType;
|
26 | }
|
27 | exports.collectVariables = collectVariables;
|
28 |
|
\ | No newline at end of file |