cms
cms copied to clipboard
[GraphQL] Empty `relatedToAll` argument gives back no results
Description
I'm unable to get back any entries when no related to values are provided. This differs from relatedTo
where providing an empty array would give back all entries.
I'm working on a filter where by default all entries have to be provided. However if a relational filter is selected the relatedToAll
needs to narrow down the amount of entries based on the ID, this works as expected. The problem is with when there are no relatedTo
arguments provided it is still narrowing down the results. Since the query itself is static I'll always need to provide some value to the relatedToAll
argument.
Please let me know if there's an alternative value that would provide me all entries by default.
Steps to reproduce
- The below query would provide nothing
query MyQuery($relatedToAll: [Int] = []) {
rentals: entries(section: "rentals", relatedToAll: $relatedToAll) {
... on rentals_rental_Entry {
title
}
}
}
Additional info
- Craft version: 3.5.5
- PHP version: 7.2.33
- Database driver & version: MySQL 5.7
- Plugins & versions: Redactor 2.7.1, Redirect Manager 1.1.1, SEOmatic 3.3.16, Typed link field 2.0.0-beta.10
And of course while writing this I figured out you don't need to always provide a default value to a variable. Removing the = []
did the trick.
query MyQuery($relatedToAll: [Int]) {
rentals: entries(section: "rentals", relatedToAll: $relatedToAll) {
... on rentals_rental_Entry {
title
}
}
}
But I'm gonna leave this open since the behaviour is different between relatedTo
and relatedToAll
Good call! This has to happen for 3.6, though, since it would affect queries already out there.