-
-
Notifications
You must be signed in to change notification settings - Fork 564
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
SchemaPrinter: Directives support 🤩 #996
Conversation
Codecov Report
@@ Coverage Diff @@
## master #996 +/- ##
============================================
+ Coverage 94.56% 94.61% +0.04%
Complexity 53 53
============================================
Files 120 120
Lines 9609 9711 +102
============================================
+ Hits 9087 9188 +101
- Misses 522 523 +1
Continue to review full report at Codecov.
|
Some of my thoughts from the first impression:
|
Nope, it is a free bonus 😁 But you are welcome to split it if you want.
The same problem as the multiline description - readability. This is impossible to read:
Parser strips whitespace while parsing so I guess that is not possible... But you are right, my second goal - generate GraphlQL that can be read and compared by humans even if the schema was generated by robots (= without formatting). Because from my point of view if readability doesn't matter there are no reasons to add LFs and paddings at all. Also, all original tests except two related to enum members are passed, the difference will be only in (this case is not covered by original tests): test(aaaaa: String, bbbb: String, cccc: String, dddddddddcccc: String, fsdfsdfsdfcccc: String, dsafsdcccc: String, sdfdfsdfcccc: String, sdfsdfsdcccc: String, sdfsdfsdfsfsdfcccc: String, sdfsfsdfdfsdfcccc: String): String; That will be converted into much more readable form: test(
aaaaa: String
bbbb: String
cccc: String
dddddddddcccc: String
fsdfsdfsdfcccc: String
dsafsdcccc: String
sdfdfsdfcccc: String
sdfsdfsdcccc: String
sdfsdfsdfsfsdfcccc: String
sdfsfsdfdfsdfcccc: String
): String; |
Readability can be an issue, the last example is a good one. There actually has been some work done on that topic in the reference implementation (graphql/graphql-js#2797). But in general, I would argue that the library shouldn't do any sophisticated formatting. Instead, tools like Prettier can be used to format a printed GraphQL if needed. Anyway, it's unrelated to directive printing. |
See graphql/graphql-js#3362 for an attempt to get support into the reference implementation first. Let's see what they say before continuing here. |
209305e
to
7c7e24d
Compare
PR is outdated and I have no time to update it. If someone need directives maybe you can try to use (much much more customizable) |
Features:
printDirectives
option;ARGUMENT_DEFINITION
,ENUM
,ENUM_VALUE
,FIELD_DEFINITION
,INPUT_FIELD_DEFINITION
,INPUT_OBJECT
,INTERFACE
,OBJECT
,SCALAR
,UNION
;[1,2,3]
) will be split into multiple lines 🆕Closes: #552, #875