-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scripts): add
request.body.getComputed()
(#262)
Returns the `string` request body as sent via curl; with variables substituted, or `undefined` if there is no body. Very useful if you want to see the request body as it was sent to the server. The `tryGetSubstituted` method will substitute variables with their values, but leave the rest of the body as is. If you have a GraphQL query in the body, for example, the `getComputed` method will show the query as it was sent to the server, which is quite different from the substituted version. As an example, if you have a request body like this: ```graphql query getRestClient($name: String!) { restclient(name: $name) { id name editorsSupported { name } } } { "variables": { "name": "{{ENV_VAR_CLIENT_NAME}}" } } ``` Then the `getComputed` method will return the body as it was sent to the server: ```json {"query": "query getRestClient($name: String!) { restclient(name: $name) { id name editorsSupported { name } } } ", "variables": {"variables": {"name": "kulala"}}} ``` whereas the `tryGetSubstituted` method will return the body with variables substituted as seen in your script: ```graphql query getRestClient($name: String!) { restclient(name: $name) { id name editorsSupported { name } } } { "variables": { "name": "kulala" } } ``` The `getComputed` method is always `undefined` for binary bodies.
- Loading branch information
1 parent
757f87c
commit 3407b68
Showing
5 changed files
with
121 additions
and
21 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
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
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