Back to Skills

graph-viewer

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.

5stars1forksUpdated 6/29/2026

Security Assessment

Safe(100/100)
Security Score100/100

About graph-viewer

Integrates a reusable CDF graph viewer, exposed through a useGraphViewer hook, into a Flows app by copying a local code bundle rather than installing a package. It is intended for embedding an interactive graph of a CDF data model, including nodes, direct relations, edges, and reverse relations, and is explicitly not for static diagrams, pure dataflow visualizations, or non-CDF graphs. Prerequisites are that the app is wrapped in @cognite/dune's DuneProvider so useDune() returns an authenticated SDK, that the target data model's space, externalId, and version are known, and that the app uses React 18+ with TypeScript.

The integration workflow is ordered and adapts to the target repo's conventions: inspect the app's package.json and folder structure and path aliases, install any missing dependencies with the app's package manager, copy every file from the skill's code bundle into an app-local feature folder (for example src/features/graph-viewer/), import from that local folder rather than from an @skills path, render GraphCanvas inside a container with an explicit height, and run typecheck and build to fix any path or type issues introduced by the copy. A minimal example shows useGraphViewer taking a dataModel (space, externalId, version) and an instance (space, externalId) and returning GraphCanvas along with isLoading and error for handling loading and error states. Suggested dependencies include react (peer, reusing the app's version), @cognite/sdk, @cognite/dune, reagraph as the WebGL rendering engine, and lucide-react for the node-type legend icons, with the guidance to defer to versions the app already pins.

Because graph expansion can issue many CDF requests (especially with reverse relations), the skill provides cost and performance controls: set whitelistedRelationProps to only the properties the app needs to traverse, lower initialConnectionLimit (a hard maximum of connections fetched per expansion), lower maxNodes to bound the in-memory LRU buffer, and declare coreReverseQueries only for relations that must be surfaced, noting those tuples are version-aware in the form [space, viewExternalId, viewVersion, propertyName, isList]. A verification checklist confirms DuneProvider wrapping, that the bundle was copied locally with imports pointing at the local folder, that required dependencies are present, that the GraphCanvas container has an explicit height, that typecheck and build pass, and that no references to dune-industrial-components were introduced. Fuller configuration, return-value docs, layouts, and theming live in the bundle's code/README.md.

FAQ

How is the graph viewer added to a project?

By copying every file from the skill's code bundle into an app-local feature folder (for example src/features/graph-viewer/) and importing useGraphViewer from that local folder, rather than installing a package or importing from an @skills path.

What are the prerequisites for using it?

The app must be wrapped in @cognite/dune's DuneProvider so useDune() returns an authenticated SDK, you must know the target data model's space, externalId, and version, and the app must use React 18+ with TypeScript.

What dependencies does it rely on?

react (a peer dependency, reusing the app's version), @cognite/sdk, @cognite/dune, reagraph as the WebGL graph rendering engine, and lucide-react for the node-type legend icons. You should defer to any versions the app already pins.

How do I keep graph expansion from issuing too many CDF requests?

Set whitelistedRelationProps to only the properties you need to traverse, lower initialConnectionLimit (a hard maximum of connections per expansion) and maxNodes (which bounds the in-memory LRU buffer), and declare coreReverseQueries only for relations you must surface.

Is there anything required when rendering GraphCanvas?

Yes. GraphCanvas must be rendered inside a container with an explicit height, and the verification checklist also calls for passing typecheck and build and confirming no references to dune-industrial-components were introduced.

All Files

16 files
code/graph-config.ts8.2 KB
View
code/GraphViewerCanvas.tsx4.9 KB
View
code/index.ts0.4 KB
View
code/types.ts11.7 KB
View
code/useDataModelLoader.ts2.2 KB
View
code/useGraphSelection.ts2.2 KB
View
code/useNodeBuffer.ts3.7 KB
View
code/ZoomControls.tsx3.2 KB
View
code/graph-service.ts25.2 KB
View
code/GraphViewerLegend.tsx4.3 KB
View
code/README.md13.3 KB
View
code/useCanvasResize.ts0.8 KB
View
code/useGraphDataPipeline.ts2.9 KB
View
code/useGraphViewer.tsx7.5 KB
View
code/useSeedNode.ts2.9 KB
View
SKILL.md4.9 KB
View

Install graph-viewer

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill