From 10344bcfcc081738c63c0c8c8fd99dadf5f37158 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Thu, 15 Aug 2024 15:11:41 -0600 Subject: [PATCH 01/12] feat: add api request graphql command, UTs, NUTs --- README.md | 63 ++++++++--- command-snapshot.json | 8 ++ messages/graphql.md | 35 ++++++ package.json | 1 + src/commands/api/request/graphql.ts | 109 ++++++++++++++++++ src/commands/api/request/rest.ts | 2 +- test/commands/api/request/graphql.nut.ts | 131 ++++++++++++++++++++++ test/commands/api/request/graphql.test.ts | 104 +++++++++++++++++ 8 files changed, 437 insertions(+), 16 deletions(-) create mode 100644 messages/graphql.md create mode 100644 src/commands/api/request/graphql.ts create mode 100644 test/commands/api/request/graphql.nut.ts create mode 100644 test/commands/api/request/graphql.test.ts diff --git a/README.md b/README.md index 45d3817..c1f82a2 100644 --- a/README.md +++ b/README.md @@ -107,43 +107,76 @@ sf plugins -- [`sf hello world`](#sf-hello-world) +- [`sf api request graphql`](#sf-api-request-graphql) +- [`sf api request rest ENDPOINT`](#sf-api-request-rest-endpoint) -## `sf hello world` +## `sf api request graphql` -Say hello. +Summary of a command. ``` USAGE - $ sf hello world [--json] [--flags-dir ] [-n ] + $ sf api request graphql -o --body file [--json] [--flags-dir ] [-S Example: report.xlsx | -i] FLAGS - -n, --name= [default: World] The name of the person you'd like to say hello to. + -S, --stream-to-file=Example: report.xlsx Stream responses to a file. + -i, --include Include the HTTP response status and headers in the output. + -o, --target-org= (required) Username or alias of the target org. Not required if the + `target-org` configuration variable is already set. + --body=file (required) File to use as the body for the request. Specify "-" to read + from standard input. GLOBAL FLAGS --flags-dir= Import flag values from a directory. --json Format output as json. DESCRIPTION - Say hello. + Summary of a command. - Say hello either to the world or someone you know. + More information about a command. Don't repeat the summary. EXAMPLES - Say hello to the world: + $ sf api request graphql +``` + +_See code: [src/commands/api/request/graphql.ts](https://github.com/salesforcecli/plugin-api/blob/v1.0.0/src/commands/api/request/graphql.ts)_ + +## `sf api request rest ENDPOINT` + +Make an authenticated HTTP request to Salesforce REST API and print the response. + +``` +USAGE + $ sf api request rest ENDPOINT -o username [--flags-dir ] [-i | -S Example: report.xlsx] [-X + GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS|TRACE] [-H key:value...] [--body file] - $ sf hello world +ARGUMENTS + ENDPOINT Salesforce API endpoint - Say hello to someone you know: +FLAGS + -H, --header=key:value... HTTP header in "key:value" format. + -S, --stream-to-file=Example: report.xlsx Stream responses to a file. + -X, --method=