【发布时间】:2016-05-08 10:43:32
【问题描述】:
假设我有一个博客:
- 1 个博客有很多帖子
- 1 个帖子有很多赞
- 1 个帖子有很多 cmets
- 1 条评论有很多赞
在我博客的首页,我想展示前 10 篇文章。对于每个帖子,我想显示最近的 10 个喜欢的人、最近的 5 个 cmet 和最近喜欢每条评论的 10 个人。 (数字不重要,我只是在设置类似于 facebook 的东西)。
所以我的查询可能看起来像这样:
query getPosts(
$postCount: Int,
$likersCount: Int,
$commentCount: Int,
$commentCursor: ID,
$commentLikersCount: Int) {
recentPosts(first: $postCount) {
id,
title,
body,
likers(first: $likersCount) {
id,
name
},
comments(first: $commentCount, after: $commentCursor) {
id,
title,
body,
likers(first: $commentLikersCount) {
id,
name
},
}
}
}
如果我使用新的$commentCursor 重新提交此查询以加载更多 cmets,中继如何缓存数据以便知道在本地获取其他所有内容?我得到了商店的基本图形架构,但是对于像这样的嵌套事物,我在调试器中感到困惑。
【问题讨论】:
标签: relayjs