Good afternoon,
Is there a corresponding query/property in the GraphQL API which we could use instead of the deprecated shop.primary_location_id (Shop - REST) ?
Thank you!
Piotr
Good afternoon,
Is there a corresponding query/property in the GraphQL API which we could use instead of the deprecated shop.primary_location_id (Shop - REST) ?
Thank you!
Piotr
Hi Piotr,
It doesn’t look like there is a direct replacement for this deprecated endpoint, but the locations query would be the closest in the GraphQL API. You can filter by date created and name, etc.
Thanks Liam!
I’ve found the locations - GraphQL Admin query, but I’m not sure which of the properties of the GraphQL Location object (Location - GraphQL Admin) would be a replacement for the REST Shop’s “primary_location_id” property (Shop - REST) ? The Location’s “isPrimary” GraphQL property is deprecated.
Correct - there is no direct replacement because it’s deprecated. You’d need to get them all with the locations query.
What would be your specific requirement for this?
Using the existing REST Shop - REST endpoint (property “primary_location_id”) we are reading how the merchant configured their “Default Location” setting in Settings->Locations->Default Location:
We use this setting as a fallback/default location in our business logic when trying to pick the appropriate Shopify location (mapping between locations in our system and the ones in Shopify).
I see there’s a default
property you can filter by on the query field for locations
:
I’m afraid no - I just tested the default
property of the query
and as per the docs Filter by a case-insensitive search of multiple fields in a document.
- all it does it lets me not specify the field I’m filtering on, and just do sth like
query {
locations(first: 10, query:"xxx") {
rather than having to indicate the specific field e.g.
query {
locations(first: 10, query:"name:xxx") {
This might not be possible in that case via the API. One possible workaround could be to get the merchant to indicate what the default is, within your app and store this as a metafield - however that might not be very reliable as changes would not populate across.