[GraphQL] Empty `relatedToAll` argument gives back no results
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the GraphQL entries query implementation and trace how an empty relatedToAll array is handled. Compare that behavior with an empty relatedTo array using the reproduction query and the issue's expected result. Done means an empty relatedToAll value returns all matching entries rather than no results, with coverage for the empty-array case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100