I have a Query to filter my Premises
by a query called premiseBySelectedFlag
Like this.
premiseBySelectedFlag(selected: Boolean!): [Premise!]!
@resolver(name: "listAllSelectedPremises", paginated: true)
How do I create a function for this? I want to show Premises
that have the selected value of true
only.
Currently, I have a basic function like this:
Query(
Lambda(
["size", "after", "before"],
Let(
{
match: Match(Index("latestSelectedPremises")),
page: If(
Equals(Var("before"), null),
If(
Equals(Var("after"), null),
Paginate(Var("match"), { size: Var("size") }),
Paginate(Var("match"), { after: Var("after"), size: Var("size") })
),
Paginate(Var("match"), { before: Var("before"), size: Var("size") })
)
},
Map(Var("page"), Lambda(["_", "ref"], Get(Var("ref"))))
)
)
)
But When I do this in my GraphQL playground
query{
premiseBySelectedFlag(selected: true){
data{
_id
content
}
}
}
I get this error in my GraphQL
{
"errors": [
{
"message": "Lambda expects an array with 3 elements. Array contains 4.\n",
"extensions": {
"code": "invalid argument"
}
}
]
}
I then changed it to this:
Query(
Lambda(
["selected","size", "after", "before"],
Let(
{
match: Match(Index("latestSelectedPremises")),
page: If(
Equals(Var("before"), null),
If(
Equals(Var("after"), null),
Paginate(Var("match"), { size: Var("size") }),
Paginate(Var("match"), { after: Var("after"), size: Var("size") })
),
Paginate(Var("match"), { before: Var("before"), size: Var("size") })
)
},
Map(Var("page"), Lambda(["_", "ref"], Get(Var("ref"))))
)
)
)
When I do this in my GraphQL playground, It shows all Premises for both selected: true
and selected:false
What is the correct way to create this function? To be honest, I don’t even know where to start. I just want to filter my Premise object by Selected: True.
PS. I created the index latestSelectedPremises
Is this correct?
Thank you