-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[umbrealla] use a true graphql prettifier (i.e., one designed for prettifying) #3242
Comments
type Book {
title: String, asdflnasdf: String, oqweroiyweroiyqwreoiqwer: String, nbiuiwrogiuwn: String, oineoinvoiunaouinaoiubhj: String, nasgoinaionabionafb: String, author: Author
}
# comment that should not be removed
type Author {
name: String
books: [Book]
} The above is an example of a formatter that would fix all of the above 3 bugs (and probably more). It can be found at https://mtp.tools/formatters/graphql-formatter but I don't see what editor it's uses (it makes a network request with your query 🤕) Interestingly, the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
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! |
Actually, Prettier should work to correctly solve the bugs mentioned. I might look into it later and try to make a PR if that's ok! EDIT: @dimitropoulos May I have any pointer on how/where to load the Prettier package? |
@ariasmn I would love to see a PR for this!! You'd add it to the Lemme know how I can help! |
@dimitropoulos I just submitted a PR for this. Sorry it took that long, I have been a bit busy. 😅 |
* Implemented Prettier for GraphQL formatting (#3242) * package bump and linting Co-authored-by: Dimitri Mitropoulos <[email protected]> Co-authored-by: James Gatz <[email protected]>
Describe the bug
There are a number of bugs that arise from our current approach to prettifying graphql:
To Reproduce
Pretify GraphQL
and observe the resultsExpected 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.
The text was updated successfully, but these errors were encountered: