Skip to content

Commit 1ccfc0d

Browse files
authored
Merge pull request #6738 from Shopify/eric-lee-allow_graphql_queries_on_prod_stores
Add support for executing GraphQL queries on non-dev stores
2 parents 0873748 + c9b495e commit 1ccfc0d

25 files changed

Lines changed: 354 additions & 111 deletions

packages/app/src/cli/api/graphql/business-platform-organizations/generated/fetch_dev_store_by_domain.ts renamed to packages/app/src/cli/api/graphql/business-platform-organizations/generated/fetch_store_by_domain.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import * as Types from './types.js'
33

44
import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core'
55

6-
export type FetchDevStoreByDomainQueryVariables = Types.Exact<{
6+
export type FetchStoreByDomainQueryVariables = Types.Exact<{
77
domain?: Types.InputMaybe<Types.Scalars['String']['input']>
8+
storeTypes: Types.Scalars['String']['input']
89
}>
910

10-
export type FetchDevStoreByDomainQuery = {
11+
export type FetchStoreByDomainQuery = {
1112
organization?: {
1213
id: string
1314
name: string
@@ -28,19 +29,24 @@ export type FetchDevStoreByDomainQuery = {
2829
} | null
2930
}
3031

31-
export const FetchDevStoreByDomain = {
32+
export const FetchStoreByDomain = {
3233
kind: 'Document',
3334
definitions: [
3435
{
3536
kind: 'OperationDefinition',
3637
operation: 'query',
37-
name: {kind: 'Name', value: 'FetchDevStoreByDomain'},
38+
name: {kind: 'Name', value: 'FetchStoreByDomain'},
3839
variableDefinitions: [
3940
{
4041
kind: 'VariableDefinition',
4142
variable: {kind: 'Variable', name: {kind: 'Name', value: 'domain'}},
4243
type: {kind: 'NamedType', name: {kind: 'Name', value: 'String'}},
4344
},
45+
{
46+
kind: 'VariableDefinition',
47+
variable: {kind: 'Variable', name: {kind: 'Name', value: 'storeTypes'}},
48+
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'String'}}},
49+
},
4450
],
4551
selectionSet: {
4652
kind: 'SelectionSet',
@@ -71,12 +77,12 @@ export const FetchDevStoreByDomain = {
7177
{
7278
kind: 'ObjectField',
7379
name: {kind: 'Name', value: 'operator'},
74-
value: {kind: 'EnumValue', value: 'EQUALS'},
80+
value: {kind: 'EnumValue', value: 'IN'},
7581
},
7682
{
7783
kind: 'ObjectField',
7884
name: {kind: 'Name', value: 'value'},
79-
value: {kind: 'StringValue', value: 'app_development', block: false},
85+
value: {kind: 'Variable', name: {kind: 'Name', value: 'storeTypes'}},
8086
},
8187
],
8288
},
@@ -140,4 +146,4 @@ export const FetchDevStoreByDomain = {
140146
},
141147
},
142148
],
143-
} as unknown as DocumentNode<FetchDevStoreByDomainQuery, FetchDevStoreByDomainQueryVariables>
149+
} as unknown as DocumentNode<FetchStoreByDomainQuery, FetchStoreByDomainQueryVariables>

packages/app/src/cli/api/graphql/business-platform-organizations/queries/fetch_dev_store_by_domain.graphql

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
query FetchStoreByDomain($domain: String, $storeTypes: String!) {
2+
organization {
3+
id
4+
name
5+
accessibleShops(filters: {field: STORE_TYPE, operator: IN, value: $storeTypes}, search: $domain) {
6+
edges {
7+
node {
8+
id
9+
externalId
10+
name
11+
storeType
12+
primaryDomain
13+
shortName
14+
url
15+
}
16+
}
17+
}
18+
currentUser {
19+
organizationPermissions
20+
}
21+
}
22+
}

