[umbrealla] use a true graphql prettifier (i.e., one designed for prettifying)
See original GitHub issueDescribe the bug There are a number of bugs that arise from our current approach to prettifying graphql:
- comments are destroyed https://github.com/Kong/insomnia/issues/1124
- indentation is not respected https://github.com/Kong/insomnia/issues/2301
- very long query parameters (which is not terribly uncommon) don’t wrap https://github.com/Kong/insomnia/issues/2600
- (and probably more that I haven’t yet found - let me know if so).
To Reproduce
- Create a GraphQL request
- click
Pretify GraphQL
and observe the results
Expected behavior The above issues have different solutions, but the over-arching concept is that the prettifying should work as one might naturally expect (and definitely without destroying information).
I think we should look at other tools and graphql clients to see how they approach this problem and go with the most widely adopted solution. I believe prettier may be an option, but the docs are down at the time of writing this issue.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
GraphQL schema basics
This article describes the fundamental building blocks of a schema and how to create one for your GraphQL server. The schema definition language....
Read more >GraphQL Formatter and GraphQL Beautifier free and easy to use
GraphQL Formatter Online helps to prettier your GraphQL queries data. It's a pretty simple and easy way to read GraphQL Data and Share...
Read more >GraphQL Code Libraries, Tools and Services
A powerful JavaScript GraphQL client, designed to work well with React, React Native, ... Real-Time with GraphQL for any GraphQL schema or transport....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ariasmn I would love to see a PR for this!! You’d add it to the
insomnia-app
package and run it using the prettier API (https://prettier.io/docs/en/api.html).Lemme know how I can help!
Hi!
I have (kinda) looked into it, and the problem with the comments comes from the Javascript GraphQL library AST, since it can’t parse comments. If they implement it, making a small library to correctly prettify the code should not be much of a problem, but modifying the parser is out of my league sadly.
My guess is that the one from mtp.tools is using a whole different GraphQL AST that parse comments correctly.
I hope that this information helps you!