1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getQueryFacts = exports.getOperationASTFacts = void 0;
|
4 | const graphql_1 = require("graphql");
|
5 | const collectVariables_1 = require("./collectVariables");
|
6 | function getOperationASTFacts(documentAST, schema) {
|
7 | const variableToType = schema
|
8 | ? collectVariables_1.collectVariables(schema, documentAST)
|
9 | : undefined;
|
10 | const operations = [];
|
11 | graphql_1.visit(documentAST, {
|
12 | OperationDefinition(node) {
|
13 | operations.push(node);
|
14 | },
|
15 | });
|
16 | return { variableToType, operations };
|
17 | }
|
18 | exports.getOperationASTFacts = getOperationASTFacts;
|
19 | function getOperationFacts(schema, documentString) {
|
20 | if (!documentString) {
|
21 | return;
|
22 | }
|
23 | try {
|
24 | const documentAST = graphql_1.parse(documentString);
|
25 | return Object.assign(Object.assign({}, getOperationASTFacts(documentAST, schema)), { documentAST });
|
26 | }
|
27 | catch (_a) {
|
28 | return;
|
29 | }
|
30 | }
|
31 | exports.default = getOperationFacts;
|
32 | exports.getQueryFacts = getOperationFacts;
|
33 |
|
\ | No newline at end of file |