Add file upload support to "Copy to cURL" functionality #2919
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #961
The "Copy to cURL" feature now generates working cURL commands for GraphQL mutations with file uploads. Previously, attempting to copy a mutation with file variables would show an error: "This is not currently available with file variables". This implementation follows the GraphQL multipart request spec to generate proper multipart/form-data cURL commands.
Changes
File Upload Support in cURL Generation
Extended the
generateCurlfunction to detect and handle file uploads by:operations: Query and variables with files set to nullmap: File index to variable path mapping@filenamesyntaxinput.document.file)Effect Update
Updated the
copyAsCurl$effect to pass resolved file information to the curl generator instead of showing an error.Example
Before:
After:
Features
Testing
Added comprehensive test coverage for:
Usage Note
Generated cURL commands use relative file paths (
@filename.ext). Users should either run the command from the directory containing the file or modify the path to an absolute path (@/path/to/filename.ext).Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
downloads.sentry-cdn.comIf you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fixes #1600
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.