Examples

Communities and domains

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

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:

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:

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:

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:

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:

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:

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:

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:

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:

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

Schemas, tables, and columns

schema table column

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

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):

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)

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:

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:

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

All complex relations related to a given asset:

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

Complex relations are always on the source side of a relation so there is no need to search for this asset in incomingRelations.