craftcms / craftcms/cms

[5.x]: Craft GraphQL relatedViaField does not narrow entry relations correctly

Open
#18,712 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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
  1. Query exhibitions related to entry 214488 with a generic relation filter.
  2. Add field narrowing through showItemOfArtist.
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.