UNPKG

1.18 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.collectVariables = void 0;
4const graphql_1 = require("graphql");
5function 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}
27exports.collectVariables = collectVariables;
28//# sourceMappingURL=collectVariables.js.map
\No newline at end of file