generated from salesforcecli/plugin-template-sf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2290a88
commit 20f0e7b
Showing
4 changed files
with
34 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,31 @@ | ||
# summary | ||
|
||
Execute GraphQL statements | ||
Execute a GraphQL statement. | ||
|
||
# description | ||
|
||
Run any valid GraphQL statement via the /graphql [API](https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html) | ||
Specify the GraphQL statement with the "--body" flag, either directly at the command line or with a file that contains the statement. You can query Salesforce records using a "query" statement or use mutations to modify Salesforce records. | ||
|
||
This command uses the GraphQL API to query or modify Salesforce objects. For details about the API, and examples of queries and mutations, see https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html. | ||
|
||
# examples | ||
|
||
- Runs the graphql query directly via the command line | ||
- Execute a GraphQL query on the Account object by specifying the query directly to the "--body" flag; the command uses your default org: | ||
|
||
<%= config.bin %> <%= command.id %> --body "query accounts { uiapi { query { Account { edges { node { Id \n Name { value } } } } } } }" | ||
|
||
- Runs a mutation to create an Account, with an `example.txt` file, containing | ||
- Read the GraphQL statement from a file called "example.txt" and execute it on an org with alias "my-org": | ||
|
||
mutation AccountExample{ | ||
uiapi { | ||
AccountCreate(input: { | ||
Account: { | ||
Name: "Trailblazer Express" | ||
} | ||
}) { | ||
Record { | ||
Id | ||
Name { | ||
value | ||
} | ||
} | ||
} | ||
} | ||
} | ||
<%= config.bin %> <%= command.id %> --body example.txt --target-org my-org | ||
|
||
<%= config.bin %> <%= command.id %> --body example.txt | ||
- Pipe the GraphQL statement that you want to execute from standard input to the command: | ||
|
||
will create a new account returning specified fields (Id, Name) | ||
$ echo graphql | sf api request graphql --body - | ||
|
||
# flags.header.summary | ||
- Write the output of the command to a file called "output.txt" and include the HTTP response status and headers: | ||
|
||
HTTP header in "key:value" format. | ||
<%= config.bin %> <%= command.id %> --body example.txt --stream-to-file output.txt --include | ||
|
||
# flags.body.summary | ||
|
||
File or content with GraphQL statement. Specify "-" to read from standard input. | ||
File or content with the GraphQL statement. Specify "-" to read from standard input. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters