Out now! Check out the Poll results: Do you have a Shopify store?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Graphql Locations Query String Not Working

Solved

Graphql Locations Query String Not Working

TravisImagine
Shopify Partner
16 0 2

Hello,

 

I am having an issue with the Locations GraphQL endpoint. I have one specific location that can't be searched for by query string. I have modified the names for these examples. I have:

 

 

{
  locations(first: 1, query: "Name:broken") {
    edges {
      node {
        id
        name
      }
    }
  }
}

Which returns:

 

{
  "data": {
    "locations": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/Location/{REDACTED}",
            "name": "A Store"
          }
        }
      ]
    }
  }

A Store is the first store I have alphabetically. Changing the names changes the store that it picks up by default. If I change that query to select more than `First:1` then it will return multiple stores.

 

If I re-run that first query, but change the name to A Store, it will pick up just that store, it will only return one store if First:5 is requested. Same with my other store. This leads me to believe there is some sort of specific set up on that store that's causing issues.

 

Anyone else come across something like this?

 

 

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 522

This is an accepted solution.

Hi @TravisImagine 👋

 

Since the query parameter "Name:'...'" is invalid, the results are ignoring the parameter. Would you please try replacing it with "name:'...'" instead? The sort order is set by the `sortKey` (i.e. `sortKey: NAME`), but the order shouldn't matter here since the `name` param is an exact match.

 

{
  locations(first: 10, query: "name:A Store", sortKey: NAME) {
    edges {
      node {
        id
        name
      }
    }
  }
}

 

Hope that helps!

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

View solution in original post

Replies 2 (2)

ShopifyDevSup
Shopify Staff
1453 238 522

This is an accepted solution.

Hi @TravisImagine 👋

 

Since the query parameter "Name:'...'" is invalid, the results are ignoring the parameter. Would you please try replacing it with "name:'...'" instead? The sort order is set by the `sortKey` (i.e. `sortKey: NAME`), but the order shouldn't matter here since the `name` param is an exact match.

 

{
  locations(first: 10, query: "name:A Store", sortKey: NAME) {
    edges {
      node {
        id
        name
      }
    }
  }
}

 

Hope that helps!

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

TravisImagine
Shopify Partner
16 0 2

Thanks for the quick response. Yeah this seems to be it. I had more than two stores in my shop, and it worked previously for the first, third and fourth alphabetically, but not the second. Very odd, but now it works for all four! So it must have been the capitalization on the search parameter. Thanks!