I have a query
{
"query": "query($withComments: Boolean!) {feed(id: 2) {name comments @include(if: $withComments) {title text}}}",
"vars": {"withComments": true}
}
Based on the withComments
variable I can grab the feed with or without comments. It works. But it seems that Sangria has to get the feed with the comments in any case (what is the performance issue for me) even if I do not need them and passed withComments
with the false
value:
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")))))
What is the proper way to include/exclude inherit lists (say relations) in an Object and do not select all the data from the repository if I do not @include
, make an repository aware of it?
If solution is to make two queries feed
and feedWithComments
I can not see any flexibility with the @include
.