# pub.chive.graph.getHierarchy

> Published by [chive.pub](https://lexicon.garden/identity/did:plc:7natp5xae72bddaqlkef2t4e)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:7natp5xae72bddaqlkef2t4e/pub.chive.graph.getHierarchy)
- [Documentation](https://lexicon.garden/lexicon/did:plc:7natp5xae72bddaqlkef2t4e/pub.chive.graph.getHierarchy/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:7natp5xae72bddaqlkef2t4e/pub.chive.graph.getHierarchy/examples)

## Definitions

### `pub.chive.graph.getHierarchy`

**Type**: `query`

Get hierarchical tree structure for nodes of a specific subkind

#### Parameters

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `subkind` | `string` | Yes | Subkind to get hierarchy for (e.g., field) |
| `relationSlug` | `string` | No | Relation slug for hierarchy traversal |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `roots` | `array` | Yes | Root nodes with children |
| `subkind` | `string` | Yes | Subkind of hierarchy |
| `relationSlug` | `string` | Yes | Relation used for hierarchy |

### `pub.chive.graph.getHierarchy#hierarchyItem`

**Type**: `object`

Hierarchy node with recursive children

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `node` | `ref` → `pub.chive.graph.listNodes#graphNode` | Yes | Node data |
| `depth` | `integer` | Yes | Depth in hierarchy (0 = root) |
| `children` | `array` | Yes | Child hierarchy items |

## Raw Schema

```json
{
  "id": "pub.chive.graph.getHierarchy",
  "defs": {
    "main": {
      "type": "query",
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "roots",
            "subkind",
            "relationSlug"
          ],
          "properties": {
            "roots": {
              "type": "array",
              "items": {
                "ref": "#hierarchyItem",
                "type": "ref"
              },
              "description": "Root nodes with children"
            },
            "subkind": {
              "type": "string",
              "description": "Subkind of hierarchy"
            },
            "relationSlug": {
              "type": "string",
              "description": "Relation used for hierarchy"
            }
          }
        },
        "encoding": "application/json"
      },
      "parameters": {
        "type": "params",
        "required": [
          "subkind"
        ],
        "properties": {
          "subkind": {
            "type": "string",
            "description": "Subkind to get hierarchy for (e.g., field)"
          },
          "relationSlug": {
            "type": "string",
            "default": "broader",
            "description": "Relation slug for hierarchy traversal"
          }
        }
      },
      "description": "Get hierarchical tree structure for nodes of a specific subkind"
    },
    "hierarchyItem": {
      "type": "object",
      "required": [
        "node",
        "children",
        "depth"
      ],
      "properties": {
        "node": {
          "ref": "pub.chive.graph.listNodes#graphNode",
          "type": "ref",
          "description": "Node data"
        },
        "depth": {
          "type": "integer",
          "description": "Depth in hierarchy (0 = root)"
        },
        "children": {
          "type": "array",
          "items": {
            "ref": "#hierarchyItem",
            "type": "ref"
          },
          "description": "Child hierarchy items"
        }
      },
      "description": "Hierarchy node with recursive children"
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1,
  "revision": 1
}
```
