Skip to content

Commit 7a95eed

Browse files
committed
initial implementation of allowing graphql queries on non-dev stores
1 parent 5568d31 commit 7a95eed

File tree

19 files changed

+352
-79
lines changed

19 files changed

+352
-79
lines changed

packages/app/src/cli/api/graphql/app-dev/generated/types.d.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/consistent-type-definitions, @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any, tsdoc/syntax */
1+
/* eslint-disable @typescript-eslint/consistent-type-definitions, @typescript-eslint/naming-convention, tsdoc/syntax */
22
import {JsonMapType} from '@shopify/cli-kit/node/toml'
33

44
export type Maybe<T> = T | null
@@ -15,12 +15,6 @@ export type Scalars = {
1515
Boolean: {input: boolean; output: boolean}
1616
Int: {input: number; output: number}
1717
Float: {input: number; output: number}
18-
/**
19-
* Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date and time string.
20-
* For example, 3:50 pm on September 7, 2019 in the time zone of UTC (Coordinated Universal Time) is
21-
* represented as `"2019-09-07T15:50:00Z`".
22-
*/
23-
DateTime: {input: any; output: any}
2418
/**
2519
* A [JSON](https://www.json.org/json-en.html) object.
2620
*
@@ -37,12 +31,4 @@ export type Scalars = {
3731
* }`
3832
*/
3933
JSON: {input: JsonMapType | string; output: JsonMapType}
40-
/**
41-
* Represents an [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986) and
42-
* [RFC 3987](https://datatracker.ietf.org/doc/html/rfc3987)-compliant URI string.
43-
*
44-
* For example, `"https://example.myshopify.com"` is a valid URL. It includes a scheme (`https`) and a host
45-
* (`example.myshopify.com`).
46-
*/
47-
URL: {input: string; output: string}
4834
}

packages/app/src/cli/api/graphql/bulk-operations/generated/types.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ export type BulkOperationsSortKeys =
203203
| 'COMPLETED_AT'
204204
/** Sort by the `created_at` value. */
205205
| 'CREATED_AT'
206+
/** Sort by the `status` value. */
207+
| 'STATUS'
206208

