subqueries-in-expand
Note that you can create very complex queries within the expand scope:
const { peopleApi } = peopleService();
peopleApi
.requestBuilder()
.getAll()
.expand(
peopleApi.schema.FRIENDS.select(
peopleApi.schema.FIRST_NAME,
peopleApi.schema.ADDRESS_INFO
)
.filter(peopleApi.schema.LAST_NAME.equals('Miller'))
.orderBy(asc(peopleApi.schema.GENDER))
.top(1)
.skip(1)
);
In this example, the filter will reduce the number of friends to be shown.
The effect of a filter depends on whether it is used inside or outside an expand.
The different cases are explained in Filters in Expand.
The URL for the query will be:
/People?$expand=Friends($select=FirstName,AddressInfo;$filter=(LastName eq 'Miller');$skip=1;$top=1;$orderby=Gender asc)