@graphql-mesh/transport-common
Version:
44 lines (40 loc) • 1.08 kB
JavaScript
import { GraphQLScalarType, valueFromASTUntyped } from 'graphql';
export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
export { getDocumentString } from '@envelop/core';
export { defaultPrintFn } from '@graphql-tools/executor-common';
const ObjMapScalar = new 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 valueFromASTUntyped(ast, variables);
}
});
function abortSignalAny(signals) {
return AbortSignal.any(signals);
}
export { ObjMapScalar, abortSignalAny };