Skip to content

Commit cbb8441

Browse files
chore: --api-version
1 parent 03829eb commit cbb8441

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

command-snapshot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"command": "api:request:graphql",
55
"flagAliases": [],
66
"flagChars": ["S", "i", "o"],
7-
"flags": ["body", "flags-dir", "include", "json", "stream-to-file", "target-org"],
7+
"flags": ["api-version", "body", "flags-dir", "include", "json", "stream-to-file", "target-org"],
88
"plugin": "@salesforce/plugin-api"
99
},
1010
{

src/commands/api/request/graphql.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default class Graphql extends SfCommand<void> {
2323

2424
public static readonly flags = {
2525
'target-org': Flags.requiredOrg(),
26+
'api-version': Flags.orgApiVersion(),
2627
'stream-to-file': streamToFileFlag,
2728
include: includeFlag,
2829
body: Flags.string({
@@ -38,15 +39,14 @@ export default class Graphql extends SfCommand<void> {
3839

3940
const org = flags['target-org'];
4041
const streamFile = flags['stream-to-file'];
41-
const apiVersion = await org.retrieveMaxApiVersion();
42+
const apiVersion = flags['api-version'] ?? (await org.retrieveMaxApiVersion());
4243
const body = `{"query":"${(fs.existsSync(flags.body) ? fs.readFileSync(flags.body, 'utf8') : flags.body)
4344
.replaceAll(os.EOL, '\\n')
4445
.replaceAll('"', '\\"')}"}`;
46+
const url = new URL(`${org.getField<string>(Org.Fields.INSTANCE_URL)}/services/data/v${apiVersion}/graphql`);
4547

4648
await org.refreshAuth();
4749

48-
const url = new URL(`${org.getField<string>(Org.Fields.INSTANCE_URL)}/services/data/v${apiVersion}/graphql`);
49-
5050
const options = {
5151
agent: { https: new ProxyAgent() },
5252
headers: {

src/shared/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function getHeaders(keyValPair: string[]): Headers {
3232
}
3333

3434
export async function sendAndPrintRequest(options: {
35-
streamFile: string | undefined;
35+
streamFile?: string;
3636
url: URL;
3737
options: Record<string, unknown>;
3838
include: boolean;

0 commit comments

Comments
 (0)