Block Protocol Graph

Graph-service APIs for blocks and embedding applications

Block ProtocolTypeScriptBeta↓ 1.7M

IntroductionCopy link to this section

@blockprotocol/graph implements the Block Protocol Graph service. Blocks use it to request and update graph data; embedding applications use it to handle those requests and supply data to blocks.

Published release: 0.5.1 on npm.

InstallationCopy link to this section

Shell
yarn add @blockprotocol/graph

Entry pointsCopy link to this section

Import pathProvides
@blockprotocol/graphGraph service types and the GraphBlockHandler and GraphEmbedderHandler message handlers.
@blockprotocol/graph/reactHooks for connecting React blocks and embedding applications to the Graph service.
@blockprotocol/graph/custom-elementThe BlockElementBase class for blocks built with Lit custom elements.
@blockprotocol/graph/stdlibHelpers for reading subgraph roots, entities, and links.
@blockprotocol/graph/codegenUtilities for generating TypeScript definitions from entity types.

Build a block or embedderCopy link to this section

The block development guide covers receiving a block entity subgraph, reading its contents, and sending graph requests. The types guide explains entity type code generation.

For embedding applications, create a GraphEmbedderHandler for each block and provide callbacks for the requests your application supports. See the package README for handler setup and the Graph service specification for message definitions.

The package depends on Block Protocol Type System for the shared types used to describe graph data.