Question

Proper use of AND Operator, respectively NOT

  • 29 November 2022
  • 1 reply
  • 95 views

Badge

Hello everyone,

I have again a GraphQL related question. We do have a news-type that may be of different kinds (e.g. Topnachrichten which is “Top News” in English) and those may be tagged. One of those tags is “test”.

So we played around with the combination of those values and found interesting behavior of the GraphQL API.

query NewsTypeCounts {
all_news: all_newspage {
total
}
count_top_news: all_newspage(
where: {news_types: {select_news_type: "Topnachrichten"}}
) {
total
}
count_not_top_news: all_newspage(
where: {news_types: {select_news_type_ne: "Topnachrichten"}}
) {
total
}
news_not_tagged_with_test: all_newspage(
where: {tags_nin: "test"}
) {
total
}
news_tagged_with_test: all_newspage(
where: {tags_in: "test"}
) {
total
}
with_and: all_newspage(
where: {AND: {tags_nin: "test", news_types: {select_news_type: "Topnachrichten"}}}
) {
total
}
}

The results are as follows

{
"data": {
"all_news": {
"total": 372
},
"count_top_news": {
"total": 12
},
"count_not_top_news": {
"total": 372
},
"news_not_tagged_with_test": {
"total": 372
},
"news_tagged_with_test": {
"total": 0
},
"with_and": {
"total": 372
}
}
}

Let’s check the results

  • we have a total of 372 news ✅
  • of those 12 are “Top News“ ✅
  • of those 372 are not “Top News” ❌
    • that should be 360
  • of those 372 are not tagged with “test” ✅
  • of those 0 are tagget with “test” ✅
  • of those 372 are not tagget with “test” and are “Top News” ❌
    • that should be 0

Maybe I should use a different way of negation?


1 reply

Userlevel 5

Hi - the team is looking into your question. More to come. 

Reply