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

vinnc87
Shopify Partner
3 0 0

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.

Replies 6 (6)

jpola12
Tourist
4 0 2

Hi @vinnc87

 

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

 

Good luck!

 

vinnc87
Shopify Partner
3 0 0

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

erik_lindberg_s
Shopify Partner
16 3 5

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
}
}
}



Liam
Shopify Staff
2731 302 783

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.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

vinnc87
Shopify Partner
3 0 0

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 

Liam
Shopify Staff
2731 302 783

Can you add the `read_all_orders` scope and test this again?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog