-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathexecute.ts
More file actions
33 lines (27 loc) · 1.25 KB
/
execute.ts
File metadata and controls
33 lines (27 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {storeOperationFlags} from '../../flags.js'
import {storeExecuteOperation} from '../../services/store-execute-operation.js'
import {loadQuery} from '../../utilities/execute-command-helpers.js'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import BaseCommand from '@shopify/cli-kit/node/base-command'
export default class StoreExecute extends BaseCommand {
static summary = 'Execute GraphQL queries and mutations against a store.'
static descriptionWithMarkdown = `Executes an Admin API GraphQL query or mutation on the specified store, authenticated as the current user.
Unlike [\`app execute\`](https://shopify.dev/docs/api/shopify-cli/app/app-execute), this command does not require an app to be linked or installed on the target store.`
static description = this.descriptionWithoutMarkdown()
static flags = {
...globalFlags,
...storeOperationFlags,
}
async run(): Promise<void> {
const {flags} = await this.parse(StoreExecute)
const query = await loadQuery(flags)
await storeExecuteOperation({
storeFqdn: flags.store,
query,
variables: flags.variables,
variableFile: flags['variable-file'],
outputFile: flags['output-file'],
...(flags.version && {version: flags.version}),
})
}
}