---
title: "Graph Definitions hooks"
description: "Hand-written shim. Generated CRUD hooks via ./graph-definitions.gen
(`useListGraphDefinitions`, `useCreateGraphDefinition`,
`useRetrieveGraphDefinition`, `useUpdateGraphDefinition`,
`useDeleteGraphDefinition`, `useRestoreGraphDefinition`). Hooks below
cover the node-definition / edge-definition sub-resources, the
graphs-of-definition sub-resource, and the extract / save-instance ops —
none of which fit the manifest's standard CRUD kinds."
section: "Libraries"
group: "React hooks"
order: 424
---

## Hooks

### `useAddGraphEdgeDefinition` `mutation`

Add an edge definition to a graph definition.

```ts
useAddGraphEdgeDefinition(options?: MutationOpts<GraphEdgeDefinition, AddGraphEdgeDefinitionVars>)
```

**Types:** [GraphEdgeDefinition](/types/graph-edge-definition)

### `useAddGraphNodeDefinition` `mutation`

Add a node definition to a graph definition.

```ts
useAddGraphNodeDefinition(options?: MutationOpts<GraphNodeDefinition, AddGraphNodeDefinitionVars>)
```

**Types:** [GraphNodeDefinition](/types/graph-node-definition)

### `useCreateGraphDefinition` `mutation`

Create a new graph definition.

```ts
useCreateGraphDefinition(options?: MutationOpts<GraphDefinition, CreateGraphDefinitionParams>)
```

**Types:** [GraphDefinition](/types/graph-definition) · [CreateGraphDefinitionParams](/types/create-graph-definition-params)

### `useCreateGraphInstance` `mutation`

Create a graph instance under a definition. Pass optional `nodes` and
`edges` to populate atomically (the old `useSaveGraphInstance` flow,
now folded into `createGraph`).

```ts
useCreateGraphInstance(options?: MutationOpts<Graph, CreateGraphInstanceVars>)
```

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

### `useDeleteGraphDefinition` `mutation`

Soft-delete a graph definition and all its instances.

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

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

### `useExtractGraph` `composite`

Extract a graph from text content against a graph definition.

```ts
useExtractGraph(options?: MutationOpts<ExtractGraphResult, ExtractGraphVars>)
```

**Types:** [ExtractGraphResult](/types/extract-graph-result)

### `useListGraphDefinitionGraphs` `query`

List graph instances created from a specific graph definition.
Backed by the canonical top-level `graphs.list({ graph_definition_id })`
(returns the page's `data` array for back-compat).

```ts
useListGraphDefinitionGraphs(graphDefId: string, params?: Record<string, unknown>, options?: QueryOpts<Graph[]>)
```

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

### `useListGraphDefinitions` `query`

List graph definitions.

```ts
useListGraphDefinitions(params?: Omit<ListGraphDefinitionsParams, | > & { filter?: GraphDefinitionFilter; orderBy?: GraphDefinitionOrderBy[]; } & GraphDefinitionShorthands, options?: QueryOpts<Page<GraphDefinition>>)
```

**Types:** [ListGraphDefinitionsParams](/types/list-graph-definitions-params) · [GraphDefinitionFilter](/types/graph-definition-filter) · [GraphDefinitionOrderBy](/types/graph-definition-order-by) · [GraphDefinitionShorthands](/types/graph-definition-shorthands) · [Page](/types/page) · [GraphDefinition](/types/graph-definition)

### `usePurgeGraphDefinition` `composite`

Permanently delete a soft-deleted graph definition.

```ts
usePurgeGraphDefinition(options?: MutationOpts<SuccessResponse, PurgeGraphDefinitionParams>)
```

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

### `useRemoveGraphEdgeDefinition` `mutation`

Remove an edge definition from a graph definition.

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

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

### `useRemoveGraphNodeDefinition` `mutation`

Remove a node definition from a graph definition.

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

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

### `useRestoreGraphDefinition` `composite`

Restore a soft-deleted graph definition.

```ts
useRestoreGraphDefinition(options?: MutationOpts<GraphDefinition, string>)
```

**Types:** [GraphDefinition](/types/graph-definition)

### `useRetrieveGraphDefinition` `query`

Get a graph definition by ID, including node + edge definitions.

```ts
useRetrieveGraphDefinition(id: string, options?: QueryOpts<GraphDefinition>)
```

**Types:** [GraphDefinition](/types/graph-definition)

### `useUpdateGraphDefinition` `mutation`

Update a graph definition.

```ts
useUpdateGraphDefinition(options?: MutationOpts<GraphDefinition, UpdateGraphDefinitionParams>)
```

**Types:** [GraphDefinition](/types/graph-definition) · [UpdateGraphDefinitionParams](/types/update-graph-definition-params)
