我有以下架构
User {
username: String!
name: String!
posts(page: Int!): [Post]
}
Post {
title: String!
description: String
}
并在查询
type Query {
user(username: String!): User
}
在我定义的解析器中Query -> user
,user -> posts
当我提取我使用的数据时:
{
user(username: 'pewpewlasers'){
username
name
posts(page: 1){
title
description
}
}
}
它工作得很好。现在我的问题是如何在无限滚动的情况下有效地拉第二页(最后加载更多按钮)。我可以使用:
{
user(username: 'pewpewlasers'){
username
name
posts(page: 2){
title
description
}
}
}
但是再次吸引用户似乎没有必要,我只需要发布更多内容。是否有内置方式 graphql 处理这个?还是我必须定义一个单独的posts(page: Int!, username: String!)
查询