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

GraphQL: Support for multiline strings #1012

Merged

Conversation

dblessing
Copy link
Collaborator

@dblessing dblessing commented Oct 8, 2018

Fixes #992 and fixes #993

Adds support for multiline strings for GraphQL and markdown descriptions.

Markdown descriptions are in the GraphQL spec at https://facebook.github.io/graphql/draft/#sec-Descriptions

@dblessing dblessing force-pushed the fix_graphql_multiline_str_992 branch from 1e8ece6 to be24440 Compare October 8, 2018 20:51
@dblessing dblessing force-pushed the fix_graphql_multiline_str_992 branch from be24440 to d59a7a2 Compare October 8, 2018 20:52
@dblessing
Copy link
Collaborator Author

@langpavel What do you think of this? It adds support for regular multiline string values, plus markdown descriptions.

One note that differs from your example in #993. The first line is not made into a markdown header in this case. That's because the GraphQL lexer simply delegates the text to the Markdown lexer, which would only make the first line a header if it was preceded by some form of #.

Is this acceptable? If this is a surprise for GraphQL users we could potentially inject a preceding #. Although, that would be slightly unprecedented in Rouge, I think.

@langpavel
Copy link

@dblessing Hi, thank you for your effort!

I think that first line can be treated as you did, so it will not break reading so much.
<h1> is often too big and results may be horrible if you inject # implicitly.

It's perfectly fine to left first paragraph as is, you can see that other tooling like graphiql and prisma interprets first line as plain paragraph...

@dblessing
Copy link
Collaborator Author

@langpavel Perfect! I'll take this as-is, then.

If you're familiar with GraphQL and multiline strings, would you mind checking that my second example in the samples file is valid? From looking at the multiline spec, I believe it is but I have little real-world experience on GraphQL.

@langpavel
Copy link

langpavel commented Oct 8, 2018

If you're familiar with GraphQL and multiline strings, would you mind checking that my second example in the samples file is valid? From looking at the multiline spec, I believe it is but I have little real-world experience on GraphQL.

Yes, it is valid (only not recommended style)

@langpavel
Copy link

langpavel commented Oct 8, 2018

Only issue I can imagine is with de-indenting strategy in GraphQL parser tokenizer:

Copy link

@langpavel langpavel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good first step! 🎉

@langpavel
Copy link

Thank you @dblessing! I will be very satisfied if this lands soon! :-)

@dblessing
Copy link
Collaborator Author

Thanks @langpavel

@dblessing dblessing merged commit e957c74 into rouge-ruby:master Oct 9, 2018
@langpavel
Copy link

Can I kindly ask you when you plan new release? @dblessing @jneen 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GraphQL: Markdown descriptions GraphQL multiline strings
2 participants