Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
graphql query filter an attribute by "array of values" or "all except one value"

I have a graphql query like the following one. As you can see, I have a variable defined activityCategory which is of type array of strings. That filter is populated by a multiselect dropdown on the UI which will have options like All, category1, category2 etc. So when All is selected we would send empty array [] to the filter which will return all the categories records. Or what ever were selected by the user for eg: [category1, category2], which then will return only the selected category records only.

gql`
  query searchActivities(
    $activityCategory: [String]
  ) {
    expert {
      engagement {
        getActivities(
          searchQuery: {
            activityCategory: $activityCategory
          }
        ) {
          activities {
            activityId
            activityCategory
            createdDate
            action
          }
        }
      }
    }
  }
`;

Now, we have added one more category to the categories enum let`s say category3 which wouldn't be part of the UI multiselect filter. Also, the behaviour should be like if the option All is selected, it means give all categories records except this newly added category3. And if user selects few categories from the dropdown it'll behave in the same way it used to, an array of user selected values would be sent in the filter and only those will be received.

In short, for the variable activityCategory from the above query, the value would be either activityCategory: {ne: "category3"} or activityCategory: ["category1", "category2"]. How does the above query change in this case? What type would I define for the query variable activityCategory instead of [String]?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!