Graphql conditional where Query

I am Using Graphql to fetch data from api with some Where condition. In that, i need to check whether a field is not null and if so then i need to check for some key is present in that object and write the where query.

My Graphql query is as follows:
query Orders{
orders(limit:500 where:”(store(key in (“store1″,”store2”))) and (state(key in (“state1″,”state2″)))”){
total
count
results {
id
origin
store{
key
}
state{
key
id
}
}
}
}

if i run the above query i am getting error as below
“message”: “Malformed parameter: where: The field ‘key’ does not exist.”,
“path”: [
“orders”
],
This is because the object state is null in some of the results and so , i need to check for the key if the state object is not null.

I tried state!=null but this doesn’t work.
Any ideas or suggestions?