graph-node
graph-node copied to clipboard
feat: AND/OR query filters
Enables users to execute queries with logical operators.
Query Example:
{
musicians(where: {OR: {name: "John", id: "m2"}}) {
name
id
}
}
Question: should we limit this to only one level deep?
Closes #579
Seeing
ANDwhen everything else is lower case feels a little strange.
In the ticket and to make it more differentiable made these logical filters uppercase. Don’t have a preference so happy to do whatever you think is the best.
Agree with David, I think lowercase would be more in keeping. And nice work!
Can you clarify what you mean by The current implementation would resolve OR only one level deep but AND is recursively constructed. - so you could have X OR (Y AND Z), and you could have X AND (Y OR Z) but not X OR (Y OR Z)?
actually need to make it recursive for picking up OR cause if we want to even mix and match AND/OR like wouldn't work. Unless we think cause of performance reasons we don't want to allow this
{
proposals(
where: {OR: {name_contains_nocase: "Creating", AND: {status: WITHDRAWN}}}
) {
id
name
contributor
contentCID
}
}
above query for sure can be simplified since it should really just be a simple AND which is what we implicitly do. But someone can send that and would expect results back
similarly this query would fail in current implementation but in theory user should just so all in one line
{
proposals(
where: {OR: {name_contains_nocase: "Creating", OR: {contentCID_in: ["0x29eeb7b4ac75dbcdcbe098e18fe6707dcc5281af"]}}}
) {
id
name
contributor
contentCID
}
}
so you could have X OR (Y AND Z), and you could have X AND (Y OR Z) but not X OR (Y OR Z)?
@azf20 updated it so it no longer is limiting. User can make as much recursively deep AND/OR filter they if they chose to do so.
there's some test failures.
@lutter fixed the schema tests
@saihaj i think we need a rebase here, and then we are good to go in terms of code review?
Quick note on rebasing: please always rebase with git rebase master <mybranch> not by merging master into the branch since that leads to funky looking merge commits.
If we proceed with https://github.com/graphprotocol/graph-node/pull/4080 should we close this @saihaj ?