207209
/**
208210
* The possible HTTP methods that can be used when sending a request to upload a file using information from a
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/* eslint-disable @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-duplicate-type-constituents */
2+
import * as Types from './types.js'
3+
4+
import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core'
5+
6+
export type FetchStoreByDomainQueryVariables = Types.Exact<{
7+
domain?: Types.InputMaybe<Types.Scalars['String']['input']>
8+
}>
9+
10+
export type FetchStoreByDomainQuery = {
11+
organization?: {
12+
id: string
13+
name: string
14+
accessibleShops?: {
15+
edges: {
16+
node: {
17+
id: string
18+
externalId?: string | null
19+
name: string
20+
storeType?: Types.Store | null
21+
primaryDomain?: string | null
22+
shortName?: string | null
23+
url?: string | null
24+
}
25+
}[]
26+
} | null
27+
currentUser?: {organizationPermissions: string[]} | {organizationPermissions: string[]} | null
28+
} | null
29+
}
30+
31+
export const FetchStoreByDomain = {
32+
kind: 'Document',
33+
definitions: [
34+
{
35+
kind: 'OperationDefinition',
36+
operation: 'query',
37+
name: {kind: 'Name', value: 'FetchStoreByDomain'},
38+
variableDefinitions: [
39+
{
40+
kind: 'VariableDefinition',
41+
variable: {kind: 'Variable', name: {kind: 'Name', value: 'domain'}},
42+
type: {kind: 'NamedType', name: {kind: 'Name', value: 'String'}},
43+
},
44+
],
45+
selectionSet: {
46+
kind: 'SelectionSet',
47+
selections: [
48+
{
49+
kind: 'Field',
50+
name: {kind: 'Name', value: 'organization'},
51+
selectionSet: {
52+
kind: 'SelectionSet',
53+
selections: [
54+
{kind: 'Field', name: {kind: 'Name', value: 'id'}},
55+
{kind: 'Field', name: {kind: 'Name', value: 'name'}},
56+
{
57+
kind: 'Field',
58+
name: {kind: 'Name', value: 'accessibleShops'},
59+
arguments: [
60+
{
61+
kind: 'Argument',
62+
name: {kind: 'Name', value: 'search'},
63+
value: {kind: 'Variable', name: {kind: 'Name', value: 'domain'}},
64+
},
65+
],
66+
selectionSet: {
67+
kind: 'SelectionSet',
68+
selections: [
69+
{
70+
kind: 'Field',
71+
name: {kind: 'Name', value: 'edges'},
72+
selectionSet: {
73+
kind: 'SelectionSet',
74+
selections: [
75+
{
76+
kind: 'Field',
77+
name: {kind: 'Name', value: 'node'},
78+
selectionSet: {
79+
kind: 'SelectionSet',
80+
selections: [
81+
{kind: 'Field', name: {kind: 'Name', value: 'id'}},
82+
{kind: 'Field', name: {kind: 'Name', value: 'externalId'}},
83+
{kind: 'Field', name: {kind: 'Name', value: 'name'}},
84+
{kind: 'Field', name: {kind: 'Name', value: 'storeType'}},
85+
{kind: 'Field', name: {kind: 'Name', value: 'primaryDomain'}},
86+
{kind: 'Field', name: {kind: 'Name', value: 'shortName'}},
87+
{kind: 'Field', name: {kind: 'Name', value: 'url'}},
88+
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
89+
],
90+
},
91+
},
92+
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
93+
],
94+
},
95+
},
96+
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
97+
],
98+
},
99+
},
100+
{
101+
kind: 'Field',
102+
name: {kind: 'Name', value: 'currentUser'},
103+
selectionSet: {
104+
kind: 'SelectionSet',
105+
selections: [
106+
{kind: 'Field', name: {kind: 'Name', value: 'organizationPermissions'}},
107+
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
108+
],
109+
},
110+
},
111+
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
112+
],
113+
},
114+
},
115+
],
116+
},
117+
},
118+
],
119+
} as unknown as DocumentNode<FetchStoreByDomainQuery, FetchStoreByDomainQueryVariables>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
query FetchStoreByDomain($domain: String) {
2+
organization {
3+
id
4+
name
5+
accessibleShops(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
@@ -25,7 +25,7 @@ export default class BulkExecute extends AppLinkedCommand {
2525

2626
await executeBulkOperation({
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/commands/app/execute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class Execute extends AppLinkedCommand {
2222

2323
await executeOperation({
2424
remoteApp: appContextResult.remoteApp,
25-
storeFqdn: store.shopDomain,
25+
store,
2626
query,
2727
variables: flags.variables,
2828
apiVersion: flags.version,

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/execute-bulk-operation.test.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ describe('executeBulkOperation', () => {
4242
} as OrganizationApp
4343

4444
const storeFqdn = 'test-store.myshopify.com'
45+
const mockStore = {
46+
shopId: '123',
47+
link: 'link',
48+
shopDomain: storeFqdn,
49+
shopName: 'Test Store',
50+
transferDisabled: true,
51+
convertableToPartnerTest: false,
52+
provisionable: true,
53+
storeType: 'APP_DEVELOPMENT',
54+
}
4555
const mockAdminSession = {token: 'test-token', storeFqdn}
4656

4757
const createdBulkOperation: NonNullable<
@@ -75,7 +85,7 @@ describe('executeBulkOperation', () => {
7585

7686
await executeBulkOperation({
7787
remoteApp: mockRemoteApp,
78-
storeFqdn,
88+
store: mockStore,
7989
query,
8090
})
8191

@@ -96,7 +106,7 @@ describe('executeBulkOperation', () => {
96106

97107
await executeBulkOperation({
98108
remoteApp: mockRemoteApp,
99-
storeFqdn,
109+
store: mockStore,
100110
query,
101111
})
102112

@@ -117,7 +127,7 @@ describe('executeBulkOperation', () => {
117127

118128
await executeBulkOperation({
119129
remoteApp: mockRemoteApp,
120-
storeFqdn,
130+
store: mockStore,
121131
query: mutation,
122132
})
123133

@@ -140,7 +150,7 @@ describe('executeBulkOperation', () => {
140150

141151
await executeBulkOperation({
142152
remoteApp: mockRemoteApp,
143-
storeFqdn,
153+
store: mockStore,
144154
query: mutation,
145155
variables,
146156
})
@@ -161,7 +171,7 @@ describe('executeBulkOperation', () => {
161171
vi.mocked(runBulkOperationQuery).mockResolvedValue(mockResponse)
162172
await executeBulkOperation({
163173
remoteApp: mockRemoteApp,
164-
storeFqdn,
174+
store: mockStore,
165175
query,
166176
})
167177

@@ -185,7 +195,7 @@ describe('executeBulkOperation', () => {
185195

186196
await executeBulkOperation({
187197
remoteApp: mockRemoteApp,
188-
storeFqdn,
198+
store: mockStore,
189199
query,
190200
})
191201

@@ -216,7 +226,7 @@ describe('executeBulkOperation', () => {
216226

217227
await executeBulkOperation({
218228
remoteApp: mockRemoteApp,
219-
storeFqdn,
229+
store: mockStore,
220230
query: mutation,
221231
variableFile: variableFilePath,
222232
})
@@ -238,7 +248,7 @@ describe('executeBulkOperation', () => {
238248
await expect(
239249
executeBulkOperation({
240250
remoteApp: mockRemoteApp,
241-
storeFqdn,
251+
store: mockStore,
242252
query: mutation,
243253
variableFile: nonExistentPath,
244254
}),
@@ -256,7 +266,7 @@ describe('executeBulkOperation', () => {
256266
await expect(
257267
executeBulkOperation({
258268
remoteApp: mockRemoteApp,
259-
storeFqdn,
269+
store: mockStore,
260270
query,
261271
variables,
262272
}),
@@ -276,7 +286,7 @@ describe('executeBulkOperation', () => {
276286
await expect(
277287
executeBulkOperation({
278288
remoteApp: mockRemoteApp,
279-
storeFqdn,
289+
store: mockStore,
280290
query,
281291
variableFile: variableFilePath,
282292
}),
@@ -306,7 +316,7 @@ describe('executeBulkOperation', () => {
306316

307317
await executeBulkOperation({
308318
remoteApp: mockRemoteApp,
309-
storeFqdn,
319+
store: mockStore,
310320
query,
311321
watch: true,
312322
})
@@ -338,7 +348,7 @@ describe('executeBulkOperation', () => {
338348

339349
await executeBulkOperation({
340350
remoteApp: mockRemoteApp,
341-
storeFqdn,
351+
store: mockStore,
342352
query,
343353
watch: true,
344354
})
@@ -372,7 +382,7 @@ describe('executeBulkOperation', () => {
372382

373383
await executeBulkOperation({
374384
remoteApp: mockRemoteApp,
375-
storeFqdn,
385+
store: mockStore,
376386
query,
377387
watch: true,
378388
outputFile,
@@ -404,7 +414,7 @@ describe('executeBulkOperation', () => {
404414

405415
await executeBulkOperation({
406416
remoteApp: mockRemoteApp,
407-
storeFqdn,
417+
store: mockStore,
408418
query,
409419
watch: true,
410420
})
@@ -432,7 +442,7 @@ describe('executeBulkOperation', () => {
432442

433443
await executeBulkOperation({
434444
remoteApp: mockRemoteApp,
435-
storeFqdn,
445+
store: mockStore,
436446
query,
437447
watch: true,
438448
})
@@ -456,7 +466,7 @@ describe('executeBulkOperation', () => {
456466
await expect(
457467
executeBulkOperation({
458468
remoteApp: mockRemoteApp,
459-
storeFqdn,
469+
store: mockStore,
460470
query,
461471
}),
462472
).rejects.toThrow('Bulk operation response returned null with no error message.')

0 commit comments

Comments
 (0)