many-to-many
many-to-many copied to clipboard
GraphQL QueryArgument ":notempty:" not working for many-to-many field
Describe the bug
We have two sections: Organisation Entries and Job Entries. Each Job Entry has a "organisation" relationship field that selects one organisation. In the organisation entry itself we added a many-to-many relationship field called "relatedJobs".
There is no way to filter the organisation entries to only show organisations where the relatedJobs
is not empty.
Testing this with the built-in relationship field on the job entries this is working without an issue.
Steps to reproduce
- create two section types
- add on relationship field and one many-to-many relationship field on the entries
- query for both with queryargument ":notempty:"
query GetOrganisationsWithJobOffers {
organisationsEntries(relatedJobs: ":notempty:") {
... on EntryInterface {
title
}
... on organisations_organisation_Entry {
relatedJobs {
title
}
}
}
allOrgEntries: organisationsEntries {
... on EntryInterface {
title
}
... on organisations_organisation_Entry {
relatedJobs {
title
}
}
}
jobsEntries(organisation: ":notempty:") {
... on jobs_jobOffer_Entry {
title
organisation {
title
}
}
}
}
Result:
{
"data": {
"organisationsEntries": [],
"allOrgEntries": [
{
"title": "Some Organisation",
"relatedJobs": [
{
"title": "Some Job Offer"
}
]
},
{
"title": "Some Other Organisation",
"relatedJobs": []
}
],
"jobsEntries": [
{
"title": "Some Job Offer",
"organisation": [
{
"title": "Some Organisation"
}
]
}
]
}
}
Craft CMS version
4.5.6.1
Plugin version
3.0.4
Multi-site?
No
Additional context
No response
Still looking into this, I'm not sure why, but the arguments aren't even being picked up for the field! But this may very well be related to https://github.com/craftcms/cms/issues/3538