---
title: "Graphs hooks"
description: "Hand-written shim. Generated graph CRUD via ./graphs.gen. The hooks below
cover (a) the `data` query — full graph load (instance + nodes + edges) —
and (b) graph-node / graph-edge composite hooks that don't fit the
standard CRUD kinds.

GraphDefinition hooks (CRUD + node/edge definition helpers) live in
./graph-definitions.ts."
section: "Libraries"
group: "React hooks"
order: 427
---

## Hooks

### `useDeleteGraph` `mutation`

Soft-delete a graph instance.

```ts
useDeleteGraph(options?: MutationOpts<SuccessResponse, string>)
```

**Types:** [SuccessResponse](/types/success-response)

### `useGetGraphData` `query`

Load the full graph — instance metadata plus every node and edge.
Custom hook: backed by the bespoke `/api/graphs/:id/data` endpoint that
doesn't fit the standard CRUD kinds.

```ts
useGetGraphData(graphId: string, options?: QueryOpts)
```

```ts
const { data } = useGetGraphData("grp_abc123");
```

### `useListGraphEdges` `query`

```ts
useListGraphEdges(params: { graph_id: string; [k: string]: unknown; }, options?: QueryOpts)
```

### `useListGraphNodes` `query`

```ts
useListGraphNodes(params: { graph_id: string; [k: string]: unknown; }, options?: QueryOpts)
```

### `useListGraphs` `query`

List graph instances.

```ts
useListGraphs(params?: Omit<ListGraphsParams, | > & { filter?: GraphFilter; orderBy?: GraphOrderBy[]; } & GraphShorthands, options?: QueryOpts<Page<Graph>>)
```

**Types:** [ListGraphsParams](/types/list-graphs-params) · [GraphFilter](/types/graph-filter) · [GraphOrderBy](/types/graph-order-by) · [GraphShorthands](/types/graph-shorthands) · [Page](/types/page) · [Graph](/types/graph)

### `usePurgeGraph` `composite`

Permanently delete a soft-deleted graph instance.

```ts
usePurgeGraph(options?: MutationOpts<SuccessResponse, PurgeGraphParams>)
```

**Types:** [SuccessResponse](/types/success-response) · [PurgeGraphParams](/types/purge-graph-params)

### `useRemoveGraphNode` `mutation`

```ts
useRemoveGraphNode(options?: MutationOpts<unknown, string>)
```

### `useRestoreGraph` `composite`

Restore a soft-deleted graph instance.

```ts
useRestoreGraph(options?: MutationOpts<Graph, string>)
```

**Types:** [Graph](/types/graph)

### `useRetrieveGraph` `query`

Get a graph instance by ID.

```ts
useRetrieveGraph(id: string, options?: QueryOpts<Graph>)
```

**Types:** [Graph](/types/graph)

### `useRetrieveGraphEdge` `query`

```ts
useRetrieveGraphEdge(id: string, options?: QueryOpts)
```

### `useRetrieveGraphNode` `query`

```ts
useRetrieveGraphNode(id: string, options?: QueryOpts)
```
