feat: add copy cURL request option to playground copy button - #3141
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe playground now supports copying the active query or a generated cURL request. It adds header validation, environment substitution, feature-flag propagation, warning reporting, toolbar integration, and automated cURL tests. ChangesPlayground copy flow
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (4)
studio/src/components/playground/copy-operation.tsx (1)
16-16: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd an explicit component return type.
CopyOperationdoes not declare a return type. Add the applicable React JSX element return type.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@studio/src/components/playground/copy-operation.tsx` at line 16, Update the CopyOperation component declaration to explicitly return the applicable React JSX element type, while preserving its existing implementation and behavior.Source: Coding guidelines
studio/src/__tests__/playground-curl.test.ts (1)
17-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse one template literal for the expected command.
These lines concatenate template literals. Use one template literal for the complete expected command.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@studio/src/__tests__/playground-curl.test.ts` around lines 17 - 19, Update the expected command construction in the playground curl test to use a single template literal for the complete curl command instead of concatenating multiple template literals. Preserve the existing URL, headers, line breaks, and serialized query payload.Source: Coding guidelines
studio/src/lib/playground-headers.ts (1)
1-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd explicit return types to exported helpers.
validateHeadersandsubstituteHeadersFromEnvdo not declare return types. Add: voidand: Record<string, string>.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@studio/src/lib/playground-headers.ts` around lines 1 - 9, Add explicit return types to the exported helpers validateHeaders and substituteHeadersFromEnv: declare validateHeaders as returning void and substituteHeadersFromEnv as returning Record<string, string>, preserving their existing implementations.Source: Coding guidelines
studio/src/lib/playground-curl.ts (1)
26-81: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace
anyin parsed JSON values.
parseJsonObjectreturnsRecord<string, any>, which propagates unchecked values into variables, headers, and the request body. ReturnRecord<string, unknown>and narrow values where string conversion or body construction requires it.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@studio/src/lib/playground-curl.ts` around lines 26 - 81, Update parseJsonObject and related parsed JSON declarations to use Record<string, unknown> instead of any. Narrow unknown header values before string conversion, and ensure variables and request-body construction handle unknown values without unchecked typing while preserving the existing behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@studio/src/components/playground/copy-operation.tsx`:
- Around line 89-91: Add an accessible name to the icon-only Button containing
CopyIcon by setting an appropriate aria-label such as “Copy operation,” while
preserving its existing variant, size, and styling.
In `@studio/src/lib/playground-curl.ts`:
- Around line 64-77: Update the header-building flow in the cURL generation
logic to validate each header name after substituteHeadersFromEnv and merging
extraHeaders, matching graphiQLFetch validation. Exclude invalid header names
such as those containing spaces and emit a warning instead of throwing, while
preserving valid headers in the generated command.
In `@studio/src/lib/playground-headers.ts`:
- Around line 9-25: Update substituteHeadersFromEnv to parse playground:env
inside a try block, returning an empty environment when parsing fails or yields
null/non-object data. Replace any with unknown for parsed environment values,
and narrow each value before boolean, numeric, or string conversion while
preserving existing header substitution behavior.
---
Nitpick comments:
In `@studio/src/__tests__/playground-curl.test.ts`:
- Around line 17-19: Update the expected command construction in the playground
curl test to use a single template literal for the complete curl command instead
of concatenating multiple template literals. Preserve the existing URL, headers,
line breaks, and serialized query payload.
In `@studio/src/components/playground/copy-operation.tsx`:
- Line 16: Update the CopyOperation component declaration to explicitly return
the applicable React JSX element type, while preserving its existing
implementation and behavior.
In `@studio/src/lib/playground-curl.ts`:
- Around line 26-81: Update parseJsonObject and related parsed JSON declarations
to use Record<string, unknown> instead of any. Narrow unknown header values
before string conversion, and ensure variables and request-body construction
handle unknown values without unchecked typing while preserving the existing
behavior.
In `@studio/src/lib/playground-headers.ts`:
- Around line 1-9: Add explicit return types to the exported helpers
validateHeaders and substituteHeadersFromEnv: declare validateHeaders as
returning void and substituteHeadersFromEnv as returning Record<string, string>,
preserving their existing implementations.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 112099ff-2292-44f9-9238-f3ee1c46a992
📒 Files selected for processing (7)
studio/src/__tests__/playground-curl.test.tsstudio/src/components/playground/copy-operation.tsxstudio/src/components/playground/types.tsstudio/src/lib/playground-curl.tsstudio/src/lib/playground-headers.tsstudio/src/pages/[organizationSlug]/[namespace]/graph/[slug]/playground.tsxstudio/src/styles/playground.css
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (50.37%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #3141 +/- ##
==========================================
- Coverage 62.40% 1.87% -60.54%
==========================================
Files 263 330 +67
Lines 31048 46020 +14972
Branches 0 522 +522
==========================================
- Hits 19376 861 -18515
- Misses 10162 44844 +34682
+ Partials 1510 315 -1195
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Claude Code Review
Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
studio/src/lib/playground-curl.ts (2)
28-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename module constants to
UPPER_SNAKE_CASE.Rename
jsonText,jsonValueSchema,variablesSchema,headerValueSchema, andheadersSchema.As per coding guidelines, use
UPPER_SNAKE_CASEfor constants.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@studio/src/lib/playground-curl.ts` around lines 28 - 70, Rename the module-level constants jsonText, jsonValueSchema, variablesSchema, headerValueSchema, and headersSchema to UPPER_SNAKE_CASE names, updating all references including the recursive schema references and pipe calls while preserving their existing behavior.Source: Coding guidelines
28-94: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd explicit callback types.
The new transform, lazy, map, filter, and parameterized-test callbacks rely on inferred types.
studio/src/lib/playground-curl.ts#L28-L94: Add explicit parameter and return types to the new callbacks.studio/src/__tests__/playground-curl.test.ts#L98-L107: Add explicit types to_label,variables,warning, and the callback return type.As per coding guidelines, use explicit type annotations for function parameters and return types in TypeScript.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@studio/src/lib/playground-curl.ts` around lines 28 - 94, Add explicit parameter and return type annotations to the callbacks in studio/src/lib/playground-curl.ts lines 28-94, including the JSON transform, lazy schema, issue map, entry filter/iteration, and parseEditor-related callbacks, using types consistent with their schemas and inferred results. In studio/src/__tests__/playground-curl.test.ts lines 98-107, annotate _label, variables, warning, and the parameterized-test callback’s return type; do not change behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@studio/src/lib/playground-curl.ts`:
- Around line 28-70: Rename the module-level constants jsonText,
jsonValueSchema, variablesSchema, headerValueSchema, and headersSchema to
UPPER_SNAKE_CASE names, updating all references including the recursive schema
references and pipe calls while preserving their existing behavior.
- Around line 28-94: Add explicit parameter and return type annotations to the
callbacks in studio/src/lib/playground-curl.ts lines 28-94, including the JSON
transform, lazy schema, issue map, entry filter/iteration, and
parseEditor-related callbacks, using types consistent with their schemas and
inferred results. In studio/src/__tests__/playground-curl.test.ts lines 98-107,
annotate _label, variables, warning, and the parameterized-test callback’s
return type; do not change behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 585276c5-1897-4f7e-9771-7d31479c302c
📒 Files selected for processing (2)
studio/src/__tests__/playground-curl.test.tsstudio/src/lib/playground-curl.ts
Summary by CodeRabbit
New Features
Bug Fixes
Checklist