Skip to content

Commit ecf9464

Browse files
nickwesselmanericlee878
authored andcommitted
initial implementation of allowing graphql queries on non-dev stores
1 parent 726218f commit ecf9464

File tree

19 files changed

+368
-79
lines changed

19 files changed

+368
-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
@@ -210,6 +210,8 @@ export type BulkOperationsSortKeys =
210210
| 'COMPLETED_AT'
211211
/** Sort by the `created_at` value. */
212212
| 'CREATED_AT'
213+
/** Sort by the `status` value. */
214+
| 'STATUS'
213215

214216
/**
215217
* 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
@@ -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/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
@@ -50,6 +50,16 @@ describe('executeBulkOperation', () => {
5050
} as OrganizationApp
5151

5252
const storeFqdn = 'test-store.myshopify.com'
53+
const mockStore = {
54+
shopId: '123',
55+
link: 'link',
56+
shopDomain: storeFqdn,
57+
shopName: 'Test Store',
58+
transferDisabled: true,
59+
convertableToPartnerTest: false,
60+
provisionable: true,
61+
storeType: 'APP_DEVELOPMENT',
62+
}
5363
const mockAdminSession = {token: 'test-token', storeFqdn}
5464

5565
const createdBulkOperation: NonNullable<
@@ -87,7 +97,7 @@ describe('executeBulkOperation', () => {
8797
await executeBulkOperation({
8898
organization: mockOrganization,
8999
remoteApp: mockRemoteApp,
90-
storeFqdn,
100+
store: mockStore,
91101
query,
92102
})
93103

@@ -110,7 +120,7 @@ describe('executeBulkOperation', () => {
110120
await executeBulkOperation({
111121
organization: mockOrganization,
112122
remoteApp: mockRemoteApp,
113-
storeFqdn,
123+
store: mockStore,
114124
query,
115125
})
116126

@@ -133,7 +143,7 @@ describe('executeBulkOperation', () => {
133143
await executeBulkOperation({
134144
organization: mockOrganization,
135145
remoteApp: mockRemoteApp,
136-
storeFqdn,
146+
store: mockStore,
137147
query: mutation,
138148
})
139149

@@ -158,7 +168,7 @@ describe('executeBulkOperation', () => {
158168
await executeBulkOperation({
159169
organization: mockOrganization,
160170
remoteApp: mockRemoteApp,
161-
storeFqdn,
171+
store: mockStore,
162172
query: mutation,
163173
variables,
164174
})
@@ -181,7 +191,7 @@ describe('executeBulkOperation', () => {
181191
await executeBulkOperation({
182192
organization: mockOrganization,
183193
remoteApp: mockRemoteApp,
184-
storeFqdn,
194+
store: mockStore,
185195
query,
186196
})
187197

@@ -206,7 +216,7 @@ describe('executeBulkOperation', () => {
206216
await executeBulkOperation({
207217
organization: mockOrganization,
208218
remoteApp: mockRemoteApp,
209-
storeFqdn,
219+
store: mockStore,
210220
query,
211221
})
212222

@@ -242,7 +252,7 @@ describe('executeBulkOperation', () => {
242252
await executeBulkOperation({
243253
organization: mockOrganization,
244254
remoteApp: mockRemoteApp,
245-
storeFqdn,
255+
store: mockStore,
246256
query: mutation,
247257
variableFile: variableFilePath,
248258
})
@@ -265,7 +275,7 @@ describe('executeBulkOperation', () => {
265275
executeBulkOperation({
266276
organization: mockOrganization,
267277
remoteApp: mockRemoteApp,
268-
storeFqdn,
278+
store: mockStore,
269279
query: mutation,
270280
variableFile: nonExistentPath,
271281
}),
@@ -284,7 +294,7 @@ describe('executeBulkOperation', () => {
284294
executeBulkOperation({
285295
organization: mockOrganization,
286296
remoteApp: mockRemoteApp,
287-
storeFqdn,
297+
store: mockStore,
288298
query,
289299
variables,
290300
}),
@@ -305,7 +315,7 @@ describe('executeBulkOperation', () => {
305315
executeBulkOperation({
306316
organization: mockOrganization,
307317
remoteApp: mockRemoteApp,
308-
storeFqdn,
318+
store: mockStore,
309319
query,
310320
variableFile: variableFilePath,
311321
}),
@@ -338,7 +348,7 @@ describe('executeBulkOperation', () => {
338348
await executeBulkOperation({
339349
organization: mockOrganization,
340350
remoteApp: mockRemoteApp,
341-
storeFqdn,
351+
store: mockStore,
342352
query,
343353
watch: true,
344354
})
@@ -378,7 +388,7 @@ describe('executeBulkOperation', () => {
378388
await executeBulkOperation({
379389
organization: mockOrganization,
380390
remoteApp: mockRemoteApp,
381-
storeFqdn,
391+
store: mockStore,
382392
query,
383393
watch: true,
384394
})
@@ -467,7 +477,7 @@ describe('executeBulkOperation', () => {
467477
await executeBulkOperation({
468478
organization: mockOrganization,
469479
remoteApp: mockRemoteApp,
470-
storeFqdn,
480+
store: mockStore,
471481
query,
472482
watch: true,
473483
outputFile,
@@ -501,7 +511,7 @@ describe('executeBulkOperation', () => {
501511
await executeBulkOperation({
502512
organization: mockOrganization,
503513
remoteApp: mockRemoteApp,
504-
storeFqdn,
514+
store: mockStore,
505515
query,
506516
watch: true,
507517
})
@@ -530,7 +540,7 @@ describe('executeBulkOperation', () => {
530540
await executeBulkOperation({
531541
organization: mockOrganization,
532542
remoteApp: mockRemoteApp,
533-
storeFqdn,
543+
store: mockStore,
534544
query,
535545
watch: true,
536546
})
@@ -555,7 +565,7 @@ describe('executeBulkOperation', () => {
555565
executeBulkOperation({
556566
organization: mockOrganization,
557567
remoteApp: mockRemoteApp,
558-
storeFqdn,
568+
store: mockStore,
559569
query,
560570
}),
561571
).rejects.toThrow('Bulk operation response returned null with no error message.')

0 commit comments

Comments
 (0)