diff --git a/config/site/examples/music/queries/filtering/OptionalMatchingFilter.graphql b/config/site/examples/music/queries/filtering/OptionalMatchingFilter.graphql new file mode 100644 index 00000000..89afeae9 --- /dev/null +++ b/config/site/examples/music/queries/filtering/OptionalMatchingFilter.graphql @@ -0,0 +1,18 @@ +query OptionalMatchingFilter( + $optionalMatchQuery: MatchesQueryFilterInput = null +) { + artists(filter: { + bio: { + description: { + matchesQuery: $optionalMatchQuery + } + } + }) { + nodes { + name + bio { + description + } + } + } +} \ No newline at end of file diff --git a/config/site/src/query-api/filtering/full-text-search.md b/config/site/src/query-api/filtering/full-text-search.md index ad3ce689..2071cb01 100644 --- a/config/site/src/query-api/filtering/full-text-search.md +++ b/config/site/src/query-api/filtering/full-text-search.md @@ -39,3 +39,11 @@ are supported to control both aspects to make matching stricter: {% highlight graphql %} {{ site.data.music_queries.filtering.PhraseSearch }} {% endhighlight %} + +### Bypassing matchesPhrase and matchesQuery + +In order to make a `matchesPhrase` or `matchesQuery` filter optional, you can supply `null` to the `MatchesQueryFilterInput` parameter, like this: + +{% highlight graphql %} +{{ site.data.music_queries.filtering.OptionalMatchingFilter }} +{% endhighlight %}