如何為 graphQL Query 實作分頁?我不斷收到:“訊息”:“Core_EventPeopleConnection”型別的欄位“pageInfo”上的未知引數“hasNextPage”。
query myquery($viewId: ID!,$hasNextPage: Boolean!, $endCursor: String!){
Core_eventPeopleListView(viewId: $viewId){
id
people{
pageInfo(hasNextPage: true,endCursor: $endCursor){
hasNextPage
endCursor
}
nodes{
firstName
lastName
jobTitle
organization
websiteUrl
}
}
}
}
Variables:
{
"viewId":"RXZlbnRWaWV3XzMyMTY1Mw==",
"endCursor": "WyJhZ2Fyd2FsIiwic2hydXRpIiwiUlhabGJuUlFaVzl3YkdWZk1UVXhPREkzTlRVPSJd",
"hasNextPage": true
}
uj5u.com熱心網友回復:
在 Relay 規范中,hasNextPage不是引數,而是從 API 回傳的欄位,告訴您是否可以進一步分頁。只需洗掉引數:
query myquery($viewId: ID!,$hasNextPage: Boolean!, $endCursor: String!){
Core_eventPeopleListView(viewId: $viewId){
id
people{
pageInfo(endCursor: $endCursor){
hasNextPage
endCursor
}
nodes{
firstName
lastName
jobTitle
organization
websiteUrl
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/494955.html
