-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite documentation for empty filters/predicates #40
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few suggestions--and I've got one "meta" suggestion: I found it confusing that your branch name and PR title say that this PR updates the readme when it does not in fact make changes to README.md
. It would help avoid confusion if "README" is used only to refer to a README.md
file.
In this case I'd say that his updates the documentation for anyOf
and not
.
Although that makes me realize something: instead of narrowly focusing on the documentation of anyOf
and not
, I think we need to rewrite the documentation of empty filters/predicates entirely. That rewrite will likely say more about anyOf
and not
since the behavior there is noteworthy but I don't see this task as limited to anyOf
and not
.
config/site/src/_includes/filtering_predicate_definitions/conjunctions.md
Outdated
Show resolved
Hide resolved
|
||
> [!WARNING] | ||
> When a object is passed, it will be treated as a single object within a list. | ||
> For example, `anyOf: {...}` is the same as `anyOf: [{...}]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue is already explained in depth here:
https://block.github.io/elasticgraph/query-api/filtering/conjunctions/#warning-always-pass-a-list
I don't think we need to repeat it here. If you see anything in that section that can be improved, feel free to do so in a follow up PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I'll remove the warning from here.
config/site/src/_includes/filtering_predicate_definitions/not.md
Outdated
Show resolved
Hide resolved
anyOf
and not
87e0570
to
9a0f067
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, if we want to stick with the true/false phrasing, but as per my inline comment I wonder if it's clearer to use "matches all documents"/"matches no documents" instead?
Also, I'd like to see this updated as part of this PR:
Will be ignored when `null` is passed. When an empty list is passed, will | ||
cause this part of the filter to match no documents. | ||
Will be treated as `true` when `null` or an empty object is passed. | ||
When an empty list is passed, will cause this part of the filter to match no documents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Will be treated as true
" and "cause this part of the filter to match no documents" are opposites but aren't phrased as such, so it's an odd pairing. Maybe we should standardize on one of these pairs:
- "Will be treated as
true
"/"Will be treated asfalse
" - "cause this part of the filter to match all documents"/"cause this part of the filter to match no documents"
Overall, I'm thinking that "matches all documents"/"matches no documents" is clearer than "treated as true
"/"treated as false
". In the context of a SQL WHERE clause, where you can use a literal true
or false
, "treated as (true|false)" makes a lot of sense, but we don't let users provide a literal true or false in our GraphQL filter syntax. So maybe it's worth rewording all the docs to speak in terms of "matching all documents" and "matching no documents" rather than true/false.
That's a loosely held opinion, though, and I realize it essentially involves redoing this PR. But if there's consensus that it's clearer, probably worth it.
@BrianSigafoos-SQ I'm curious what you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep it "Will be treated as true
"/"Will be treated as false
", since we end up using that phrase in other parts of the project (e.g. tests). Though I can be swayed either ways depending on the consensus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That SGTM. I'd also consider making it more consistent and slightly less wordy.
From this:
Will be treated as `true` when `null` is passed.
When an empty list is passed, will cause this part of the filter to match no documents.
To this:
When `null` is passed, matches all documents.
When an empty list is passed, this part of the filter matches no documents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since, you both like "matches" phrase more, I'll update the PR to use that wording instead. I also like the less wordy approach.
@@ -6,11 +6,11 @@ | |||
filters that can't be provided on a single filter input because of collisions between key names. | |||
For example, if you want to provide multiple `anySatisfy: ...` filters, you could do `allOf: [{anySatisfy: ...}, {anySatisfy: ...}]`. | |||
|
|||
Will be ignored when `null` or an empty list is passed. | |||
Will be treated as `true` when `null`, an empty object or list is passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to mention the empty object case here? The schema type system doesn't allow empty object here, but it gets coerced from {}
into [{}]
. I don't really want to encourage users to not pass an object here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I have removed the mention of empty object.
|
||
[`anyOf`]({% link query-api/filtering/conjunctions.md %}) | ||
: Matches records where any of the provided sub-filters evaluate to true. | ||
This works just like an `OR` operator in SQL. | ||
|
||
Will be ignored when `null` is passed. When an empty list is passed, will | ||
cause this part of the filter to match no documents. | ||
Will be treated as `true` when `null` or an empty object is passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment here about empty object: there's a gotcha related to that and we don't want to encourage empty objects to be passed so maybe not worth mentioning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I have removed the mention of empty object.
2b23c8c
to
210ff2f
Compare
|
||
Filters with a value of `null` or empty object (`{}`) are ignored. The filters in this query are all ignored: | ||
Filters with a value of `null` or empty object (`{}`) match all documents. Expect for `not` in which case no documents are matched. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filters with a value of `null` or empty object (`{}`) match all documents. Expect for `not` in which case no documents are matched. | |
Filters with a value of `null` or empty object (`{}`) match all documents. When negated with `not`, no documents are matched. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
@@ -17,12 +17,13 @@ As shown here, filters have two basic parts: | |||
you'll need to provide a nested object matching the field structure. | |||
* A _filtering predicate_: this specifies a filtering operator to apply at the field path. | |||
|
|||
### Ignored Filters | |||
### Null Or Empty Filters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just call this "Empty Filters". To me a filter with a value of null
is still an empty filter.
And if you change that, maybe rename NullOrEmptyFilters
to EmptFilters
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, changed to EmptFilters
.
part of the filter to match no documents. When `null` is passed in the list, will | ||
match records where the field value is `null`. | ||
When `null` is passed, matches all documents. When an empty list is passed, will | ||
cause this part of the filter to match no documents. When `null` is passed in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/nit Elsewhere you did away with the "will cause" language--can you do that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the "will cause" language everywhere.
part of the filter to match no documents. When `null` is passed in the list, will | ||
match records where the field value is `null`. | ||
When `null` is passed, matches all documents. When an empty list is passed, will | ||
cause this part of the filter to match no documents. When `null` is passed in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "will cause" language could be remove here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the "will cause" language everywhere.
part of the filter to match no documents. When `null` is passed in the list, will | ||
match records where the field value is `null`. | ||
When `null` is passed, matches all documents. When an empty list is passed, will | ||
cause this part of the filter to match no documents. When `null` is passed in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "will cause" language could be removed here too.
(And with that I'll stop commenting on the other spots with it--please clean those up as well!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the "will cause" language everywhere.
210ff2f
to
5ab6a57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Great work here @acerbusace!
@@ -1,4 +1,4 @@ | |||
query IgnoredFilters { | |||
query NullOrEmptyFilters { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query NullOrEmptyFilters { | |
query EmptyFilters { |
...to match the filename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't realize you had auto-merge on (which is fine), so this was merged when I approved. I've got a followup PR to fix this here: #41 if you want to review it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, thanks!
Rewrite documentation for empty filters/predicates, based on the changes of #6 PR.