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

Apply entity query filter to user profile fields #1093

Open
reallyquitetoby opened this issue Sep 29, 2020 · 0 comments
Open

Apply entity query filter to user profile fields #1093

reallyquitetoby opened this issue Sep 29, 2020 · 0 comments

Comments

@reallyquitetoby
Copy link

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:

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
                              }
                            }
                          }
                        }
                      }
              }
            }
    }
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

2 participants