graph-viewer
cognitedata/builder-skills
Embed interactive CDF graph visualizations in Flows apps with nodes, relations, and data model instances.
What is graph-viewer?
Integrates a reusable React hook (useGraphViewer) to render interactive graphs of CDF data models, relationships, and instances inside a Flows application. Use this when you need to visualize knowledge graphs, data model structures, or connected CDF entities within your app.
- Renders interactive WebGL-powered graph visualization of CDF data model nodes and relationships
- Fetches and displays direct relations, reverse relations, and edges from CDF instances
- Provides node-type legend with icons and expandable connection traversal
- Supports configurable whitelisting of relation properties and connection limits to optimize CDF API costs
- Includes LRU buffer with configurable max nodes for memory-efficient large graph handling
How to install graph-viewer
npx skills add https://github.com/cognitedata/builder-skills --skill graph-viewer- App wrapped in @cognite/dune's <DuneProvider> with authenticated SDK access
- Target data model exists in CDF with known space, externalId, and version
- React 18+ and TypeScript in the target application
- Container element with explicit height for GraphCanvas rendering
How to use graph-viewer
- 1.Inspect the target app's package.json and folder structure to understand conventions
- 2.Install required dependencies (@cognite/sdk, @cognite/dune, reagraph, lucide-react) using the app's package manager
- 3.Copy all files from skills/graph-viewer/code/ into an app-local folder (e.g., src/features/graph-viewer/)
- 4.Import useGraphViewer from the local folder path, not from @skills/
- 5.Call useGraphViewer with dataModel and instance configuration to get GraphCanvas component
- 6.Render GraphCanvas inside a container with explicit height and width CSS classes
- 7.Run typecheck (tsc --noEmit) and build to verify no path or type errors
- 8.Optionally tune CDF performance by setting whitelistedRelationProps, initialConnectionLimit, and maxNodes
Use cases
- Visualize a pump asset and all connected equipment, sensors, and maintenance records in a data model
- Display a knowledge graph of organizational relationships, dependencies, and metadata within CDF
- Embed a data model schema browser showing entity types, properties, and relationships in a Flows dashboard
- Explore reverse relations to find all instances referencing a particular asset or entity
- React/TypeScript developers building Flows apps with CDF data models
- Data engineers and analysts embedding graph exploration into dashboards
- Teams managing complex asset hierarchies or knowledge graphs in CDF
graph-viewer FAQ
No. This skill is specifically for interactive CDF data model graphs. Do not use it for static diagrams, pure dataflow visualizations, or graphs not backed by CDF.
Set whitelistedRelationProps to only the properties you need, lower initialConnectionLimit to reduce connections fetched per expansion, reduce maxNodes to bound the in-memory buffer, and only declare coreReverseQueries for relations your app must surface.
Yes. Always defer to the React version already pinned by the target app rather than upgrading. The same applies to other dependencies the app already pins.
GraphCanvas requires an explicit height to render properly. If the container lacks height, the graph will not display. Ensure the parent element has a defined height (e.g., h-[600px]).
Always import from the app-local folder (e.g., @/features/graph-viewer) after copying the code bundle. Never import from @skills/...
Full instructions (SKILL.md)
Source of truth, from cognitedata/builder-skills.
name: graph-viewer description: Integrate the reusable CDF graph viewer (useGraphViewer) into a Flows app by copying the local code bundle. Use when embedding a graph visualization, adding a knowledge graph, or showing CDF data model relationships and instances.
Graph Viewer
Use This When
The user wants to embed an interactive graph of a CDF data model — nodes, direct relations, edges, and reverse relations — inside a Flows app.
Do not use this skill for static diagrams, pure dataflow visualizations, or non-CDF graphs.
Prerequisites
- The app is wrapped in
@cognite/dune's<DuneProvider>souseDune()returns an authenticated SDK. - The target data model exists in CDF and you know its
space,externalId, andversion. - The app uses React 18+ and TypeScript.
Integration Workflow
Follow these steps in order. Adapt to the target repo's conventions instead of inventing new ones.
-
Inspect the target app. Read
package.jsonand look at the existing folder structure (e.g.src/features/*,src/components/*, path aliases like@/*). -
Install missing dependencies with the app's package manager (
npm,pnpm,yarn, …). See the Dependencies table below for purposes and suggested versions. Reuse the React version already pinned by the app rather than upgrading it, and prefer any versions the repo already pins over the suggestions here. -
Copy the bundle into the app. Copy every file from
skills/graph-viewer/code/into an app-local feature folder, for example:src/features/graph-viewer/If the repo already has a different feature/components layout or alias, mirror it.
-
Import from the local folder, never from
@skills/.... With a typical@/*alias:import { useGraphViewer } from "@/features/graph-viewer"; -
Render
GraphCanvasinside a container with explicit dimensions (height is required — see the minimal example below). -
Run typecheck and build (
tsc --noEmit,npm run build, etc.) and fix any path or type issues introduced by the copy.
Minimal Example
import { useGraphViewer } from "@/features/graph-viewer";
export function GraphPanel() {
const { GraphCanvas, isLoading, error } = useGraphViewer({
dataModel: { space: "my-space", externalId: "my-data-model", version: "1" },
instance: { space: "my-instance-space", externalId: "pump-001" },
});
if (isLoading) return <div>Loading graph…</div>;
if (error) return <div>Error: {error}</div>;
return <GraphCanvas className="h-[600px] w-full" />;
}
Dependencies
Suggested versions reflect the latest published majors at the time of writing. They are starting points — if the target app already pins different versions, defer to the app.
| Package | Suggested version | Purpose |
|---|---|---|
react | ^18.2.0 | UI framework (peer; reuse the app's version) |
@cognite/sdk | ^10.10.0 | CDF API client (instances, data models) |
@cognite/dune | ^2.1.0 | Provides the authenticated SDK via useDune() |
reagraph | ^4.30.8 | WebGL graph rendering engine |
lucide-react | ^1.14.0 | Icon set used by the node-type legend |
Example install (npm; adapt to the app's package manager):
npm install @cognite/sdk@^10.10.0 @cognite/dune@^2.1.0 reagraph@^4.30.8 lucide-react@^1.14.0
CDF Cost & Performance
Graph expansion can issue many CDF requests, especially with reverse relations. For large or unfamiliar data models, be conservative:
- Set
whitelistedRelationPropsto the few properties the app actually needs to traverse. - Lower
initialConnectionLimit(it is a hard maximum of connections fetched per expansion). - Lower
maxNodesto bound the in-memory LRU buffer. - Only declare
coreReverseQueriesfor relations the app must surface; each entry adds an extra query per expansion.
Tuples in coreReverseQueries are version-aware:
[space, viewExternalId, viewVersion, propertyName, isList].
Advanced Reference
For full configuration tables, return-value docs, layouts, theming, and richer examples, read code/README.md.
For implementation details, inspect the source files under code/.
Verification Checklist
- The app is wrapped in
<DuneProvider>. - All files from
skills/graph-viewer/code/were copied into an app-local folder. - Imports point to the app-local folder (e.g.
@/features/graph-viewer), not@skills/.... -
@cognite/dune,@cognite/sdk,reagraph, andlucide-reactare present inpackage.json. - The container that renders
<GraphCanvas>has an explicit height. -
tsc --noEmitand the app's build both pass. - No references to
dune-industrial-componentswere introduced.
Related skills
More from cognitedata/builder-skills and the wider catalog.

integrate-atlas-chat
Integrate streaming Atlas Agent chat UI into Flows apps with automatic component and hook setup.

integrate-file-viewer
Integrate CogniteFileViewer into Flows apps to preview CDF files (PDFs, images, text) with zero manual setup.

integrate-fusion-agent
Integrate your Flows/Dune app with Fusion's built-in PAIA agent panel using @cognite/app-sdk.

integrate-todo-list
Add structured task tracking to Flows apps with Atlas chat integration.

migrate-app-to-flows
Orchestrate full migration of legacy Dune apps to Flows app hosting infrastructure.

performance
Find and fix performance issues in Flows apps—re-renders, inefficient queries, pagination, and memory leaks.