Filtering

You can narrow down the contents of a collection field using one or more filter arguments. a community that has name Business Analysts Community:

query {
    communities (where: {name: {eq: "Business Analysts Community"}}) {
        id
        name
    }
}

The available operators depend on the field type. You can find the complete list of filter operators in the Filter operators section.

To combine multiple filters, put them next to one another. All such filters are related to one another using the implicit boolean AND operator. The following example is a query for communities that have been created by a user with the first name Admin and the last name Istrator:

query {
    communities(
        where: {
            createdBy: { firstName: { eq: "Admin" }, lastName: { eq: "Istrator" } }
        }
    ) {
        id
        name
    }
}

You can also combine multiple filters or alter the filtering logic by explicitly using one of the boolean operators: AND or OR. This example is the equivalent the query above:

query {
    communities(
        where: {
            createdBy: {
                _and: [{ firstName: { eq: "Admin" } }, { lastName: { eq: "Istrator" } }]
            }
        }
    ) {
        id
        name
    }
}

The same rules apply to the usage of the OR filter. The following example is a query for communities that have been created by a user whose first name is either Admin or contains the letter S:

query {
    communities(
        where: {
            createdBy: {
                _or: [{ firstName: { eq: "Admin" } }, { firstName: { contains: "S" } }]
            }
        }
    ) {
        id
        name
        createdBy {
            fullName
        }
    }
}

To combine operators or to use filtering on the same field more then once, you must explicitly provide the boolean operators:

query {
    communities(
        where: {
            _and: [
                {_or: [{name: {contains: "Data"}}, {description: {contains: "Data"}}]}
                {system: false}
            ]
        }
    ) {
        id
        name
        description
        system
    }
}
query {
    communities(
        where: {
            _and: [
                {name: {endsWith: "Blocks"}}
                {name: {contains: "building"}}
            ]
        }
    ) {
        id
        name
    }
}

Filtering is not limited to the queried entity but you can also filter on the fields of related entities. The following query retrieves assets from domains that belong to the Finance:

query {
    assets(where: {
        domain: {
            parent: {
                name : {eq: "Finance"}
            }
        }
    }) {
        fullName
    }
}

Due to technical limitations not all of those rules apply to stringValues of MultiValueAttributes. When filtering, use either the contains operator to match a single value, or eq separated by semicolon to match all of them:

query {
    assets(where: {multiValueAttributes: {any: {stringValues: {contains: "Success"}}}}) {
        id
        fullName
        multiValueAttributes {
            stringValues
        }
    }
}
query {
    assets(where: {multiValueAttributes: {any: {stringValues: {eq: "Failed;Success"}}}}) {
        id
        fullName
        multiValueAttributes {
            stringValues
        }
    }
}