UNPKG

1.35 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var get_root_1 = require("../utils/get-root");
4var build_selection_set_1 = require("./build-selection-set");
5var transform_variables_1 = require("./transform-variables");
6var debugging_1 = require("../debugging");
7var printer_1 = require("graphql/language/printer");
8function transformOperation(schema, operationNode) {
9 var name = operationNode.name && operationNode.name.value ? operationNode.name.value : '';
10 debugging_1.debugLog("[transformOperation] transforming operation " + name + " of type " + operationNode.operation);
11 var root = get_root_1.getRoot(schema, operationNode);
12 var variables = transform_variables_1.transformVariables(schema, operationNode);
13 return {
14 name: name,
15 selectionSet: build_selection_set_1.buildSelectionSet(schema, root, operationNode.selectionSet),
16 operationType: operationNode.operation,
17 variables: variables,
18 hasVariables: variables.length > 0,
19 isQuery: operationNode.operation === 'query',
20 isMutation: operationNode.operation === 'mutation',
21 isSubscription: operationNode.operation === 'subscription',
22 document: printer_1.print(operationNode),
23 };
24}
25exports.transformOperation = transformOperation;
26//# sourceMappingURL=transform-operation.js.map
\No newline at end of file