UNPKG

graphile-build

Version:

Build a GraphQL schema from plugins

30 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NodeIdCodecPipeStringPlugin = void 0; require("graphile-config"); exports.NodeIdCodecPipeStringPlugin = { name: "NodeIdCodecPipeStringPlugin", version: "1.0.0", description: `Adds the 'pipeString' codec for NodeIDs`, schema: { hooks: { init(_, build) { if (!build.registerNodeIdCodec) { return _; } const { EXPORTABLE, grafast: { markSyncAndSafe }, } = build; build.registerNodeIdCodec(EXPORTABLE((markSyncAndSafe) => ({ name: "pipeString", encode: markSyncAndSafe(function pipeStringEncode(value) { return Array.isArray(value) ? value.join("|") : null; }), decode: markSyncAndSafe(function pipeStringDecode(value) { return typeof value === "string" ? value.split("|") : null; }), }), [markSyncAndSafe], "pipeStringNodeIdCodec")); return _; }, }, }, }; //# sourceMappingURL=NodeIdCodecPipeStringPlugin.js.map