Block Protocol Graph
Graph-service APIs for blocks and embedding applications
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.
View on GitHub
View package source code in our hash monorepo
View on npm
or use npm install @blockprotocol/graph
InstallationCopy link to this section
yarn add @blockprotocol/graphEntry pointsCopy link to this section
| Import path | Provides |
|---|---|
@blockprotocol/graph | Graph service types and the GraphBlockHandler and GraphEmbedderHandler message handlers. |
@blockprotocol/graph/react | Hooks for connecting React blocks and embedding applications to the Graph service. |
@blockprotocol/graph/custom-element | The BlockElementBase class for blocks built with Lit custom elements. |
@blockprotocol/graph/stdlib | Helpers for reading subgraph roots, entities, and links. |
@blockprotocol/graph/codegen | Utilities 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.