I’d like to create a GraphQL query that can return a filtered view of related docs. I’ve implemented the resolver which overwrites the items
with the filtered result set and it seems to work via FQL but always returns all items when called via the graphql interface. Curious if this is possible or I’m breaking a rule.
Here’s part of my schema and the function for reference.
type List @collection(name: "lists") {
owner: User! @relation
title: String
created: Int
updated: Int
favorite: Boolean
archive: Boolean
items: [Item!] @relation
}
type Item @collection(name: "items") {
list: List! @relation
title: String
archive: Boolean
}
type Query {
userLists(args: UserListsInput!): [List!]! @resolver(paginated: true)
}
CreateFunction({
name: "listItems",
body: Query(
Lambda(
["args", "size", "after", "before"],
Map(
Paginate(
Match(Index("items_by_list_archive"), [
Ref(Collection("lists"), Select("list", Var("args"))),
Select("archive", Var("args"), false)
]),
{ size: Var("size") }
),
Lambda("item", Get(Var("item")))
)
)
)
}),
CreateFunction({
name: "userLists",
body: Query(
Lambda(
["args", "size", "after", "before"],
Map(
Paginate(
If(
Select("archive", Var("args"), false),
Match(Index("list_owner_by_user"), [
Ref(Collection("users"), Select("user", Var("args")))
]),
Match(Index("list_by_owner_archive"), [
Ref(Collection("users"), Select("user", Var("args"))),
Select("archive", Var("args"), false)
])
),
{ size: Var("size") }
),
Lambda(
"list",
Call(Function("addToData"), [
Get(Var("list")),
If(
Select("items", Var("args"), false),
{
items: Call(Function("listItems"), [
{ list: Select("id", Var("list")) },
10,
"",
""
])
},
{}
)
])
)
)
)
)
})