Apparent BUG in API graphQL search syntax (query argument), filter (Field) parameters

den232
Shopify Partner
143 5 43

 

 

 

 

Using the API search with a query argument gets results that differ significantly from the documentation.

case 1. a term search (query:"foo") (no fields specified) finds not just the text requested, but also anything containing that substring.  Acts like a prefix query (query:"foo*")

case 2. a field search (query:"title=foo") retrieves records for which the title does not contain foo, but the handle contains foo.

case 3. a field/prefix search for tag (query:"how*") does not find tags beginning with the specified substring

Below are some cases from graphiQL using the storefront API on a small database

_________________________


result 1. search for foo anywhere

 {
  products(first: 10, query:"foo") {
    edges { node { id handle title tags }}
  }
}

{
  "data": {
    "products": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/Product/7430316884146",
            "handle": "az-44",
            "title": "az 21",
            "tags": [
              "flat",
              "foo",
              "howlite",
              "marbled"
            ]
          }
        },
        {
          "node": {
            "id": "gid://shopify/Product/7432788050098",
            "handle": "foo",
            "title": "customer_7432788050098_design_7432788050098_version_4.000006",
            "tags": []
          }
        },
        {
          "node": {
            "id": "gid://shopify/Product/7433296281778",
            "handle": "foo-1",
            "title": "bar",
            "tags": []
          }
        },
        {
          "node": {
            "id": "gid://shopify/Product/7433349464242",
            "handle": "bar",
            "title": "foo",
            "tags": []
          }
        }
      ]
    }
  }
}

---------------------------------------

result 2. search for title=foo

 {
  products(first: 10, query:"title='foo'") {
    edges { node { id handle title tags }}
  }
}

{
  "data": {
    "products": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/Product/7432788050098",
            "handle": "foo",
            "title": "customer_7432788050098_design_7432788050098_version_4.000006",
            "tags": []
          }
        },
        {
          "node": {
            "id": "gid://shopify/Product/7433296281778",
            "handle": "foo-1",
            "title": "bar",
            "tags": []
          }
        },
        {
          "node": {
            "id": "gid://shopify/Product/7433349464242",
            "handle": "bar",
            "title": "foo",
            "tags": []
          }
        }
      ]
    }
  }
}

----------------------

result 3. search for tag foo

  {
  products(first: 10, query:"tag:foo") {
    edges { node { id handle title tags }}
  }
}

{
  "data": {
    "products": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/Product/7430316884146",
            "handle": "az-44",
            "title": "az 21",
            "tags": [
              "flat",
              "foo",
              "howlite",
              "marbled"
            ]
          }
        }
      ]
    }
  }
}

---------------------------

result 4. search for tag how

 {
  products(first: 10, query:"tag:how") {
    edges { node { id handle title tags }}
  }
}

{
  "data": {
    "products": {
      "edges": []
    }
  }
}

---------------------------

result 5. search for tag how*

 {
  products(first: 10, query:"tag:how*") {
    edges { node { id handle title tags }}
  }
}

{
  "data": {
    "products": {
      "edges": []
    }
  }
}

--------------------------

For the record, documentation page: https://shopify.dev/api/usage/search-syntax

Supported filter parameters:
(from https://shopify.dev/api/admin-graphql/2021-10/queries/products)

barcode
created_at
delivery_profile_id
error_feedback
gift_card
has_only_composites
has_only_default_variant
id
inventory_total
is_price_reduced
out_of_stock_somewhere
price
product_type
publishable_status
published_status
sku
status
tag
tag_not
title
updated_at
vendor

 

 

 

 

Replies 0 (0)