craftcms / craftcms/cms

[4.x]: GraphQL "not" keyword working with tag field ids

Open
#13,175 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug craft4
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

What happened?
Description

Hello, I'm trying to filter out entries that include certain tag ids using GraphQL.

However an entry query with a tag field argument with variable ["not", ...ids] returns all entries that include the id(s) instead of of all entries not including.

Example below:

Screenshot 2023-05-10 at 2 27 01 pm

As a note: i've also tried using relatedToTags using the not keyword in the id argument inside that but it also returned the same results - all entries including the id.

Steps to reproduce
  1. Make an entry or entries query with a tag field argument in the graphiql
  2. Pass a variable such as "not 123", ["not", "123", "1234"], ["not 124"] on the tag field argument
  3. Run and get results including the id(s) instead of the inverse
Expected behavior

Show all entries that does not contain the tag with id(s)

Actual behavior

Shows all entries that includes the id(s)

Craft CMS version

4.4.5

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 tag-field filter in GraphiQL using the reported Craft CMS 4.4.5 queries and variables. Trace the entry query's tag field argument handling and compare it with relatedToTags; done means tag IDs prefixed with not exclude matching entries, including for multiple IDs, with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, php
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.