# getStockTree

Audience: Developer

**Served by:** [inventory](https://docs.pyck.cloud/api/services/inventory.md)

## Arguments

| Name | Type |
| --- | --- |
| `after` | [Cursor](https://docs.pyck.cloud/api/scalars/cursor.md) |
| `first` | Int |
| `before` | [Cursor](https://docs.pyck.cloud/api/scalars/cursor.md) |
| `last` | Int |
| `where` | [StockWhereInput](https://docs.pyck.cloud/api/inputs/stockwhereinput.md) |

## Returns

[RepositoryTreeConnection](https://docs.pyck.cloud/api/types/repositorytreeconnection.md)!

## Example

Returns the first 3 stock entries as a hierarchical tree, showing stock levels per repository including child repositories.

```graphql
query GetStockTree($after: Cursor, $first: Int, $before: Cursor, $last: Int, $where: StockWhereInput) {
  getStockTree(after: $after, first: $first, before: $before, last: $last, where: $where) {
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    edges {
      cursor
      node {
        children {
          cursor
          node {
            children {
              cursor
            }
            createdAt
            parentID
            repositoryID
            stocks {
              createdAt
              createdBy
              deletedAt
              deletedBy
              id
              incomingStock
              itemID
              movementID
              outgoingStock
              ownIncomingStock
              ownOutgoingStock
              ownQuantity
              quantity
              repositoryID
              tenantID
              updatedAt
              updatedBy
              version
            }
          }
        }
        createdAt
        parentID
        repositoryID
        stocks {
          createdAt
          createdBy
          deletedAt
          deletedBy
          id
          incomingStock
          itemID
          movementID
          outgoingStock
          ownIncomingStock
          ownOutgoingStock
          ownQuantity
          quantity
          repositoryID
          tenantID
          updatedAt
          updatedBy
          version
        }
      }
    }
  }
}
```

**Variables**

```json
{
  "first": 3,
  "where": {
    "createdAtGTE": "2023-10-17T00:00:00Z"
  }
}
```
