craftcms / craftcms/cms

[5.x]: GraphQL search does not return renamed text field, while Craft search does

Open
#18,239 4 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

We are encountering an inconsistency between Craft’s native search and GraphQL search when reusing and renaming a text field within an entry.

Problem

When a text field is reused for a different purpose (same field, different context/name) and contains content, the field is searchable in the Craft Control Panel, but cannot be found using a GraphQL search query.

GraphQL search only works if the original field handle is used, not the renamed context in which the field is currently used.

Steps to reproduce
1.	Create a text field (e.g. textUntranslatable) ,check searchable
2.	Use this field in Section A and fill it with content
3.	Reuse the same field in Section B, but give it a different name/label in the layout
4.	Create an entry in Section B and fill the field with searchable text
5.	Search for this text:
•	In Craft CP → works as expected
•	Via GraphQL search argument → no results returned
Expected behavior

GraphQL search should return entries based on the actual stored content, regardless of:
• Field reuse
• Renaming/relabeling in a different field layout context

This should behave consistently with Craft’s native search.

Actual behavior

GraphQL search does not return entries when the field is reused under a different name/context, even though:
• The content exists
• Craft CP search finds it correctly

Craft CMS version

5.8.22

PHP version

8.3.27

Operating system and version

No response

Database type and version

mariadb 10.6

Image driver and version

No response

Installed plugins and versions

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 behavior with a reused text field that has a different layout label, comparing Craft CP search with the GraphQL search argument. Trace how each search path resolves the field context, then verify that GraphQL returns entries containing the renamed field's stored text.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, mariadb, php
Domain
api, databases, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.