I have created a GraphQL Query that gets complex where conditions but in Apollo GraphQL iOS client there is no way of changing query after compiling the project. Apollo GraphQL iOS client gives chance to change defined variables in the query but not the query itself.
My original Lighthouse GraphQL query is like following;
query ($first:Int, $page:Int) {
my_listings(
where: {
AND: [
{ column: NET_AREA, operator: GTE, value: 200 }
]
}
orderBy: [
{ column: ID, order: ASC }
]
first: $first
page: $page
) {
data {
...listingFields
}
paginatorInfo {
currentPage
lastPage
}
}
}
Altered Lighthouse GraphQL query is like this, only added $conditions variable which is MyListingsWhereWhereConditions
type.
query($first: Int, $page: Int, $conditions:MyListingsWhereWhereConditions) {
my_listings(
where: $conditions
orderBy: [{ column: ID, order: ASC }]
first: $first
page: $page
) {
data {
...listingFields
}
paginatorInfo {
currentPage
lastPage
}
}
}
When I give the following variables into the second query Lighthouse server returns me the following message
{
"first": 1,
"page": 1,
"conditions": {"AND": {"column": "PRICE", "operator": "LTE","value": "190"}}
}
error message
Variable \"$conditions\" got invalid value {\"AND\":{\"column\":\"PRICE\",\"operator\":\"LTE\",\"value\":\"190\"}}; Expected type MyListingsWhereWhereConditions to be an object at value.AND.column.
Is there a way of giving these conditions in a variable ? Without it I couldn't find a way of changing where condition on iOS client.