graph-viewer
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.
More from cognitedata/builder-skills
use-topbar
>-
60code-quality
MUST be used whenever reviewing a Flows app for code quality, maintainability, or clean code issues — before a PR review, after a feature is complete, or when the user asks for a code review. Do NOT skip linting steps. Triggers: code quality, code review, clean code, refactor, maintainability, technical debt, any type, naming, dead code, duplication, DRY, single responsibility, component size, lint, linting, TypeScript strict, dependency injection, file structure.
60skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch for Claude Code or Cursor, update or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
60integrate-todo-list
MUST be used whenever adding a task/todo list feature to a Flows app with Atlas chat. Do NOT manually create todo state management or tool definitions — this skill handles the full module (context, provider, tool, hooks, UI components) and all integration wiring. Prerequisite: integrate-atlas-chat must already be set up. Triggers: todo list, task list, task tracking, TodoWrite, todo panel, task panel, progress tracking, add todos, add tasks.
60correctness-and-error-handling
MUST be used whenever fixing correctness and error handling issues in a Flows app. This skill finds AND fixes bugs, missing error states, unhandled rejections, and edge-case failures — it does not just report them. Triggers: correctness, error handling, bug fix, edge case, crash, unhandled, null, undefined, empty state, loading state, error boundary, try catch, async error, useEffect cleanup, type guard, runtime error, robustness.
60security
MUST be used whenever fixing security issues in a Flows app, or before shipping any feature that handles credentials, user input, or external data. This skill finds AND fixes security problems — it does not just report them. Do NOT skip this when the user asks for a security fix, security hardening, or vulnerability remediation — run every step in order. Triggers: security, security fix, security hardening, vulnerability, XSS, injection, credentials, secrets, auth, authentication, authorization, token, sensitive data, input validation, CORS, CSP, dependency audit.
59