I tried to query track records which either title or lyric contain "cat". But only record return if both title and lyric have cat. May I know how to query by OR operator.
Query
query Tracks($where: TrackWhereInput) {
tracks(where: $where) {
id
title
lyric
youtube_url
mp3_url
}
}
Variables
{
"where": {
"OR": [
{
"title": {
"contains": "cat"
},
"lyric": {
"contains": "cat"
}
}
]
}
}
You must pass conditions to OR
operator in different objects. You've passed an object array but both conditions are in same object. Conditions in same object use AND
operator.
Your fixed code would be:
{
"where": {
"OR": [
{
"title": {
"contains": "cat"
},
},
{
"lyric": {
"contains": "cat"
}
}
]
}
}