我有如下所示的模式。
type Board {
id: ID,
title: String,
content: String,
replies: [Replies]
}
type Replies {
id: ID,
content: String
}然后,在搜索董事会时,有与董事会相关的答复。
在这里,您可以通过这样的查询获得董事会和回复:
query{
getBoard(id: "xxx") {
id,
title,
content: String,
replies {
id,
content
}
}
}但是,我想要的是如何在后端java中实现,而无需使用指令来获取在检索选定的板和内部回复时的最后5个答复?
我正在通过https://github.com/graphql-java-kickstart进行开发。
query{
getBoard(id: " xxx") {
id,
title,
content: String,
replies(limit: 5) {
id,
content
}
}
}发布于 2022-04-09 09:55:39
在创建.type函数时,可以尝试添加一个新的数据获取器( graphql.schema.idl.RuntimeWiring ())。因此,您可以添加新的graphql.schema.DataFetcher函数来恢复所需的内容。
https://stackoverflow.com/questions/71806718
复制相似问题