Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/preview-store-pool-opt-in.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/store': patch
---

Preview store creation now labels its requests (`source: "shopify_cli"`) and opts in to the backend's warm pool (`pool: true`). Inert until the backend enables the pool for this source; creation falls back to inline behavior otherwise, with an unchanged response shape.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ describe('preview store client', () => {
}),
body: JSON.stringify({
name: 'Lavender Candles',
source: 'shopify_cli',
pool: true,
variables: {storeCreatePayload: {country: 'US'}},
}),
})
Expand Down Expand Up @@ -153,7 +155,7 @@ describe('preview store client', () => {
expect(got.adminApiScopes).toEqual(['read_themes', 'write_themes'])
})

test('omits name and country variables when absent', async () => {
test('omits name and country variables when absent (label and pool opt-in always sent)', async () => {
vi.mocked(shopifyFetch).mockResolvedValueOnce(
response(201, {
shop: {id: 123, name: 'My Store', domain: 'x.myshopify.com'},
Expand All @@ -165,7 +167,7 @@ describe('preview store client', () => {

await createPreviewStore({}, {storage: inMemoryStorage('instance-1')})

expect(vi.mocked(shopifyFetch).mock.calls[0]![1]!.body).toBe('{}')
expect(vi.mocked(shopifyFetch).mock.calls[0]![1]!.body).toBe(JSON.stringify({source: 'shopify_cli', pool: true}))
})

test.each([
Expand Down
11 changes: 11 additions & 0 deletions packages/store/src/cli/services/store/create/preview/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ function clientStorage() {

export interface PreviewStoreClientOptions extends PreviewStoreRequestOptions {}

// The CLI's create label + warm-pool opt-in, sent together on purpose: the
// backend stocks warm preview stores per (country, source) cell, so the same
// release that asks for a pooled store (pool: true) must label the request
// (source: "shopify_cli") for the pool to have a matching cell. Both fields
// are inert until the backend enables the pool for this source: an unstocked
// or disabled pool falls back to inline creation and the response shape is
// unchanged.
export const PREVIEW_STORE_SOURCE = 'shopify_cli'

interface PreviewStoreCreateRequest {
name?: string
country?: string
Expand Down Expand Up @@ -137,6 +146,8 @@ export async function createPreviewStore(
const url = `https://${fqdn}/services/preview-stores`
const body = JSON.stringify({
...(request.name ? {name: request.name} : {}),
source: PREVIEW_STORE_SOURCE,
pool: true,
...(request.country
? {
variables: {
Expand Down
Loading