A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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?
Solved! Go to the solution
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
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
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!