[5.x]: Craft GraphQL relatedViaField does not narrow entry relations correctly
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
What happened?
Description
On the remote endpoint https://dev-lawha.plcd.nl/graphql, the entry with ID 214488 exists and direct relation field filters return results. However, when the same relation is queried through relatedToEntries and narrowed with relatedViaField, the response is an empty array. Using relatedViaField at the top level can also trigger a generic GraphQL processing error.
Steps to reproduce
- Query exhibitions related to entry 214488 with a generic relation filter.
- Add field narrowing through showItemOfArtist.
- Compare the result with the direct field filter.
Expected behavior
Only entries related through the requested relation field should be returned.
Actual behavior
An empty array is returned, or the server responds with a generic processing error.
Craft CMS version
Craft Solo 5.9.19
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
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 by reproducing the query against the reported GraphQL endpoint, comparing relatedToEntries with relatedViaField against the direct relation field filter. Trace the relatedToEntries and top-level relatedViaField handling in the GraphQL implementation. Done means the requested field narrowing returns only correctly related entries without a generic processing error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100