Closed dallen66 closed 7 years ago
or
requires an array instead of an object. Try something like this:
{
allPosts(first: 10, filter: {
or: [
{ headline: { ilike: "%thing%"} },
{ body: { ilike: "%thing%"} }
]
}) {
edges {
node {
id
headline
body
}
}
}
}
If run against kitchen-sink-schema.sql that query should return:
{
"data": {
"allPosts": {
"edges": [
{
"node": {
"id": 1,
"headline": "No… It’s a thing; it’s like a plan, but with more greatness.",
"body": null
}
}
]
}
}
}
Also, if you want to drop the %
wildcards, you can use conti
(containsInsensitive
) to get the same result.
Let me know if you're still having trouble.
Thanks. Never thought of using and array, FACE-PALM. 😔
I am having an hard time getting OR to work. It is applying AND when I check the query executed SQL query.
query { allPosts( first: 10 filter: { or:{headline:{ilike: "%Mayer%"}} body:{ilike: "%Mayer%"}} ) { edges { node { id headline body } } } }
filter: { or:{headline:{ilike: "%Mayer%"}} body:{ilike: "%Mayer%"} }
filter: { headline:{ilike: "%Mayer%"} or:{ body:{ilike: "%Mayer%"}} }
filter: { or:{ headline:{ilike: "%Mayer%"} body:{ilike: "%Mayer%"}} }
This is what I am trying to accomplish.
select post.* from forum_example.post as post where post.headline ilike ('%' || search || '%') or post.body ilike ('%' || search || '%')