Filter by Switch with multible values enabled

I have a field called “userTypes” which is a Switch with multiple values enabled. The options are:
[‘CONSULTANTS’, ‘EMPLOYER’, ‘STREAMING_KNOWLEDGE’]

How do I filter my data on for example userTypes equals ‘CONSULTANTS’?
Thanks

Like this:

query {
 usersList(filter: {
    userTypes: {
      equals: "CONSULTANTS"
    }
  }) {
    count
  }
}

The problem is that it does not seem to show up?

Ahhhh… you have the “Allow Multiple” box selected. Essentially, this turns it into a JSON field that stores an array of multiple string values and is NOT filterable. Do you need a user to be enabled to have multiple types? (i.e. a Consultant AND an Employer for the same user?)

If so, 2 approaches.

  1. Create a table called UserTypes and then make a many-to-many relationship between it and your users table. You’ll then be able to filter based on the relationship.

  2. Maybe the way you’re defining userTypes may best be expressed as different user roles, which can be associated with user records. That’s found in the Application Servicers → Roles area of the console.

If you DON’T need a user to have multiple types, just uncheck the allow multiple box and filtering should work!