Skip to content

Add store list for organization stores#7708

Open
dmerand wants to merge 2 commits into
mainfrom
donald/store-list-business-platform
Open

Add store list for organization stores#7708
dmerand wants to merge 2 commits into
mainfrom
donald/store-list-business-platform

Conversation

@dmerand

@dmerand dmerand commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Add shopify store list, listing the stores in the Shopify organizations available to the current CLI account.

Builds store list out from the prototype in the shopify store create preview stack.

Scope

  • add shopify store list (organization source, backed by Business Platform internally)
  • discover organizations and list per-organization stores, keeping successful organizations with a warning when some fail
  • render Subdomain | Name | Type | Created, sorted newest first
  • fetch only the newest 250 per organization server-side (accessibleShops(sort: SHOP_CREATED_AT_DESC, first: 250), one page) instead of paginating the whole org, then merge/sort/cap to 250 — bounds the work for orgs with thousands of stores
  • on truncation, emit a stderr warning (both formats) and a truncated: true flag in JSON
  • add optional --organization-id to list a single organization; an unknown/inaccessible id errors with the organizations you can access
  • model retrieval as a discriminated success | unresolved-session | organization-not-found result so fallback policy can live in the service index
  • harden the CLI session read against malformed persisted JSON

Review notes

@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 92fffc1 to c7e152d Compare June 5, 2026 13:41
@dmerand dmerand changed the title Add Business Platform-backed store list command Add store list for organization stores Jun 5, 2026
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 3ac3560 to 6fbe857 Compare June 5, 2026 14:24

dmerand commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

@dmerand dmerand force-pushed the donald/store-list-business-platform branch 3 times, most recently from f516bbe to 79dbfa7 Compare June 5, 2026 19:06

amcaplan commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

I believe you should be able to gitignore packages/store/src/cli/api/graphql/business-platform-organizations/organizations_schema.graphql

@dmerand dmerand force-pushed the donald/store-list-business-platform branch 2 times, most recently from 5986997 to b4c7faa Compare June 8, 2026 19:10
@dmerand dmerand marked this pull request as ready for review June 8, 2026 20:56
Copilot AI review requested due to automatic review settings June 8, 2026 20:56
@dmerand dmerand requested review from a team as code owners June 8, 2026 20:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new shopify store list command in the @shopify/store plugin to list stores available through the current CLI account’s Shopify organizations, backed by Business Platform GraphQL. It also extends organizations fetching to expose “current user resolved/email” metadata and hardens CLI session persistence reads against malformed JSON.

Changes:

  • Add shopify store list command + output formatting (text table + JSON), including --organization-id, truncation cap (250), and partial-organization failure warnings.
  • Add a Business Platform Organizations GraphQL query + codegen plumbing for store listing, and wire it to organization discovery via @shopify/organizations.
  • Improve robustness of persisted CLI session reads by discarding malformed JSON and clearing the stored session.

Reviewed changes

Copilot reviewed 26 out of 33 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds lockfile entries for new @shopify/store dependencies.
packages/store/src/index.ts Registers the new store:list command.
packages/store/src/cli/services/store/list/types.ts Defines store list result/entry types and the 250-entry cap constant.
packages/store/src/cli/services/store/list/result.ts Implements text/JSON presenters (table rendering, warnings, truncation messaging).
packages/store/src/cli/services/store/list/result.test.ts Tests presenter behavior (table fields, empty states, JSON, truncation warning).
packages/store/src/cli/services/store/list/index.ts Service entrypoint: handles discriminated results, org-not-found erroring, truncation.
packages/store/src/cli/services/store/list/index.test.ts Tests service behavior (success, unresolved session, org-not-found, truncation).
packages/store/src/cli/services/store/list/bp-source.ts Business Platform-backed store listing: org discovery + per-org store fetch + merge/sort.
packages/store/src/cli/services/store/list/bp-source.test.ts Tests Business Platform source behavior (filters, merging, hasMore, partial failure).
packages/store/src/cli/commands/store/list.ts Adds the shopify store list oclif command and --organization-id / --json.
packages/store/src/cli/commands/store/list.test.ts Tests CLI wiring: flags passthrough and presenter selection.
packages/store/src/cli/api/graphql/business-platform-organizations/queries/list_accessible_shops.graphql Adds query for newest stores per organization (sort: SHOP_CREATED_AT_DESC, first).
packages/store/src/cli/api/graphql/business-platform-organizations/generated/types.d.ts Adds generated schema typings for the store Business Platform orgs project.
packages/store/src/cli/api/graphql/business-platform-organizations/generated/list_accessible_shops.ts Adds generated typed document node for store listing query.
packages/store/project.json Adds Nx targets for GraphQL codegen + formatting/postfix steps for store package.
packages/store/package.json Adds dependencies required for typed GraphQL documents + organizations access info.
packages/organizations/src/index.ts Exports new fetchOrganizationsWithAccessInfo.
packages/organizations/src/cli/services/fetch.ts Implements fetchOrganizationsWithAccessInfo returning orgs + user-resolved/email metadata.
packages/organizations/src/cli/services/fetch.test.ts Adds tests for the new access-info fetch behavior and updates existing fixtures.
packages/organizations/src/cli/api/graphql/business-platform-destinations/queries/organizations.graphql Extends org query to include current user email.
packages/organizations/src/cli/api/graphql/business-platform-destinations/generated/organizations.ts Updates generated query typings to include email.
packages/e2e/data/snapshots/commands.txt Updates CLI command snapshot to include store list.
packages/cli/README.md Updates CLI command reference docs to include shopify store list.
packages/cli/oclif.manifest.json Adds manifest entry for store:list command.
packages/cli-kit/src/private/node/session/store.ts Hardens session store parsing: on malformed JSON, clear persisted sessions and return undefined.
packages/cli-kit/src/private/node/session/store.test.ts Adds test coverage for discarding malformed JSON session content.
package.json Updates knip config for packages/store (ignore generated + mark typed-doc-node dep as ignored).
graphql.config.ts Adds storeBusinessPlatformOrganizations graphql-codegen project configuration.
docs-shopify.dev/generated/generated_docs_data_v2.json Updates generated docs data to include store list command interface metadata.
docs-shopify.dev/commands/interfaces/store-list.interface.ts Adds generated TypeScript interface for store list flags.
bin/get-graphql-schemas.js Ensures BP organizations schema is fetched/copied for both app + store packages.
.gitignore Ignores Business Platform schema files under packages/store.
.changeset/store-list-bp-auto.md Changeset for new command + partial failure behavior + session parsing hardening.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +122 to +124
// Fetches only the newest STORE_LIST_LIMIT stores for the organization, sorted server-side, rather
// than paginating the whole org. The global newest-N is a subset of each org's newest-N, so a
// single bounded page per organization is enough and keeps huge orgs from being walked end to end.
import {Flags} from '@oclif/core'

export default class StoreList extends StoreCommand {
static summary = 'List stores in your Shopify organization.'
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from b4c7faa to cb1e68e Compare June 8, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants