Custom Graphs
This guide will introduce the concept of Custom Graphs and how to create and manage them.
This guide provides an introduction to the concept of Custom Graphs. More information will be provided in due course.
As outlined in the Graph concept page, there are two classes of Graph instances:
The Global Graph: This is the default, familiar graph, encompassing all connections to date.
Custom Graphs: These are app-specific graphs, accessible openly or governed by Graph Rules.
Create a Custom Graph
To create a Graph, you need to:
Create a Graph Metadata object
Upload the Graph Metadata object onto a public URI.
Deploy the Lens Graph smart contract.
See the Lens Metadata Standards guide for more information on creating and hosting Metadata objects.
- TS/JS
- JSON Schema
Use the @lens-protocol/metadata package to construct a valid GraphMetadata object:
Example
import { graph } from "@lens-protocol/metadata";
const metadata = graph({ name: "XYZ", title: "Not Just Another Graph… or is it?", description: "My custom graph description",});
Then, upload the Graph Metadata object to a public URI.
import { uploadJson } from "./my-upload-lib";
const metadataURI = await uploadJson(metadata); // e.g., lens://4f91ca…
- GraphQL
- React
- TypeScript
You can use the createGraph mutation to deploy the Lens Graph smart contract.
You MUST be authenticated as Builder to make this request.
Finally, handle the result as explained in the Transaction Lifecycle guide.
Fetch a Graph
- GraphQL
- React
- TypeScript
Use the graph query to fetch a single Graph by address or by transaction hash.