From b685cc55d974b1b5e89c6c1c7c802cc0662839f3 Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 15:13:59 +0000 Subject: [PATCH 01/10] Documentation edits made through Mintlify web editor --- docs/studio/playground/custom-scripts.mdx | 76 +++++++++---------- .../playground/shared-playground-state.mdx | 44 +++++++++++ 2 files changed, 80 insertions(+), 40 deletions(-) create mode 100644 docs/studio/playground/shared-playground-state.mdx diff --git a/docs/studio/playground/custom-scripts.mdx b/docs/studio/playground/custom-scripts.mdx index a0e10d6..8ad31a0 100644 --- a/docs/studio/playground/custom-scripts.mdx +++ b/docs/studio/playground/custom-scripts.mdx @@ -1,27 +1,24 @@ --- title: "Custom Scripts" description: "Run scripts before or after executing operations in the playground for authentication, validation and other workflows" -icon: code +icon: "code" --- Create one or more scripts to handle various stages of the request lifecycle for your operations. Incorporate functionality for working with external APIs, authentication tokens, utilizing environment variables, and injecting headers as needed. ## Script Types -* **Pre-Flight Scripts**: This script runs across all instances of the playground and its various tabs. It executes first, before the request is sent to the router. Use pre-flight scripts to set headers or perform authentication workflows. These scripts are enabled by default. - -* **Operation Scripts**: These scripts run either before or after executing an operation and are scoped to a single tab in the playground. By default, they are disabled. - - * **Pre-Operation Scripts**: Executed after the pre-flight script but before the request reaches the router, these scripts function similarly to pre-flight scripts but are applied on a per-operation basis. - - * **Post-Operation Scripts**: These scripts run after the operation completes. Here, you can access the response body and perform any necessary validation steps. +- **Pre-Flight Scripts**: This script runs across all instances of the playground and its various tabs. It executes first, before the request is sent to the router. Use pre-flight scripts to set headers or perform authentication workflows. These scripts are enabled by default. +- **Operation Scripts**: These scripts run either before or after executing an operation and are scoped to a single tab in the playground. By default, they are disabled. + - **Pre-Operation Scripts**: Executed after the pre-flight script but before the request reaches the router, these scripts function similarly to pre-flight scripts but are applied on a per-operation basis. + - **Post-Operation Scripts**: These scripts run after the operation completes. Here, you can access the response body and perform any necessary validation steps. ### Execution Lifecycle Below depicts the execution lifecycle with operation and scripts configured - + ![](/images/studio/image-17.png) ## Creating and running scripts @@ -29,44 +26,45 @@ Below depicts the execution lifecycle with operation and scripts configured You can create multiple scripts of each type and select the appropriate one as needed. All created scripts are accessible at the account level; however, scripts selected for use are scoped specifically to your device or browser. - Scripts are stored in plain text in the database, so avoid including any sensitive information directly in the script. For sensitive data, use environment variables instead, as these are scoped to your device or browser. + Scripts are stored in plain text in the database, so avoid including any sensitive information directly in the script. For sensitive data, use environment variables instead, as these are scoped to your device or browser. To configure scripts for your operations, follow these steps: + - - In the playground, locate the script editor in the bottom-left corner. Here, you can edit **Pre-Flight Scripts** and, under the **Operation Scripts** tab (next to **Variables** and **Headers**), configure operation scripts for the active tab. - - - Click on the** edit icon** to modify the script. A modal will open, with a **Create** button, allowing you to create a new script within your organization. - - - Input your script code in the editor. To test it, run the script directly in the console. You can also manage environment variables using the **Environment Variables** editor, which is formatted in JSON. - - - Click **Use Script** to set it as the script to be used. - - - Once the modal closes, ensure that the checkbox next to the script is ticked to enable it. - - - With the script configured and enabled, proceed to run your operation. - + + In the playground, locate the script editor in the bottom-left corner. Here, you can edit **Pre-Flight Scripts** and, under the **Operation Scripts** tab (next to **Variables** and **Headers**), configure operation scripts for the active tab. + + + Click on the**edit icon** to modify the script. A modal will open, with a **Create** button, allowing you to create a new script within your organization. + + + Input your script code in the editor. To test it, run the script directly in the console. You can also manage environment variables using the **Environment Variables** editor, which is formatted in JSON. + + + Click **Use Script** to set it as the script to be used. + + + Once the modal closes, ensure that the checkbox next to the script is ticked to enable it. + + + With the script configured and enabled, proceed to run your operation. + - + + From a81c1649f2c5c3cf947cdad6e0937bbe66d5789e Mon Sep 17 00:00:00 2001 From: Akshay Garg <145957134+akshaygarg576@users.noreply.github.com> Date: Mon, 12 May 2025 11:13:53 +0530 Subject: [PATCH 08/10] fix: revert unnecessary changes --- docs/studio/playground/custom-scripts.mdx | 75 ++++++++++++----------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/docs/studio/playground/custom-scripts.mdx b/docs/studio/playground/custom-scripts.mdx index 8ad31a0..d179b60 100644 --- a/docs/studio/playground/custom-scripts.mdx +++ b/docs/studio/playground/custom-scripts.mdx @@ -1,24 +1,27 @@ --- title: "Custom Scripts" description: "Run scripts before or after executing operations in the playground for authentication, validation and other workflows" -icon: "code" +icon: code --- Create one or more scripts to handle various stages of the request lifecycle for your operations. Incorporate functionality for working with external APIs, authentication tokens, utilizing environment variables, and injecting headers as needed. ## Script Types -- **Pre-Flight Scripts**: This script runs across all instances of the playground and its various tabs. It executes first, before the request is sent to the router. Use pre-flight scripts to set headers or perform authentication workflows. These scripts are enabled by default. -- **Operation Scripts**: These scripts run either before or after executing an operation and are scoped to a single tab in the playground. By default, they are disabled. - - **Pre-Operation Scripts**: Executed after the pre-flight script but before the request reaches the router, these scripts function similarly to pre-flight scripts but are applied on a per-operation basis. - - **Post-Operation Scripts**: These scripts run after the operation completes. Here, you can access the response body and perform any necessary validation steps. +* **Pre-Flight Scripts**: This script runs across all instances of the playground and its various tabs. It executes first, before the request is sent to the router. Use pre-flight scripts to set headers or perform authentication workflows. These scripts are enabled by default. + +* **Operation Scripts**: These scripts run either before or after executing an operation and are scoped to a single tab in the playground. By default, they are disabled. + + * **Pre-Operation Scripts**: Executed after the pre-flight script but before the request reaches the router, these scripts function similarly to pre-flight scripts but are applied on a per-operation basis. + + * **Post-Operation Scripts**: These scripts run after the operation completes. Here, you can access the response body and perform any necessary validation steps. ### Execution Lifecycle Below depicts the execution lifecycle with operation and scripts configured - ![](/images/studio/image-17.png) + ## Creating and running scripts @@ -26,45 +29,44 @@ Below depicts the execution lifecycle with operation and scripts configured You can create multiple scripts of each type and select the appropriate one as needed. All created scripts are accessible at the account level; however, scripts selected for use are scoped specifically to your device or browser. - Scripts are stored in plain text in the database, so avoid including any sensitive information directly in the script. For sensitive data, use environment variables instead, as these are scoped to your device or browser. + Scripts are stored in plain text in the database, so avoid including any sensitive information directly in the script. For sensitive data, use environment variables instead, as these are scoped to your device or browser. To configure scripts for your operations, follow these steps: - - - In the playground, locate the script editor in the bottom-left corner. Here, you can edit **Pre-Flight Scripts** and, under the **Operation Scripts** tab (next to **Variables** and **Headers**), configure operation scripts for the active tab. - - - Click on the**edit icon** to modify the script. A modal will open, with a **Create** button, allowing you to create a new script within your organization. - - - Input your script code in the editor. To test it, run the script directly in the console. You can also manage environment variables using the **Environment Variables** editor, which is formatted in JSON. - - - Click **Use Script** to set it as the script to be used. - - - Once the modal closes, ensure that the checkbox next to the script is ticked to enable it. - - - With the script configured and enabled, proceed to run your operation. - + + In the playground, locate the script editor in the bottom-left corner. Here, you can edit **Pre-Flight Scripts** and, under the **Operation Scripts** tab (next to **Variables** and **Headers**), configure operation scripts for the active tab. + + + Click on the** edit icon** to modify the script. A modal will open, with a **Create** button, allowing you to create a new script within your organization. + + + Input your script code in the editor. To test it, run the script directly in the console. You can also manage environment variables using the **Environment Variables** editor, which is formatted in JSON. + + + Click **Use Script** to set it as the script to be used. + + + Once the modal closes, ensure that the checkbox next to the script is ticked to enable it. + + + With the script configured and enabled, proceed to run your operation. + - ## API Reference -| 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. | +|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.| ## Environment Variables @@ -75,7 +77,7 @@ Environment variables are local key-value pairs stored as JSON within your brows In the playground's **Headers** tab, you can reference an environment variable by using the syntax `{{key}}`. The playground will replace `{{key}}` with the corresponding value from the environment variables before executing your operation. - ![](/images/studio/image-18.png) + ## Examples @@ -153,6 +155,7 @@ if (responseBody.data && responseBody.data.user) { Scripts support the use of CryptoJS, which provides convenient cryptographic methods to enhance your scripts securely. + ```bash const encryptedToken = playground.env.get('refreshToken'); // Encoded refresh token const secretKey = playground.env.get('encryptionKey'); @@ -164,4 +167,4 @@ const tokenData = JSON.parse(decodedToken); const tokenExpiry = tokenData.exp * 1000; console.log(tokenExpiry) -``` \ No newline at end of file +``` From aa40c1526c764886440d188fae0c1933a17f7bf8 Mon Sep 17 00:00:00 2001 From: Akshay Garg <145957134+akshaygarg576@users.noreply.github.com> Date: Mon, 12 May 2025 11:14:19 +0530 Subject: [PATCH 09/10] fix: revert unnecessary changes --- docs/studio/playground/custom-scripts.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/studio/playground/custom-scripts.mdx b/docs/studio/playground/custom-scripts.mdx index d179b60..a0e10d6 100644 --- a/docs/studio/playground/custom-scripts.mdx +++ b/docs/studio/playground/custom-scripts.mdx @@ -168,3 +168,4 @@ const tokenData = JSON.parse(decodedToken); const tokenExpiry = tokenData.exp * 1000; console.log(tokenExpiry) ``` + From 5b2b28ca06f90850ad30d8ec819c8c7a9f6a3ec9 Mon Sep 17 00:00:00 2001 From: Akshay Garg <145957134+akshaygarg576@users.noreply.github.com> Date: Mon, 12 May 2025 12:42:52 +0530 Subject: [PATCH 10/10] Fix: typo --- docs/studio/playground/shared-playground-state.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/studio/playground/shared-playground-state.mdx b/docs/studio/playground/shared-playground-state.mdx index 263473a..46a1397 100644 --- a/docs/studio/playground/shared-playground-state.mdx +++ b/docs/studio/playground/shared-playground-state.mdx @@ -37,7 +37,7 @@ Here's what you can share: - Available options will appear in top section - Unavailable options (if no content available) will appear in the bottom section - + @@ -69,4 +69,4 @@ If you choose to include headers, they are compressed and encoded as part of the - Share reproducible bugs with your team - Collaborate on queries with full context - Link to example queries in internal docs -- Speed up onboarding of new developers with pre-filled queries \ No newline at end of file +- Speed up onboarding of new developers with pre-filled queries