33.5 Views
A view is a root field defined by a query. It returns the same result type as the type's list field and takes the same arguments, so clients can still filter, search, order and page within it. The view's own query is applied first:
"views": [
{ "name": "upcoming", "query": "IEvent.Where(e => e.Status == 1)", "description": "Published events." },
{ "name": "jazz", "query": "IEvent.WhereSearch(\"jazz\").OrderBy(e => e.StartsUtc)" }
]{ upcoming(orderBy: starts, pageSize: 10) { totalCount items { title starts } } }The query is written in the text form of the query language (§20). It starts with a type's code name, without its namespace, and uses the datamodel's property names, not the endpoint's. Enum values are written as numbers. A view can use only methods that keep the result a set of nodes the endpoint can page:
Where, WhereSearch, WhereInIds, WhereIn, WhereTypes, Relates, RelatesNot,
RelatesAny, OrderBy, WhereCulture, WhereCultureFallback, WhereHidden and Traverse.
Page, Include, Select and Count are not allowed, because the endpoint adds paging and
includes itself. A view whose type the endpoint does not expose is left out, with a warning.
Use a view to give clients a selection they cannot build with filter: an or across relations, a
traversal, or a culture.