Run scripts before or after executing operations in the playground for authentication, validation and other workflows
Pre-flight > Pre-Operation > Execute Operation > Post-Operation
Navigate to the Script Editor
Edit or Create a Script
Enter and Test the Script
Set the Script for Use
Enable the Script
Run Your Operation
API | Description |
---|---|
playground.env.set(name: string, value: any): void | Sets a local environment variable with a specified key (name ) and value . |
playground.env.get(name: string): JSONValue | Retrieves the value of a local environment variable using the key (name ). |
playground.request.body: { query: string; variables?: { [key: string]: JSONValue }; operationName?: string } | Represents the GraphQL request body. Contains the query string, an optional variables object, and an optional operationName . |
playground.response.body?.data?: T | Holds the data returned from the GraphQL operation within the response body, where data is of a generic type T . |
playground.CryptoJS: typeof import("crypto-js") | Exposes the crypto-js library, allowing for cryptographic operations. |
{{key}}
. The playground will replace {{key}}
with the corresponding value from the environment variables before executing your operation.
set
command.