FROM CACHE - en_header

GraphQL query for default location

Solved
HunkyBill
Shopify Expert
4817 60 572

I am looking for the easiest way to get the default physical location for inventory. I can query for Locations, and receive back one or more locations. So if there is one, I assume it is the default. But if I receive 2 or more, can I assume the first is the default? Can that be confirmed, or is there some other way to confirm the default location?

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Accepted Solution (1)

Accepted Solutions
dogowner
Shopify Partner
57 5 8

This is an accepted solution.

If you query location with no id the docs say: "If no ID is provided, the primary location of the Shop is returned."

I'm not sure if that is what you mean by default physical location for inventory but it might help.

View solution in original post

Replies 4 (4)
dogowner
Shopify Partner
57 5 8

This is an accepted solution.

If you query location with no id the docs say: "If no ID is provided, the primary location of the Shop is returned."

I'm not sure if that is what you mean by default physical location for inventory but it might help.

HunkyBill
Shopify Expert
4817 60 572

You mean like this right?

 query {
  location { 
        id
        name
        address {
          phone
          formatted
        }    
        fulfillmentService {
          id
          handle
        }
      }
    }

And that did return a single location. So I guess I will take that as that. Thanks. Note that the schema itself makes no mention of this, so I am indebted to your eagle eyes for picking that aspect out of the pile and showing it to me.

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
dogowner
Shopify Partner
57 5 8

Yeah, I am still really struggling to both decipher and navigate the docs.  I found it in the query root docs under fields and then location, which I can't direct link, But this is the link to fields:

queryroot#fields 

What do you mean by schema?  The schema you query with GraphQL itself?

HunkyBill
Shopify Expert
4817 60 572

Yes. Using Insomnia one can quickly review any aspect of the queries by a link direct to the schema in use. It beats clicking through the clunky docs, which are machine-generated anyway, and rarely offer any human insight into how things are used or why.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com