Improve error message for OR operator with column filters #6078
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the error message when users attempt to mix column filters with the 'or' operator at the same level in GraphQL queries. Instead of the generic "Filter must by an object" error, users now receive a specific, actionable error message with examples.
Problem
Previously, when users wrote queries like:
They would receive the unhelpful error:
"Filter must by an object"
which provided no guidance on what was wrong or how to fix it.Solution
The new error message provides:
Example New Error Message
Changes Made
1. New Error Type (
graph/src/data/query/error.rs
)InvalidOrFilterStructure(Vec<String>, String)
variant toQueryExecutionError
2. Enhanced Filter Validation (
graphql/src/store/query.rs
)build_filter_from_object
to detect mixed filters early_gt
,_lt
, etc.)3. Comprehensive Test Coverage
Added 5 new test cases covering:
name_gt
) with OR operatorTest Results
All existing tests continue to pass, ensuring no regressions:
Benefits
Addresses
For Ford 🚗
A humble plea in verse, for any bugs that might be terse:
Testing
To test the new error message:
The error now provides everything developers need to fix their queries without additional research or support requests.