Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda