Skip to content

Commit ed6240e

Browse files
committed
implement mutation support for BulkOps CLI command
1 parent c658f01 commit ed6240e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import {linkedAppContext} from '../../services/app-context.js'
44
import {storeContext} from '../../services/store-context.js'
55
import {executeBulkOperation} from '../../services/bulk-operations/execute-bulk-operation.js'
66
import {globalFlags} from '@shopify/cli-kit/node/cli'
7+
<<<<<<< HEAD
8+
=======
9+
import {renderSuccess, renderInfo, renderWarning} from '@shopify/cli-kit/node/ui'
10+
import {outputContent, outputToken} from '@shopify/cli-kit/node/output'
11+
import {parse, getOperationAST} from 'graphql'
12+
>>>>>>> 3e577c18f0 (implement mutation support for BulkOps CLI command)
713

814
export default class Execute extends AppLinkedCommand {
915
static summary = 'Execute bulk operations.'
@@ -34,11 +40,31 @@ export default class Execute extends AppLinkedCommand {
3440
forceReselectStore: flags.reset,
3541
})
3642

43+
<<<<<<< HEAD
3744
await executeBulkOperation({
3845
app: appContextResult.app,
3946
storeFqdn: store.shopDomain,
4047
query: flags.query,
4148
})
49+
=======
50+
const operationType = getOperationAST(parse(flags.query))?.operation
51+
52+
renderInfo({
53+
headline: `Starting bulk operation ${operationType}.`,
54+
body: `App: ${appContextResult.app.name}\nStore: ${store.shopDomain}`,
55+
})
56+
57+
let bulkOperationResponse
58+
if (operationType === 'query') {
59+
bulkOperationResponse = await runBulkOperationQuery({
60+
storeFqdn: store.shopDomain,
61+
query: flags.query,
62+
})
63+
}
64+
else if (operationType === 'mutation') {
65+
// TODO: implement mutation support
66+
}
67+
>>>>>>> 3e577c18f0 (implement mutation support for BulkOps CLI command)
4268

4369
return {app: appContextResult.app}
4470
}

packages/app/src/cli/flags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const appFlags = {
3838
export const bulkOperationFlags = {
3939
query: Flags.string({
4040
char: 'q',
41-
description: 'The GraphQL query, as a string.',
41+
description: 'The GraphQL query or mutation, as a string.',
4242
env: 'SHOPIFY_FLAG_QUERY',
4343
required: true,
4444
}),

0 commit comments

Comments
 (0)