UNPKG

@graphql-mesh/transport-common

Version:
59 lines (55 loc) 1.53 kB
'use strict'; var graphql = require('graphql'); var executor = require('@graphql-tools/executor'); var core = require('@envelop/core'); var executorCommon = require('@graphql-tools/executor-common'); var signal = require('@graphql-hive/signal'); const ObjMapScalar = new graphql.GraphQLScalarType({ name: "ObjMap", serialize: (value) => { if (typeof value === "string") { return value; } const stringifiedValue = JSON.stringify(value); return stringifiedValue; }, parseValue: (value) => { if (value == null) { return null; } if (typeof value === "object") { return value; } try { return JSON.parse(value.toString()); } catch (e) { return value; } }, parseLiteral: (ast, variables) => { if (ast.kind === "StringValue") { try { return JSON.parse(ast.value); } catch (e) { } } return graphql.valueFromASTUntyped(ast, variables); } }); Object.defineProperty(exports, "createDefaultExecutor", { enumerable: true, get: function () { return executor.executorFromSchema; } }); Object.defineProperty(exports, "getDocumentString", { enumerable: true, get: function () { return core.getDocumentString; } }); Object.defineProperty(exports, "defaultPrintFn", { enumerable: true, get: function () { return executorCommon.defaultPrintFn; } }); Object.defineProperty(exports, "abortSignalAny", { enumerable: true, get: function () { return signal.abortSignalAny; } }); exports.ObjMapScalar = ObjMapScalar;