[WORKAROUND] Error when importing a YAML collection of a previously exported GraphQL request
- Dominant language
- TypeScript
- Stars
- 40k
- Forks
- 2.4k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 61
Description
### Expected Behavior
When importing a yaml file containing a collection there should be no error and the requests should contain the same body as the originally exported collection.
### Actual Behavior
On our "real" insomnia collection we see an error saying that the import failed with a stack trace in the below example:

We have also created a test collection to try to reproduce the problem. While we haven't been able to see exactly the same issue, we do see an issue where the collection appears to import correctly, but when looking at the only request in the collection the GraphQL body and query variable sections are blank.
### Reproduction Steps
1. Create a new collection
2. Create a new GraphQL POST request with the following body: [graphql body.txt](https://github.com/Kong/insomnia/files/8630819/graphql.body.txt). Note that tabs seem to be important here, hence why I've added as a file to make sure it formats correctly.
3. Add the following in the variables section: [variables.txt](https://github.com/Kong/insomnia/files/8630825/variables.txt)
4. Export the collection
5. Import the collection
6. Look at the request inside the collection
### Is there an existing issue for this?
- [X] I have searched the [issue tracker](https://www.github.com/Kong/insomnia/issues) for this problem.
### Additional Information
From what I can tell this appears to be a very specific problem with the formatting of the request. It only happens when the request body is being saved in double quotes, which is forced by the single quotes used inside the variables section.
It seems to be something about the way insomnia wraps the text onto a newline based on the body in a way that didn't previously happen. There are instances in the collection where we have a tab character split between two lines with the "\" breaker between them.
In the exported collection, the line starts with `\t` instead of `\\t` as you would expect (and it was previously). I have no idea why our "real" collection errors when the example one doesn't. But it seems likely that it has the same root cause, especially since I can see the same weird thing when looking directly at the yaml file.
Note that I'm on a mac, but other members of the team have replicated on windows.
Exported example collection for reference:
[insomnia.example.yaml.txt](https://github.com/Kong/insomnia/files/8630850/insomnia.example.yaml.txt)
### Insomnia Version
v2022.3.0
### What operating system are you using?
macOS
### Operating System Version
macOs Monterey 12.3.1
### Installation method
Downloaded from insomnia.net
### Last Known Working Insomnia version
v2022.2.1
Contributor guide
Research direction
Start by reproducing the import using the attached graphql.body.txt, variables.txt, and insomnia.example.yaml.txt files, then compare the exported YAML with the imported request. Trace the collection import/export path to the handling of quoted, tabbed GraphQL bodies and variables. Done means the collection imports without an error and preserves both the GraphQL body and query variables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100