GraphReFlyTS

API Reference

withBlueprintHash()

Attach a content hash to a graph blueprint.

Import

import { withBlueprintHash } from "@graphrefly/ts/graph";

Signature

function withBlueprintHash(
	blueprint: GraphBlueprint,
	options: GraphBlueprintHashOptions,
): GraphBlueprint | Promise<GraphBlueprint>

Parameters

ParameterTypeDescription
blueprintGraphBlueprintBlueprint to augment.
optionsGraphBlueprintHashOptionsHash algorithm and hashing function.

Returns

The blueprint with a computed hash field, or a Promise for one.

Example

import { GRAPH_BLUEPRINT_VERSION, normalizeTopology, withBlueprintHash } from "@graphrefly/ts/graph";

const blueprint = {
  version: GRAPH_BLUEPRINT_VERSION,
  topology: normalizeTopology({ nodes: [], edges: [] }),
};
await withBlueprintHash(blueprint, {
  algorithm: "sha256",
  hash: async () => "abc123",
});

Source

packages/ts/src/graph/blueprint.ts