Skip to content
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

Empty space before second comment #474

Closed
vreality64 opened this issue Feb 25, 2020 · 4 comments
Closed

Empty space before second comment #474

vreality64 opened this issue Feb 25, 2020 · 4 comments
Labels
bug Something isn't working waiting for release

Comments

@vreality64
Copy link

vreality64 commented Feb 25, 2020

Hello. I'm using merge-graphql-schemas which uses this schema merge. I checked the auto-generated SDL and found the following issues about comment symbol #.

Source

type Some {
  # comment
  #  - first line
  #  - second line
  field: Int
}

Merged - empty space after the second line

type Some {
  # comment
   #  - first line
   #  - second line
  field: Int
}

Empty space is look like bug. Is it intended?

export function printComment(comment: string): string {
return '\n# ' + comment.replace(/\n/g, '\n # ');
}

In the test code, it was removed using the stripWhitespaces utility function. Here are playground link

Also I have another question. Is there option for strip away # generation? I only want to keep not comment but description.

@ardatan ardatan added the bug Something isn't working label Feb 27, 2020
@ardatan
Copy link
Owner

ardatan commented Mar 11, 2020

We're working on a fix for indentation issue in #483. To have descriptions instead of comments, you can pass commentDescriptions: false to the options;

mergeTypes(types, { commentDescriptions: false });

@vreality64
Copy link
Author

vreality64 commented Mar 13, 2020

@ardatan

We're working on a fix for indentation issue in #483.

Glad to hear that. 👍

commentDescriptions: false to the options

I tested commentDescriptions options, however return is not same type. (playground)

with commentDescription

mergeTypes(types, { commentDescriptions: true })
// -> SDL string

without commentDescription

mergeTypes(types, { commentDescriptions: false })
// -> Document Node

The reason is below code. However I'm not sure why this happen. In my opinion, it should be same due to option name.

if (config && config.commentDescriptions) {
result = printWithComments(doc);
} else {
result = doc;
}

suggestion

if (config && config.commentDescriptions) { 
  result = printWithComments(doc); 
} else { 
  result = print(doc); 
}

ardatan added a commit that referenced this issue Mar 17, 2020
* Remove extra new line in descriptions #474

* Improve tests
@ardatan
Copy link
Owner

ardatan commented Mar 17, 2020

@vreality64 This is done on purpose, because comments are not the part of DocumentNode anymore so we need to return string.

@ardatan
Copy link
Owner

ardatan commented Mar 17, 2020

Available in v0.9.8 !!!

@ardatan ardatan closed this as completed Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for release
Projects
None yet
Development

No branches or pull requests

2 participants