[PR #5877] feat(gql): implement 'Import from cURL' for GraphQL requests #5387

Open
opened 2026-03-17 02:50:25 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5877
Author: @nylyy0325
Created: 2/13/2026
Status: 🔄 Open

Base: mainHead: main


📝 Commits (10+)

  • de30d3a feat(gql): implement 'Import from cURL' for GraphQL requests
  • 3c3de31 chore: remove local corepack shims
  • 001c09c chore: clean unintended PR artifacts
  • a464734 fix(gql): harden cURL import validation and UI behavior
  • 238e9ca fix(gql): improve cURL import robustness and data handling
  • e6cfb3b feat(gql): support headers and auth in cURL import
  • 5852a48 fix(gql): sync variable format and implement header merging for cURL import
  • 6d40026 refactor(gql): fix sticky header hardcoding and improve code consistency
  • bfcd8ce fix(gql): implement smart auth merge for cURL import to prevent data loss
  • ac91abb fix(gql): resolve lint warning and refine variable merge logic

📊 Changes

6 files changed (+318 additions, -1 deletions)

View changed files

📝 .gitignore (+3 -0)
📝 packages/hoppscotch-common/locales/cn.json (+2 -0)
📝 packages/hoppscotch-common/locales/en.json (+2 -0)
📝 packages/hoppscotch-common/src/components/graphql/RequestOptions.vue (+136 -1)
packages/hoppscotch-common/src/helpers/curl/gql_curl.spec.ts (+91 -0)
📝 packages/hoppscotch-common/src/helpers/curl/index.ts (+84 -0)

📄 Description

Title: feat(gql): support 'Import from cURL' for GraphQL requests

Summary:
This PR implements the cURL import feature for the GraphQL module.

Logic: Added parseCurlToGQL helper in hoppscotch-common to parse GraphQL JSON payloads.
UI: Added "Import from cURL" button in RequestOptions.vue.
Testing: Added gql_curl.spec.ts with 3 comprehensive test cases (All Passed).
Platforms: Verified on Windows/Web.
Closes:#1993, #4121
Bounty: Applying for the $50 bounty via Algora/Polar.


Summary by cubic

Adds “Import from cURL” for GraphQL so users can paste a cURL command to auto-fill endpoint, query, variables, headers, and auth. Tightens parsing and UI with strict detection, standardized error codes/i18n, safe defaults, smarter merging, consistent sticky header behavior, and ignores local Corepack shims.

  • New Features

    • Added parseCurlToGQL to extract url, query, variables, headers, auth; supports JSON bodies and raw text; errors on invalid format or non-string query.
    • Added “Import from cURL” button and modal (with Paste) in GraphQL RequestOptions; sticky import bar and tabs use design token offset.
    • Imports into the active tab, merges headers (skips content-type/accept), preserves existing auth unless the cURL includes one; exposes action handler (request.import-curl); tests cover JSON/raw bodies, malformed input, non-string query, headers, empty body, and variables in JSON.
  • Bug Fixes

    • Stricter validation and clear error handling: trims input, enforces “curl” prefix, standardizes cURL import error codes and i18n, and shows toasts for clipboard permission and invalid format.
    • Refined variable merging (JSON-safe with fallback) and kept auth intact unless a valid auth is provided; resolved a lint warning.

Written for commit a962916065. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5877 **Author:** [@nylyy0325](https://github.com/nylyy0325) **Created:** 2/13/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (10+) - [`de30d3a`](https://github.com/hoppscotch/hoppscotch/commit/de30d3af8ac512c1de0ab03763f100a9bcfd229d) feat(gql): implement 'Import from cURL' for GraphQL requests - [`3c3de31`](https://github.com/hoppscotch/hoppscotch/commit/3c3de31778e781aa9bcf1428ddb95a17de951a87) chore: remove local corepack shims - [`001c09c`](https://github.com/hoppscotch/hoppscotch/commit/001c09ca7100118042b5b97655827fef3bcf856b) chore: clean unintended PR artifacts - [`a464734`](https://github.com/hoppscotch/hoppscotch/commit/a464734652c1a014560f5c25b0a175e4e1cbefd6) fix(gql): harden cURL import validation and UI behavior - [`238e9ca`](https://github.com/hoppscotch/hoppscotch/commit/238e9ca695a16558c7caa56b32dc54365b3eac0e) fix(gql): improve cURL import robustness and data handling - [`e6cfb3b`](https://github.com/hoppscotch/hoppscotch/commit/e6cfb3ba37fe34f91fddd3cc98c3a93e1879f118) feat(gql): support headers and auth in cURL import - [`5852a48`](https://github.com/hoppscotch/hoppscotch/commit/5852a48bf223e9a501be622926326ddac0f362fe) fix(gql): sync variable format and implement header merging for cURL import - [`6d40026`](https://github.com/hoppscotch/hoppscotch/commit/6d4002626dd165fd345a606abc180aa97f30e636) refactor(gql): fix sticky header hardcoding and improve code consistency - [`bfcd8ce`](https://github.com/hoppscotch/hoppscotch/commit/bfcd8ce425dafacdbc115e31e059c58d62a365fe) fix(gql): implement smart auth merge for cURL import to prevent data loss - [`ac91abb`](https://github.com/hoppscotch/hoppscotch/commit/ac91abbd96d7e98bbf213d68ab8ef2f78a57c800) fix(gql): resolve lint warning and refine variable merge logic ### 📊 Changes **6 files changed** (+318 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+3 -0) 📝 `packages/hoppscotch-common/locales/cn.json` (+2 -0) 📝 `packages/hoppscotch-common/locales/en.json` (+2 -0) 📝 `packages/hoppscotch-common/src/components/graphql/RequestOptions.vue` (+136 -1) ➕ `packages/hoppscotch-common/src/helpers/curl/gql_curl.spec.ts` (+91 -0) 📝 `packages/hoppscotch-common/src/helpers/curl/index.ts` (+84 -0) </details> ### 📄 Description Title: feat(gql): support 'Import from cURL' for GraphQL requests Summary: This PR implements the cURL import feature for the GraphQL module. Logic: Added parseCurlToGQL helper in hoppscotch-common to parse GraphQL JSON payloads. UI: Added "Import from cURL" button in RequestOptions.vue. Testing: Added gql_curl.spec.ts with 3 comprehensive test cases (All Passed). Platforms: Verified on Windows/Web. Closes:#1993, #4121 Bounty: Applying for the $50 bounty via Algora/Polar. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds “Import from cURL” for GraphQL so users can paste a cURL command to auto-fill endpoint, query, variables, headers, and auth. Tightens parsing and UI with strict detection, standardized error codes/i18n, safe defaults, smarter merging, consistent sticky header behavior, and ignores local Corepack shims. - **New Features** - Added parseCurlToGQL to extract url, query, variables, headers, auth; supports JSON bodies and raw text; errors on invalid format or non-string query. - Added “Import from cURL” button and modal (with Paste) in GraphQL RequestOptions; sticky import bar and tabs use design token offset. - Imports into the active tab, merges headers (skips content-type/accept), preserves existing auth unless the cURL includes one; exposes action handler (request.import-curl); tests cover JSON/raw bodies, malformed input, non-string query, headers, empty body, and variables in JSON. - **Bug Fixes** - Stricter validation and clear error handling: trims input, enforces “curl” prefix, standardizes cURL import error codes and i18n, and shows toasts for clipboard permission and invalid format. - Refined variable merging (JSON-safe with fallback) and kept auth intact unless a valid auth is provided; resolved a lint warning. <sup>Written for commit a9629160652fee49c51099b5963f5a4c3ab913df. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5387
No description provided.