-
Notifications
You must be signed in to change notification settings - Fork 2
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
Update the FullTextSearch docs to provide an example of their optionality #25
Conversation
…lity In order to ignore a `matchesQuery` or `matchesPhrase` filter predicate, you can supply `null` to the `MatchesQueryFilterInput` or `MatchesQueryFilterInput` types, respectively. However, this is not entirely clear from the docs, as they describe supplying `null`, but not to which field/value. This documentation update aims to make that more clear, and provides an example to highlight the ability to use a null-able variable with these predicates. ## Tested Ran the site locally. Here are the screenshots of updates:
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.
Can you use 2 spaces for each indentation level instead of 4? That's what we use for all the other queries and (at least to my eyes) I think it looks a bit cleaner.
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.
Absolutely. Fixed in the latest commit, PTAL
config/site/examples/music/queries/filtering/OptionalMatchingFilter.graphql
Outdated
Show resolved
Hide resolved
@@ -3,11 +3,11 @@ | |||
full text search. This is stricter than `matchesQuery`: all terms must match | |||
and be in the same order as the provided phrase. | |||
|
|||
Will be ignored when `null` is passed. | |||
Will be ignored when `null` is passed as the `MatchesPhraseFilterInput`. |
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'm on the fence about including the changes to this file, for a couple reasons:
- This is copied verbatim from the GraphQL docs for the
TextInputFilter.matchesPhrase
andTextInputFilter.matchesQuery
fields. It'd be nice to not diverge from them. If this is needed, we should probably update the GraphQL docs, too. - The wording
Will be ignored when null is passed
is used consistently throughout our GraphQL docs (as shown below it shows up 148 times in our.graphql
schema file!). If we're going to update this, should we update all of them with a similar clarification? - Does adding this note about the type bring necessary clarity? "Will be ignored when
null
is passed" is intended to apply to the input field that's being documented. In this case, thematchesPhrase
field--it indicates thatmatchesPhrase: null
will cause it to be ignored.
Thoughts?
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 makes sense. I've reverted the change and can see where you're coming from.
The confusion on my side stemmed from the fact that most of the examples show how to populate the matchesQuery
parameters, so I was assuming passing null
to the query
parameter of matchesQuery
would cause the filter to be ignored; however, it led to a very vague error about the type being unexpected... So maybe there's something we can do to improve that error, instead? WDYT?
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.
however, it led to a very vague error about the type being unexpected...
The type error is the equivalent of a compiler error in a statically typed language such as when the type of an argument doesn't align with the type of the method signature. We're not in control of it (it's provided by the graphql gem and might even be strictly specified by the GraphQL spec), and it's worth noting that it's not unique to this part of the ElasticGraph query API. You'd get a similar error anytime you write a query that attempts to pass a null
value for a non-null input field.
I think it's part of the learning curve of GraphQL.
|
||
### Bypassing matchesPhrase and matchesQuery | ||
|
||
In order to ignore a `matchesPhrase` or `matchesQuery` filter, you can supply `null` to the `MatchesQueryFilterInput` parameter, as such: |
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.
In order to ignore a `matchesPhrase` or `matchesQuery` filter, you can supply `null` to the `MatchesQueryFilterInput` parameter, as such: | |
In order to make a `matchesPhrase` or `matchesQuery` filter optional, you can supply `null` to the `MatchesQueryFilterInput` parameter, like this: |
We're going to be moving away from the language of "ignoring a filter" with the changes @acerbusace is working on since we very much have to not ignore such a filter when it shows up inside an anyOf
. I think speaking of optional filters avoids that misunderstanding.
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.
Fixed, thanks for letting me know. I've readjusted the paragraph to match the phrasing you provided here. Let me know if further updates are required.
* Remove the language around "ignoring" filters * Revert the changes to the high-level fulltext.md file * Alter the example query to use 2 spaces instead of 4-space tabs
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.
👍
In order to ignore a
matchesQuery
ormatchesPhrase
filter predicate, you can supplynull
to theMatchesQueryFilterInput
orMatchesQueryFilterInput
types, respectively. However, this is not entirely clear from the docs, as they describe supplyingnull
, but not to which field/value. This documentation update aims to make that more clear, and provides an example to highlight the ability to use a null-able variable with these predicates.Tested
Ran the site locally. Here are the screenshots of updates: