Cross-relation Field Queries
Introduction
The previous section has already demonstrated that queries can return not just scalars such as a String, but also fields that refer to object or entity types. What’s even more interesting is that queries can leverage fields of related objects to filter results. Let’s take this sample schema with two entity types and a one-to-many relationship between them:schema.graphql
Accounts that have at least some historicalBalances with a balance smaller than a certain threshold:
*_some is not the only operator available for making cross-relation field queries. A short description of each such operator is provided in the sections below.
The *_every filter
Returns entities for which all of the nested entities linked via the related field satisfy the condition. Example:
schema.graphql
Accounts where each and every one of the HistoricalBalance entities related to them have a balance smaller than the threshold. It is sufficient for a single HistoricalBalance to have a balance larger than the set value to make sure that the related Account is not returned in the query.
The *_none filter
Returns entities for which none of the nested entities linked via the related field satisfy the condition. Example:
Accounts in which not a single related HistoricalBalance has a balance smaller than the set threshold.
The *_some filter
Returns entities for which at least one of the nested entities linked via the related field satisfies the condition. Example:
Accounts that have at least some historicalBalances with a balance smaller than 10000000000 will be returned. This means that a single HistoricalBalance satisfying the condition is sufficient for the related Account to become a part of the results.
{entityName}sConnection queries
Same as always, the where argument works for these queries in exactly the same way as it does for {entityName}s queries used in examples above. For example this query
Accounts that have at least some historicalBalances with a balance smaller than 10000000000.
