UNPKG

graphile-build

Version:

Build a GraphQL schema from plugins

30 lines 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NodeIdCodecBase64JSONPlugin = void 0; require("graphile-config"); exports.NodeIdCodecBase64JSONPlugin = { name: "NodeIdCodecBase64JSONPlugin", version: "1.0.0", description: `Adds the 'base64JSON' codec for NodeIDs`, schema: { hooks: { init(_, build) { if (!build.registerNodeIdCodec) { return _; } const { EXPORTABLE, grafast: { markSyncAndSafe }, } = build; build.registerNodeIdCodec(EXPORTABLE((markSyncAndSafe) => ({ name: "base64JSON", encode: markSyncAndSafe(function base64JSONEncode(value) { return Buffer.from(JSON.stringify(value), "utf8").toString("base64"); }), decode: markSyncAndSafe(function base64JSONDecode(value) { return JSON.parse(Buffer.from(value, "base64").toString("utf8")); }), }), [markSyncAndSafe], "base64JSONNodeIdCodec")); return _; }, }, }, }; //# sourceMappingURL=NodeIdCodecBase64JSONPlugin.js.map