> For the complete documentation index, see [llms.txt](https://developer.collibra.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.collibra.com/api/guides/knowledge-graph/examples.md).

# Examples

## Communities and domains

A community or domain tree, starting from top-level communities:

```graphql
query {
  communities(where: {parent: {_null: true}}) {
    name
    subCommunities {
      name
      subDomains {
        name
      }
    }
    subDomains {
      name
    }
  }
}
```

Domains filtered by the parent community name, including the parent community and responsibilities:

```graphql
query {
  domains(where: {parent: {name: {contains: "Data"}}}) {
    name
    parent {
      name
    }
    responsibilities {
      userGroup {
        name
      }
      user {
        fullName
      }
    }
  }
}
```

Domains that have at least one asset, including the first five assets:

```graphql
query {
  domains(
    where: { assets: {any: {id: {null: false} } } }
  ) {
    name
    assets(limit: 5) {
      fullName
    }
  }
}
```

## Assets

Assets from a particular domain identified by ID, sorted by creation date, including asset tags:

```graphql
query {
  assets(
    where: {domain: {id: {eq: "00000000-0000-0000-0001-000200000001"}}}
    order: {createdOn: desc}
  ) {
    id
    type {
      publicId
    }
    displayName
    fullName
    createdOn
    createdBy {
      fullName
    }
    tags {
      name
    }
  }
}
```

Assets from a particular domain identified by name, having at least one attribute, including all attributes:

```graphql
query {
  assets(where: {
    domain: {name: {eq: "New Data Sets"}}
    attributes: {any: {id: {null: false}}}
  }) {
    fullName
    stringAttributes {
      type {
        publicId
      }
      stringValue
    }
    numericAttributes {
      type {
        publicId
      }
      numericValue
    }
    dateAttributes {
      type {
        publicId
      }
      dateValue
    }
    booleanAttributes {
      type {
        publicId
      }
      booleanValue
    }
  }
}
```

Assets filtered by attribute value, including the parent domain and two specific attributes:

```graphql
query {
  assets( where: { stringAttributes: { typePublicId: "DataType", any: { stringValue: { eq: "Whole Number" } } } } ) {
    fullName
    domain {
      name
    }
    dataType: stringAttributes(where: { type: { publicId: { eq: "DataType" } } } ) {
      stringValue
    }
    description: stringAttributes(where: { type: { publicId: { eq: "Description" } } } ) {
      stringValue
    }
  }
}
```

An asset identified by ID, including all incoming and outgoing relations:

```graphql
query {
  assets (
    where: {id: {eq: "ddd9f9c5-87cf-421f-a406-a52144c693d0"}}
  ) {
    fullName
    outgoingRelations {
      type {
        publicId
      }
      target {
        id
        fullName
      }
    }
    incomingRelations {
      type {
        publicId
      }
      source {
        id
        fullName
      }
    }
  }
}
```

An asset with two different relation types:

```graphql
query {
  assets (
    where: {id: {eq: "ddd9f9c5-87cf-421f-a406-a52144c693d0"}}
  ) {
    fullName
    children: outgoingRelations(
      where: {type: {publicId: {eq: "BusinessAssetGroupsBusinessAsset"}}}
    ) {
      target {
        id
        fullName
      }
    }
    acronyms: outgoingRelations(
      where: {type: {publicId: {eq: "BusinessAssetHasAcronymAcronym"}}}
    ) {
      target {
        id
        fullName
      }
    }
  }
}
```

Assets identified by the related asset ID and the relation type:

```graphql
query {
  assets (
    where: {
      incomingRelations: { any: {
        source: {id: {eq: "ddd9f9c5-87cf-421f-a406-a52144c693d0"}}
        type: { publicId: {eq: "BusinessAssetGroupsBusinessAsset"}}
      }}
    }) {
    fullName
    incomingRelations {
      type { publicId }
    }
  }
}
```

Assets with description attribute:

```graphql
query {
  assets(where: {
    attributes: {
      typePublicId: "Description"
      empty: false
    }
  })
  {
    fullName
    descriptions: stringAttributes(
      where: { type: { publicId: { eq: "Description" } } }
    ) {
      stringValue
    }
  }
}
```

## Schemas, tables, and columns

![schema table column](https://3820928149-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F259XXXQinDEdEgkdyb2W%2Fuploads%2Fgit-blob-464bb9aaf2e7185905376aba5826238fb4641f63%2Fschema-table-column.png?alt=media\&token=843c6235-e6bf-4d0c-b9a8-b94680ae129c)

Top-down query (Schema → Table → Column):

```graphql
query {
  schemas: assets(where: { type: { publicId: {eq: "Schema"}}  }) {
    displayName
    tables: outgoingRelations(where: { type: { publicId: {eq: "SchemaContainsTable"}}  }) {
      target {
        displayName
        columns: incomingRelations(where: { type: { publicId: {eq: "ColumnIsPartOfTable"}}  }) {
          source {
            displayName
          }
        }
      }
    }
  }
}
```

Bottom-up query (Column → Table → Schema):

```graphql
query {
  columns: assets(where: { type: { publicId: {eq: "Column"}}  }) {
    displayName
    tables: outgoingRelations(where: { type: { publicId: {eq: "ColumnIsPartOfTable"}}  }) {
      target {
        displayName
        schemas: incomingRelations(where: { type: { publicId: {eq: "SchemaContainsTable"}}  }) {
          source {
            displayName
          }
        }
      }
    }
  }
}
```

Mixed query (Table → Schema, Table → Column)

```graphql
query {
  tables: assets(where: { type: { publicId: {eq: "Table"}}  }) {
    displayName
    columns: incomingRelations(where: { type: { publicId: {eq: "ColumnIsPartOfTable"}}  }) {
      source {
        displayName
      }
    }
    schemas: incomingRelations(where: { type: { publicId: {eq: "SchemaContainsTable"}}  }) {
      source {
        displayName
      }
    }
  }
}
```

Please note the following tradeoffs for the above queries:

* For the first query it might be difficult to set the limits in the right way as each schema can have a very different number of tables and the same thing happens for table to column relations.
* The second query duplicates each table and schema multiple times thus making it more difficult to read.
* The last query mixes both problems.

Sometimes you need to verify if the tree structure of the response is what you actually need. Consider using a query similar to the following example to specify the limits between all of the entities and still link them using the parent identifier:

```graphql
query {
  schemas: assets(
    where: {
      _and: [
        { type: { publicId: { eq: "Schema" } } }
        { domain: { parent: { name: { eq: "Schemas" } } } }
      ]
    }
  ) {
    id
    fullName
  }
  tables: assets(
    where: {
      _and: [
        { type: { publicId: { eq: "Table" } } }
        { domain: { parent: { name: { eq: "Schemas" } } } }
      ]
    }
  ) {
    fullName
    incomingRelations(where: {type: {publicId: {eq: "SchemaContainsTable"}}}) {
      source {
        id
      }
    }
  }
  columns: assets(
    where: {
      _and: [
        { type: { publicId: { eq: "Column" } } }
        { domain: { parent: { name: { eq: "Schemas" } } } }
      ]
    }
  ) {
    fullName
    outgoingRelations(where: {type: {publicId: {eq: "ColumnIsPartOfTable"}}}) {
      target {
        id
      }
    }
  }
}
```

## Complex relations

Complex relations including all legs:

```graphql
query {
  complexRelations {
    id
    relations {
      type {
        publicId
      }
      target {
        id
        displayName
      }
    }
  }
}
```

All complex relations related to a given asset:

```graphql
query {
  complexRelations(
    where: {
      outgoingRelations: {
        any: { target: { id: { eq: "51f986dc-e19a-4d39-b762-b941c506fafc" } } }
      }
    }
  ) {
    outgoingRelations {
      target {
        id
        fullName
      }
    }
  }
}
```

{% hint style="info" %}
Complex relations are always on the source side of a relation so there is no need to search for this asset in `incomingRelations`.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.collibra.com/api/guides/knowledge-graph/examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
