-
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
Make print() break arguments over multiple lines #2797
Make print() break arguments over multiple lines #2797
Conversation
@draperunner Thanks for PR 👍 |
Let's first solve arguments and latter move to other areas in separate PRs. |
Okay, I've tested how Prettier handles arguments. See examples below.
So, what is your thoughts going forward with this? The existing printer in this projects has no awareness of line length, which is important to Prettier. Implementing it would be like reimplementing Prettier. Maybe the graphql part of Prettier could be a dependency of
|
@draperunner Prettier is an unnecessary big dependency for projects that only work with GraphQL. If you want to work on this please focus this PR on arguments, and create separate PRs for object fields. |
Proper logic for this is to be implemented, therefore are the tests failing now
Prettier does not use trailing commas if args go over multiple lines. The 'prints kitchen sink' test is updated to reflect desired behavior for multiline arguments, but where objects don't get prettified.
MAX_LINE_LENGTH is a hard-coded constant set to 80 chars for now.
@IvanGoncharov I have now added a couple of tests. I have added the I've updated the Another thing I noticed is that Prettier does not use trailing commas when arguments are on multiple lines, so I have removed that to match Prettier's behavior. |
…ription * master: (211 commits) Update deps (graphql#2844) resources: use named groups in RegExp (graphql#2840) TS: exclude integration tests from root tsconfig.json (graphql#2838) Flow: remove support for measuring Flow coverage (graphql#2837) CI: test on node 15 (graphql#2836) Update deps (graphql#2835) build: add support for experimental releases (graphql#2831) 15.4.0 Update deps (graphql#2827) Update deps (graphql#2825) integrationTests: add Flow test (graphql#2819) fix: ensure variance of types matches how values are used (graphql#2786) Cleanup '__fixtures__' leftovers (graphql#2818) Convert fixtures to be JS files (graphql#2816) Update deps (graphql#2815) benchmark: extract benchmarks into separate folder and run them on NPM package Update deps (graphql#2810) Update outdated documentation (graphql#2806) Make print() break arguments over multiple lines (graphql#2797) Added check for specific symbols in polyfills/symbols (graphql#2804) ...
Hi! We are using the
print
function to pretty-print our queries. It works quite well, but there is one thing that I think could be improved upon, and that's the rendering of arguments.This first image illustrates our problem. The main query takes a lot of parameters, and when formatting the query, all of these are put on the same line.
This next image illustrates the result of the changes made in this PR. All parameters are put on individual lines, and object values are also "prettified".
Questions