-
Notifications
You must be signed in to change notification settings - Fork 285
Description
This introduces $take/$skip in DAB REST and GraphQL endpoints.
Previous discussions had this feature as a synonym of $first/$after, but that is no longer the plan. The current plan is, instead, to introduce these as new keywords with similar, but not identical, functionality.
| Data type | Behavior | REST | GraphQL | Current Status | |
|---|---|---|---|---|---|
$first |
integer | TOP in T-SQL | ✅ | ✅ | Yes, DAB supports this today |
$after |
string | Entity key(s) | ✅ | ✅ | Yes, DAB supports this today |
$take |
integer | TOP in T-SQL (same as $first) |
✅ | ✅ | No (this article) |
$skip |
integer | OFFSET in T-SQL | ✅ | ✅ | No (this article) |
Syntax
query {
books(first: 5, after: "W3siVm1lIjoiaWQifV0=")
{
items {
id
title
}
hasNextPage
endCursor
}
}
query {
books(take: 5, skip: 50)
{
items {
id
title
}
hasNextPage
}
}Note that $first, $take, and (later) $top are all synonyms of the same operations.
Benefits
The value of the $first/$after approach is that it allows developers to paginate in a reliable way. When the underlying collection changes, the next page is always the next page and does not reset because of ordinal position. In a busy table, this provides a consistent and non-jarring user experience.
The value of the $take/$skip approach is that it allows developers to paginate in a simple way, often in order to virtualize large datasets in visualization objects. It does not account for underlying collection changes but does return a programmatic page. It operates identically to the Take() and Skip() LINQ methods in .NET languages.
Bonus: $take/$skip are both keywords in OData and represent common expressions.
Proposed synonyms
The reason for synonyms would be to accommodate the OData specification.
| Synonym | Keyword | REST | GraphQL | Current Status |
|---|---|---|---|---|
$top |
$first |
✅ | ✅ | No (this article) |
$skiptoken |
$after |
✅ | ✅ | No (this article) |
Feedback
Customers have reported that using GraphQL keywords in REST endpoints instead of OData standard keywords causes some code to struggle when interacting with our endpoints. Other customers have reported that not supporting integer-based $take/$skip disqualifies some UI components looking for the standard.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status