question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when importing a YAML collection of a previously exported GraphQL request

See original GitHub issue

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:

Screenshot 2022-05-05 at 12 34 11

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. 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
  4. Export the collection
  5. Import the collection
  6. Look at the request inside the collection

Is there an existing issue for this?

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 “<newline>” 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

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

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kacharcommented, Dec 7, 2022

I’ve solved it by manually editing the yaml file and removed the request body for several requests until the yaml syntax was valid again (by prettier).

Looks like the export functionality is generating broken yaml, and the import is working fine.

0reactions
kbumsikcommented, Dec 7, 2022

Hi, this might be related to #4905, because I have both issues at the same time. Just cross posting comments.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Full Stack Error Handling with GraphQL and Apollo
Request Errors occur when the client is at fault. There are 3 phases to a GraphQL query and client-caused errors may occur in...
Read more >
Loading GraphQL Schemas from Different Sources
All found schema files can be merged into a complete schema. There is support for #import syntax (formerly known as graphql-import ). The...
Read more >
Get GraphQL whole schema query - Stack Overflow
You have to set field schemaPath to non-existing file (it will be auto created after downloading schema) and url to GraphQL remote server....
Read more >
How to Add File Upload to Your GraphQL API - Level Up Coding
If you get errors, uninstall previous versions of Babel CLI and Babel ... const { buildSchema } = require('graphql');export const schema = buildSchema(...
Read more >
Managing Metadata | Hasura GraphQL Docs
We call the Hasura Server configuration the Metadata. ... actions.graphql ... Metadata can be exported and imported in this JSON blob format using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found