packages/app/src/cli/commands/app/bulk/execute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default class BulkExecute extends AppLinkedCommand {
2626
await executeBulkOperation({
2727
organization: appContextResult.organization,
2828
remoteApp: appContextResult.remoteApp,
29-
storeFqdn: store.shopDomain,
29+
store,
3030
query,
3131
variables: flags.variables,
3232
variableFile: flags['variable-file'],

packages/app/src/cli/commands/app/execute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class Execute extends AppLinkedCommand {
2525
await executeOperation({
2626
organization: appContextResult.organization,
2727
remoteApp: appContextResult.remoteApp,
28-
storeFqdn: store.shopDomain,
28+
store,
2929
query,
3030
variables: flags.variables,
3131
variableFile: flags['variable-file'],

packages/app/src/cli/models/app/app.test-data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
DevSessionCreateOptions,
3939
DevSessionDeleteOptions,
4040
DevSessionUpdateOptions,
41+
Store,
4142
} from '../../utilities/developer-platform-client.js'
4243
import {AllAppExtensionRegistrationsQuerySchema} from '../../api/graphql/all_app_extension_registrations.js'
4344
import {AppDeploySchema, AppDeployVariables} from '../../api/graphql/app_deploy.js'
@@ -1439,7 +1440,7 @@ export function testDeveloperPlatformClient(stubs: Partial<DeveloperPlatformClie
14391440
Promise.resolve({organization: testOrganization(), apps: [testOrganizationApp()], hasMorePages: false}),
14401441
createApp: (_organization: Organization, _options: CreateAppOptions) => Promise.resolve(testOrganizationApp()),
14411442
devStoresForOrg: (_organizationId: string) => Promise.resolve({stores: [], hasMorePages: false}),
1442-
storeByDomain: (_orgId: string, _shopDomain: string) => Promise.resolve(undefined),
1443+
storeByDomain: (_orgId: string, _shopDomain: string, _storeTypes: Store[]) => Promise.resolve(undefined),
14431444
ensureUserAccessToStore: (_orgId: string, _store: OrganizationStore) => Promise.resolve(),
14441445
appExtensionRegistrations: (_app: MinimalAppIdentifiers) => Promise.resolve(emptyAppExtensionRegistrations),
14451446
appVersions: (_app: MinimalAppIdentifiers) => Promise.resolve(emptyAppVersions),

packages/app/src/cli/models/organization.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ export interface OrganizationStore {
6060
transferDisabled: boolean
6161
convertableToPartnerTest: boolean
6262
provisionable: boolean
63+
storeType?: string
6364
}

packages/app/src/cli/services/bulk-operations/bulk-operation-status.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ describe('getBulkOperationStatus', () => {
203203
)
204204
})
205205

206+
test('uses resolved API version in admin request', async () => {
207+
vi.mocked(resolveApiVersion).mockResolvedValue('test-api-version')
208+
vi.mocked(adminRequestDoc).mockResolvedValue(mockBulkOperation({status: 'RUNNING'}))
209+
210+
await getBulkOperationStatus({organization: mockOrganization, storeFqdn, operationId, remoteApp})
211+
212+
expect(adminRequestDoc).toHaveBeenCalledWith(
213+
expect.objectContaining({
214+
version: 'test-api-version',
215+
}),
216+
)
217+
})
218+
206219
describe('time formatting', () => {
207220
test('uses "Started" for running operations', async () => {
208221
vi.mocked(adminRequestDoc).mockResolvedValue(mockBulkOperation({status: 'RUNNING'}))
@@ -386,4 +399,17 @@ describe('listBulkOperations', () => {
386399
}),
387400
)
388401
})
402+
403+
test('uses resolved API version in admin request', async () => {
404+
vi.mocked(resolveApiVersion).mockResolvedValue('test-api-version')
405+
vi.mocked(adminRequestDoc).mockResolvedValue(mockBulkOperationsList([]))
406+
407+
await listBulkOperations({organization: mockOrganization, storeFqdn, remoteApp})
408+
409+
expect(adminRequestDoc).toHaveBeenCalledWith(
410+
expect.objectContaining({
411+
version: 'test-api-version',
412+
}),
413+
)
414+
})
389415
})

0 commit comments

Comments
 (0)