The GraphQL Request block
The GraphQL Request block runs a GraphQL query or mutation request that you select from a collection. The request returns a single response, which the block sends through an output port along with any test results.
The GraphQL Request block consumes one credit each time it runs in the Postman cloud. To learn more, see How Flows consume credits.
Input
Send - If you connect another block to this input port, that block triggers the GraphQL Request block to run. This connection is optional. The GraphQL Request block will run when the flow runs and all required inputs have values.
Variables - If the selected request obtains values from variables, those variables will be listed here. Requests can reference variables in GraphQL argument values, authorization settings, test scripts, and the request body.
If an argument’s value was set without using a variable:
-
No variable will be listed for it in the GraphQL Request block.
-
There is no way to override its value from a flow.
To learn how to set or override these variable values, see Setup.
Outputs
Success - Sends the response of a successful request and any passed or failed test results. To succeed, a request must return a 2xx HTTP status code.
Fail - Sends the response of an unsuccessful request and any passed or failed test results. A request will fail if it returns an HTTP status code other than 2xx.
Setup
Search for requests - Click to open a dropdown list showing all the collections in your workspace. Select a collection, then select a request.
Variables - To assign a value to a request’s variable, use either of the following methods:
-
Connect another block’s output port to the variable’s input port.
-
Click
Add data blocks to Insert a data block inline.
You can also use these methods to assign values to environment variables or dynamic variables used in a request. If your request uses dynamic variables, the dynamic variables will work as usual in your flow. If you want to override their values, use one of the value assignment methods to assign the values you prefer.
Additional Settings
Parse Response - Specify how the GraphQL Request block parses the response it sends. Select from the following options:
- Auto
- JSON
- XML
- HTML
- Text
Allow scripts to update environment variables - Requests can change environment variables’ values with scripts. When enabled (default), if before-query or after-response scripts change an environment variable’s value, the new value persists after the GraphQL Request block completes its task. Turn this off to prevent those changes from persisting after each time the block completes its task.
Ignore test failures when routing - When enabled (default), the GraphQL Request block routes any response with a 2xx code through the Success output port even if it includes failed tests. Turn this off to route responses through the Fail output port if any tests fail.
Update environment variables with scripts
Requests can change environment variables’ values with scripts. You can configure the GraphQL Request block so that environment variable values changed by before-query and after-response scripts persist or reset when the block’s run completes. By default, script-changed values persist in new GraphQL Request blocks. Deployed flows don’t support persistent changed values for environment variables.
To turn persistent changes to environment variables on or off, do the following:
-
Click the GraphQL Request block.
-
Click
Additional Settings.
-
Turn the Allow scripts to update environment variables toggle on or off.
Left is off,
right is on.