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

RFC: Block String #327

Merged
merged 2 commits into from
Nov 30, 2017
Merged

RFC: Block String #327

merged 2 commits into from
Nov 30, 2017

Conversation

leebyron
Copy link
Collaborator

@leebyron leebyron commented Jun 22, 2017

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:

"""This is a triple-quoted string
and it can contain multiple lines"""

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:

"""
In a block string \n and C:\ are unescaped.
"""

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.

@rmosolgo
Copy link

another pending RFC

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.

@leebyron
Copy link
Collaborator Author

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

@jexp
Copy link

jexp commented Sep 3, 2017

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.
@leebyron leebyron force-pushed the rfc-multilinestring branch 3 times, most recently from 4121d52 to 17db7e9 Compare November 30, 2017 04:44
@leebyron leebyron changed the title RFC: Multi-line String RFC: Block String Nov 30, 2017
@alexisgahon
Copy link

@leebyron I know this is already merged into the RFC but why no use of ` for description ?

fermads added a commit to fermads/GraphQL-SublimeText3 that referenced this pull request Dec 2, 2018
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.
dncrews pushed a commit to dncrews/GraphQL-SublimeText3 that referenced this pull request Jun 17, 2019
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.
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.

5 participants