Skip to content

graphql: Build and and or filters from their own list - #6826

Open
yash251 wants to merge 1 commit into
graphprotocol:masterfrom
yash251:yash/6809-and-or-filter
Open

yash251 wants to merge 1 commit into
graphprotocol:masterfrom
yash251:yash/6809-and-or-filter

Conversation

@yash251

@yash251 yash251 commented Nov 28, 2026

Copy link
Copy Markdown

In build_filter_from_object, the And and Or arms passed the whole parent object to build_list_filter_from_object, and that function flattened the lists of every key into one. So where: { and: [A1, A2], or: [B1, B2] } built And([And([A1, A2, B1, B2]), Or([A1, A2, B1, B2])]), and rows that match only one or branch were dropped. { _change_block: { number_gte: 10 }, or: [...] } passes the structure check, but then failed with InvalidFilterError because the value of _change_block is not a list.

Changes:

  • Build the And and Or lists from the key's own value with build_list_filter_from_value.
  • Remove build_list_filter_from_object, which has no other callers.
  • Add two build_query unit tests: build_query_builds_and_and_or_from_their_own_lists and build_query_allows_change_block_next_to_or.

Testing:

  • cargo test -p graph-graphql --lib -- store::query::tests: both new tests fail on master (wrong filter, and a panic on the InvalidFilterError) and pass with the fix. 26 passed.
  • cargo test -p test-store --test graphql against Postgres 17: 80 passed.
  • just format, just lint (no warnings) and cargo check --release -p graph-graphql are clean.

Fixes #6809

The `And` and `Or` arms of `build_filter_from_object` built their filter
list from the whole parent object, which flattened the lists of every key
into one. A `where` with both `and` and `or` put all branches into both
filters, and `_change_block` next to `or` failed with
`InvalidFilterError`.

Build the list from the key's own value and drop the now unused
`build_list_filter_from_object`.

Fixes graphprotocol#6809

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] where: { and: [...], or: [...] } builds the wrong filter

1 participant