我想創建通過我的數據分頁的能力,但我不知道我需要放置分頁變量的位置。如何在我的模式中定義分頁參數?
以下是我在我的架構:
const Query = new GraphQLObjectType({
name: 'Query',
description: 'This is a root Query',
fields:() => {
return {
allPosts: {
type: new GraphQLList(Post),
args: {
offset: {
type: GraphQLInt
},
first: {
type: GraphQLInt
}
},
resolve(root, args) {
return Db.models.post.findAll({where: args});
}
}
};
}
});
在我指定參數時,我已經創建的變量偏移和第一才能夠使用它們。在裏面我graphiQL界面我可以這樣做:
{
allPosts() {
id
}
}
並正確檢索我的所有文章。但是,如果我嘗試這樣做:
{
allPosts(offset:10, first: 10) {
id
}
}
「消息」: 「在 'where子句' 未知列 'post.offset'」,
啊,就是這樣!我在錯看地方!我應該一直在看Sequelize文檔!非常感謝! – Amir