【发布时间】:2018-08-18 02:54:57
【问题描述】:
我有一个问题
{
"query": "query($withComments: Boolean!) {feed(id: 2) {name comments @include(if: $withComments) {title text}}}",
"vars": {"withComments": true}
}
基于withComments 变量,我可以抓取带有或不带有cmets 的提要。有用。但似乎 Sangria 在任何情况下都必须使用 cmets 获取提要(对我来说性能问题是什么),即使我不需要它们并通过 withComments 和 false 值:
val QueryType = ObjectType(
"Query",
fields[GraphQLContext, Unit](
Field("feed", OptionType(FeedType),
arguments = Argument("id", IntType) :: Nil,
resolve = c => c.ctx.feedRepository.get(c.arg[Int]("id")))))
如果我没有@include,那么在对象中包含/排除继承列表(比如关系)并且不从存储库中选择所有数据的正确方法是什么,让存储库知道它?
如果解决方案是进行两个查询 feed 和 feedWithComments 我看不到 @include 的任何灵活性。
【问题讨论】: