Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: graphql filtering on related category return unespected elements #14258

Closed
vettndr opened this issue Jan 31, 2024 · 5 comments
Closed

Comments

@vettndr
Copy link

vettndr commented Jan 31, 2024

What happened?

Description

I'm filtering records based on a category using graphql and I'm not able to understand why I'm receiving items that not match the id of that category.

Steps to reproduce

craft-query

Expected behavior

I'm expecting to receive only records that have category with id: 20

Actual behavior

Other elements are retrieved.

Craft CMS version

4.7.1

PHP version

8.1.27

Operating system and version

No response

Database type and version

MariaDB 10.6.16

Image driver and version

No response

Installed plugins and versions

craft-plugins

@i-just
Copy link
Contributor

i-just commented Jan 31, 2024

Hi, thanks for getting in touch!

It sounds like a duplicate of: #12740

For now, you can get the results you’re after if you use relatedToCategories instead of offerCategories, like so:

query getOffers {
  OfferEntries(siteId: "1", relatedToCategories: {id: "20"}) {
    ... on Offer_Entry_Entry {
      title
      offerCategories {
        ... on Offer_Category {
          id
        }
      }
    }
  }
}

@vettndr
Copy link
Author

vettndr commented Jan 31, 2024

Hi, thanks for getting in touch!

It sounds like a duplicate of: #12740

For now, you can get the results you’re after if you use relatedToCategories instead of offerCategories, like so:

query getOffers {
  OfferEntries(siteId: "1", relatedToCategories: {id: "20"}) {
    ... on Offer_Entry_Entry {
      title
      offerCategories {
        ... on Offer_Category {
          id
        }
      }
    }
  }
}

Hi @i-just ,
thank you for your reply.

I tried also as you suggested me before to create this issue.
It's still not working.

craft-query-2

@i-just
Copy link
Contributor

i-just commented Feb 1, 2024

Thanks for the info. I’m not able to reproduce this issue when using relatedToCategories. Would you be able to send your composer.json, composer.lock and database export to support@craftcms.com so we can try to replicate it?

@i-just
Copy link
Contributor

i-just commented Feb 19, 2024

The initial issue (querying by related category in a multi-site setup) was fixed in 4.7.3, so I’ll close this now.

@vettndr, if you’re still getting unexpected results when using relatedToCategories, please send the requested files to support, and we’ll have a look into it.

@i-just i-just closed this as completed Feb 19, 2024
@brandonkelly
Copy link
Member

Craft 4.8.0 was just released with a fix for this. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants