Improvements and changes coming to the Storefront API
API
Effective October 01, 2021
Action required
At this year's Unite conference, we announced that we wanted to make some sweeping changes and improvements to the Storefront API. With the 2021-10
release, we are taking the first steps towards that goal.
Improved lookup fields
You can now fetch a Product
, Collection
, Page
, or Blog
by its handle or ID:
query FetchProduct {
product(id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzEK") { ... }
# OR
product(handle: "my-cool-shirt") { ... }
}
With the introduction of these new fields, the following fields are now deprecated and will be removed in a future release:
QueryRoot.blogByHandle
QueryRoot.pageByHandle
QueryRoot.collectionByHandle
QueryRoot.productByHandle
For more details, please see https://shopify.dev/api/storefront/reference/common-objects/queryroot?api%5Bversion%5D=2021-10#fields-2021-10.
Introducing OnlineStorePublishable
In order to improve consistency among objects with common properties, we have added a new GraphQL interface type named OnlineStorePublishable
. This interface is used to denote a resource type that can be published to the Online Store sales channel, such as Product
, Collection
, Page
, and others.
{
collection(handle: "staff-picks") {
onlineStoreUrl
}
}
As a result, the following fields are now deprecated and will be removed in a future release:
Page.url
Blog.url
Article.url
More information about OnlineStorePublishable
can be found here.
Upcoming changes to object IDs
One of the most consistent pieces of feedback we've received revolves around a subtle but impactful difference between how object IDs are represented in our Admin and Storefront GraphQL APs.
You may have noticed that on the Storefront API, the values for object IDs are Base64 encoded, and furthermore, the decoded value is identical to the Admin API's response. We understand that this slight difference has proven to be problematic for developers who need to inter-operate between the two APIs.
Starting on January 3, 2022 we will begin serving non-encoded object IDs from the unstable
version of the Storefront GraphQL API, with the goal of having the 2022-04
release be the first stable version that does not serve Base64 encoded object IDs.
Refer to this guide for more details on the change and how to migrate your apps.