-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
RFC: Block String #327
RFC: Block String #327
Conversation
feac5f8
to
90e98c1
Compare
Is it worth sharing this idea now? (Or, if it's already up, should we link to it?) Perhaps that would help us see more advantages of changing the language, or even avoid a case of the "X-Y Problem", where the real goal maybe accomplished apart from a language change. |
Thanks for the reminder, @rmosolgo - I have a PR to the reference impl here graphql/graphql-js#927 - the additional change is against the schema language, which itself is a partially complete RFC at the moment. I'm also particularly interested in your feedback in this change. There is a lot more discussion here: graphql/graphql-js#926 |
I'd love to see this supported, esp. for directives which might have longer string values, there multi-line capabilities are very helpful for readability. |
This RFC adds a new lexed token, the multi-line string, similar to that found in Python and Scala. A multi-line string starts and ends with a triple-quote: ``` """This is a triple-quoted string and it can contain multiple lines""" ``` Multi-line strings are useful for typing literal bodies of text where new lines should be interpretted literally. In fact, the only escape sequence used is `\"""` and `\` is otherwise allowed unescaped. This is beneficial when writing documentation within strings which may reference the back-slash often: ``` """ In a multi-line string \n and C:\\ are unescaped. """ ``` The primary value of multi-line strings are to write long-form input directly in query text, in tools like GraphiQL, and as a prerequisite to another pending RFC to allow docstring style documentation in the Schema Definition Language.
4121d52
to
17db7e9
Compare
17db7e9
to
979a1f2
Compare
@leebyron I know this is already merged into the RFC but why no use of |
As per [GraphqQL RFC](https://facebook.github.io/graphql/draft/#sec-String-Value) and its [implementation](graphql/graphql-spec#327), block strings are being a GraphQL supported feature for a while and are used for GraphiQL documentation. This PR add support for the triple quotes (""") block string.
As per [GraphqQL RFC](https://facebook.github.io/graphql/draft/#sec-String-Value) and its [implementation](graphql/graphql-spec#327), block strings are being a GraphQL supported feature for a while and are used for GraphiQL documentation. This PR add support for the triple quotes (""") block string.
This RFC adds a new form of
StringValue
, the multi-line string, similar to that found in Coffeescript, Python, and Scala.A block string starts and ends with a triple-quote:
Block strings are useful for typing literal bodies of text where new lines should be interpreted literally. In fact, the only escape sequence used is
\"""
and\
is otherwise allowed unescaped. This is beneficial when writing documentation within strings which may reference the back-slash often:The primary value of block strings are to write long-form input directly in query text, in tools like GraphiQL, and as a prerequisite to another pending RFC to allow docstring style documentation in the Schema Definition Language.