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

fix(multiparser): no additional trailing newline for graphql in js #4616

Merged
merged 2 commits into from May 31, 2018

Conversation

@ikatyang
Copy link
Member

commented May 31, 2018

Fixes #4615

The root cause is the output doc from graphql printer does not match the desired input from stripTrailingHardline.

function stripTrailingHardline(doc) {
// HACK remove ending hardline, original PR: #1984
if (
doc.type === "concat" &&
doc.parts.length === 2 &&
doc.parts[1].type === "concat" &&
doc.parts[1].parts.length === 2 &&
doc.parts[1].parts[0].hard &&
doc.parts[1].parts[1].type === "break-parent"
) {
return doc.parts[0];
}
return doc;
}


Prettier pr-4616
Playground link

--parser babylon

Input:

graphql`
  fragment x on y {
    z
  }

  fragment a on b {
    c
  }
`;

Output:

graphql`
  fragment x on y {
    z
  }

  fragment a on b {
    c
  }
`;

@ikatyang ikatyang requested a review from vjeux May 31, 2018

@vjeux
vjeux approved these changes May 31, 2018
Copy link
Collaborator

left a comment

Thanks! Fortunately the workaround for this hack isn't too bad.

@ikatyang ikatyang merged commit b55997e into prettier:master May 31, 2018

6 of 7 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
ci/circleci: build_prod Your tests passed on CircleCI!
Details
ci/circleci: checkout_code Your tests passed on CircleCI!
Details
ci/circleci: test_prod_node4 Your tests passed on CircleCI!
Details
ci/circleci: test_prod_node9 Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
deploy/netlify Deploy preview ready!
Details

@ikatyang ikatyang deleted the ikatyang:fix/graphql-trailing-newline branch May 31, 2018

bors bot added a commit to mozilla/delivery-console that referenced this pull request Jun 1, 2018
Merge #175
175: Update dependency prettier to v1.13.4 r=rehandalal a=renovate[bot]

This Pull Request updates dependency [prettier](https://github.com/prettier/prettier) from `v1.13.3` to `v1.13.4`



<details>
<summary>Release Notes</summary>

### [`v1.13.4`](https://github.com/prettier/prettier/blob/master/CHANGELOG.md#&#8203;1134)
[Compare Source](prettier/prettier@1.13.3...1.13.4)
[link](prettier/prettier@1.13.3...1.13.4)

- Fix a regression when printing graphql-in-js ([#&#8203;4616](`prettier/prettier#4616))

---

</details>




---

This PR has been generated by [Renovate Bot](https://renovatebot.com).

Co-authored-by: Renovate Bot <bot@renovateapp.com>

@lock lock bot locked as resolved and limited conversation to collaborators Aug 29, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants
You can’t perform that action at this time.