drupal-graphql / drupal-graphql/graphql
Apply entity query filter to user profile fields
- Dominant language
- PHP
- Stars
- 287
- Forks
- 198
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to filter on user profile fields. I am using the Profile module (https://www.drupal.org/project/profile) to store profile data on user accounts and need a way to filter by them. I have had success filtering by entity reference fields on the user entity by following examples on issue #573 whereby you specify a field name using snake_case and '.' to step into their entities e.g. {field:"roles.target_id", value:["member"]}. However as mainProfiles is not an entity reference field it won't seem to let me target it. mainProfiles does however autocomplete within GraphiQL explorer so is recognised and I can retrieve fields within it. I just can't seem to filter on those values. Does anyone have any ideas how I might get this to work?
Below is an example of what I am trying to do, ideally I would like to eventually target gender for example:
```javascript
targeteduser: userQuery(filter: {conjunction:AND, conditions: [
{field:"status", value:"1"},
{field:"roles.target_id", value:["member"]},
{field:"uid", value:"60"}
# {field:"profiles.nid", value:"21"} // Internal server error if uncommented
# {field:"field_profiles.nid", value:"21"} // Again does not work
# {field:"field_profiles.target_id", value:"21"} // Again does not work
# {field:"field_main_profiles.target_id", value:"21"} // Again does not work
]}) {
count
users: entities{
...on User{
uuid
uid
entityType
entityId
roles {
targetId
}
profiles: mainProfiles {
targetId
entity{
entityId
changed
...on ProfileMain{
fieldGender{
entity{
entityId
entityLabel
}
}
}
}
}
}
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.