relay-utils
Version:
Utilities for working with Relay (modern) in general, and the Relay store in particular.
25 lines (20 loc) • 732 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createRelayDataId = createRelayDataId;
/**
* This creates a Relay data IDs. It assumes that you're using data IDs like they're
* normally created by graphql-relay-js. If you don't, you likely know how to generate
* your data IDs anyway, so this won't help.
*/
function createRelayDataId(databaseId, typename, base64Encode) {
var constructedId = "".concat(typename, ":").concat(databaseId);
if (base64Encode) {
return base64Encode(constructedId);
}
if (global && global.btoa) {
return global.btoa(constructedId);
}
throw new Error('Missing way to base64-encode ID. Please provide your own base64 encode function.');
}