Open JerryNixon opened 5 months ago
Great to see you logging this @JerryNixon. Let me expand my initial request and add some more detail in relation to what you wrote here.
In your table there is a semantic mismatch between $skip
in oData and offset
in GraphQL as for the official standards. Let me clarify with the following table whose columns specify:
oData | GraphQL | DAB/REST | DAB/GraphQL | |
---|---|---|---|---|
Page size | $top=number | first:number | $first=number | first:number |
Offset to skip | $skip=number | offset:number | N/A | N/A |
Identifier to skip | $skiptoken=string | after:string | N/A | after:string |
The perfect solution is to fully adhere to both standards by:
N/A
holes
offset
keyword in GraphQL is also important$first
to $top
$skip
and $top
standard operators which should be therefore understood from the backend to correctly adhere to the client request.(A) ASP.NET Core oData automatically exposes the CRUD for the tables but all the navigations must be manually coded. This is a major disadvantage compare to the old WCF Data Services and DAB.
HTH
Remember @raffaeler, we need a solution that is backwards compatible with existing users of DAB. I have revised the plan but still need to talk to the engineering team about this, too. Would appreciate any feedback.
I understand the backward compatibility issues Jerry, but the compliance with standards should always come first. Even more when the original draft came from MS, even if oData was then given to oasis.
I am open to discuss but I don't really see great options to avoid the breaking change out of versioning the api with some headers.
This introduces
$take
/$skip
in DAB REST and GraphQL endpoints.$first
$after
$take
$first
)$skip
Syntax
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 theTake()
andSkip()
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.
$top
$first
$skiptoken
$after
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.