-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Strips newlines when parsing GraphQL curl command #2888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strips newlines when parsing GraphQL curl command #2888
Conversation
9a9027e
to
139ddbc
Compare
Deploy preview for insomnia-storybook ready! Built with commit 636f86a |
export function newBodyGraphQL(rawBody: string): RequestBody { | ||
try { | ||
// Only strip the newlines if rawBody is a parsable JSON | ||
JSON.parse(rawBody); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no other way to do this, and JSON.parse
is the fastest way available, but it still is one of those things I want to mention - if anyone can think of a way to do this without JSON.parse
ing arbitrary inputs please say so. Sometimes in special cases there are ways around it, but from what I can tell this isn't one of those situations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is one of the special cases either so JSON.parse
seems like a reasonable approach to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionally tested and reviewed code: thanks for the contribution!
Updated branch with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks and works great! Thanks for the PR, and apologies for the delays 🙏🏽
Thanks a lot for your help @dimitropoulos and @develohpanda |
Co-authored-by: Eric Reynolds <reynolek@gmail.com>
This PR addresses a bug where GraphQL curl command copied from Chrome is not parsed correctly.
To reproduce the bug:
Expected: user is presented with a valid GraphQL query
Actual: user is presented with an invalid GraphQL (bunch of \n characters)
Video of the problem: here
Video of the new behaviour after this fix: here
Closes #1825