【发布时间】:2017-10-28 07:26:36
【问题描述】:
我正在构建一个graphql 应用程序,其中User 可以有一堆Entries。这是一个 n 到 m 的关系,中间表/边保存有关该关系的附加信息。
我的 graphql 架构看起来像这样:
type User {
id: ID!,
entries(…): [UserEntry]
}
type UserEntry {
id: ID!,
user: User,
entry: Entry,
someOtherAttribute: String,
yetAnotherAttribute: String
}
type Entry {...}
type Query {
me: User!
userEntry(userEntryId: ID!): UserEntry!
}
我想在 entries 字段之后添加光标样式分页到 Relay Cursor Connections Specification 之后。
所以我猜UserEntry 会变成这样:
type UserEntryEdge {
node: Entry,
cursor: String,
someOtherAttribute: String,
yetAnotherEdgeAttribute: String
}
但我仍然希望能够直接查询UserEntry/UserEntryEdge,在这种情况下,例如cursor 字段将是无关紧要的。
设计我的 graphql 架构以便能够直接查询边缘数据的最佳方式是什么?
(仅供参考:我在服务器和客户端都使用 nodejs 和 apollo 框架套件)
【问题讨论】:
-
所以要直接查询
Entry?您在直接下的意思是什么?您能否提供您想要使用的示例查询? -
我可以在这里查询
Entry。我希望能够仍然查询 UserEntry !我添加了当前查询的定义。谢谢