![](/img/trans.png)
[英]With TypeORM getManyWithCount how to generate a PageInfo for pagination
[英]Correct value for `startCursor` and `endCursor` in `PageInfo` when there are 0 items/edges? Is the Relay pagination spec incorrect?
中繼分頁規范對PageInfo
進行了以下說明:
它還必須包含字段
startCursor
和endCursor
,這兩個字段都返回非空的不透明字符串。[...]
startCursor
和endCursor
必須分別是邊中第一個和最后一個節點對應的游標。
但是如果我想返回零個項目怎么辦? 對特定端點的請求會返回空連接的原因有很多。
在這種情況下,我看不出startCursor
和endCursor
應該有什么值。 顯而易見的答案是null
,但規范明確表示“非空”。 那是怎么回事?
對於它的價值,我查看了大約 15 篇關於“graphql 分頁”主題的文章,所有這些文章要么忽略這個問題,要么在空列表的情況下分配null
。 所以在這一點上,規范似乎是錯誤的或與現實世界不兼容?
我在繼電器 Github 上提交了一個錯誤: https://github.com/facebook/relay/issues/3708
似乎規范的解決方案是忽略規范並使它們非空,因為 JavaScript 和 java 實現都這樣做。
Graphql-Relay-JS: https://github.com/graphql/graphql-relay-js/blob/3796e0904fbfe0dd86e540d5b4df236330c8a5e7/src/connection/arrayConnection.ts
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.