UNPKG

@graphql-mesh/runtime

Version:
35 lines (34 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isStreamOperation = void 0; exports.getOriginalError = getOriginalError; const graphql_1 = require("graphql"); const core_1 = require("@envelop/core"); const utils_1 = require("@graphql-tools/utils"); exports.isStreamOperation = (0, utils_1.memoize1)(function isStreamOperation(astNode) { if (globalThis.process?.env?.DISABLE_JIT) { return true; } const documentStr = (0, core_1.getDocumentString)(astNode); let isStream = false; if (!documentStr || documentStr.includes('@stream')) { (0, graphql_1.visit)(astNode, { Field: { enter(node) { if (node.directives?.some(d => d.name.value === 'stream')) { isStream = true; return graphql_1.BREAK; } return undefined; }, }, }); } return isStream; }); function getOriginalError(error) { if ((0, core_1.isGraphQLError)(error)) { return getOriginalError(error.originalError); } return error; }