Parameter tag_not for argument query in Order API doesn't work

I send this query:

{
  orders(first: 250, query: "tag_not:'test'") {
    edges {
      node {
        id
        processedAt
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

to endpoint admin/api/2023-07/graphql.json.

Instead of getting a list of orders that do not contain this tag, I get an empty array.

If I use the “tag” parameter, the api returns the correct response with an array of orders.

Moreover, within the same application, "tag_not" works for one shop, but does not work for the rest shops.

Hi @dmitry_5 ,

I came across this thread from @Alan_19 . It looks like your syntax is similar to what was causing the issue there, so perhaps make the suggested adjustments and retry.

Good luck!

Thanks @jpola12

Yes, indeed, this solution works when we have just one condition with the tag_not parameter, but if there are 2 tag_not parameters this solution does not work, for example:

tag_not: Test AND tag_not: Test2

Hi Vinnc87,

This does seem pretty weird, here’s two things to check:

  • Does at least one order have the test tag? I believe for the no_tag filter to work there needs to be at least one order with the tag.
  • Does your app have the read_all_orders scope?

Check the above and let me know if you’re still seeing this issue.

Hi @Liam

  1. Yes, some orders have ‘Test’ and ‘Test2’ tags
  2. No, our app doesn’t have this scope, only read_orders and write_orders

Can you add the read_all_orders scope and test this again?

Maybe something like this could work for you?

{
  orders(first: 10, query: "(fulfillment_status:unfulfilled) AND (tag_not:'SomethingElse') AND (tag_not:'SomeThing') " ) {
    nodes {
      id
    }
  }
}