@@ -695,14 +695,14 @@ The two keywords `true` and `false` represent the two boolean values.
695
695
696
696
StringValue ::
697
697
- ` " ` StringCharacter* ` " `
698
- - ` """ ` MultiLineStringCharacter * ` """ `
698
+ - ` """ ` BlockStringCharacter * ` """ `
699
699
700
700
StringCharacter ::
701
701
- SourceCharacter but not ` " ` or \ or LineTerminator
702
702
- \u EscapedUnicode
703
703
- \ EscapedCharacter
704
704
705
- MultiLineStringCharacter ::
705
+ BlockStringCharacter ::
706
706
- SourceCharacter but not ` """ ` or ` \""" `
707
707
- ` \""" `
708
708
@@ -715,37 +715,52 @@ Strings are sequences of characters wrapped in double-quotes (`"`). (ex.
715
715
significant within a string value.
716
716
717
717
Note: Unicode characters are allowed within String value literals, however
718
- GraphQL source must not contain some ASCII control characters so escape
718
+ {SourceCharacter} must not contain some ASCII control characters so escape
719
719
sequences must be used to represent these characters.
720
720
721
- ** Multi-line Strings**
721
+ ** Block Strings**
722
722
723
- Multi-line strings are sequences of characters wrapped in triple-quotes (` """ ` ).
724
- White space, line terminators, and quote and backslash characters may all be
725
- used unescaped, enabling freeform text. Characters must all be valid
726
- {SourceCharacter} to ensure printable source text. If non-printable ASCII
727
- characters need to be used, escape sequences must be used within standard
728
- double-quote strings.
723
+ Block strings are sequences of characters wrapped in triple-quotes (` """ ` ).
724
+ White space, line terminators, quote, and backslash characters may all be
725
+ used unescaped to enable verbatim text. Characters must all be valid
726
+ {SourceCharacter}.
729
727
730
- ** Semantics**
728
+ Since block strings represent freeform text often used in indented
729
+ positions, the string value semantics of a block string excludes uniform
730
+ indentation and blank initial and trailing lines via {BlockStringValue()}.
731
731
732
- StringValue :: ` " ` StringCharacter * ` " `
732
+ For example, the following operation containing a block string:
733
733
734
- * Return the Unicode character sequence of all {StringCharacter}
735
- Unicode character values (which may be empty).
734
+ ``` graphql
735
+ mutation {
736
+ sendEmail (message : " " "
737
+ Hello,
738
+ World!
736
739
737
- StringValue :: ` """ ` MultiLineStringCharacter* ` """ `
740
+ Yours,
741
+ GraphQL.
742
+ """ )
743
+ }
744
+ ```
738
745
739
- * Return the Unicode character sequence of all {MultiLineStringCharacter}
740
- Unicode character values (which may be empty).
746
+ Is identical to the standard quoted string:
741
747
742
- MultiLineStringCharacter :: SourceCharacter but not ` """ ` or ` \""" `
748
+ ``` graphql
749
+ mutation {
750
+ sendEmail (message : " Hello,\n World!\n\n Yours,\n GraphQL." )
751
+ }
752
+ ```
743
753
744
- * Return the character value of {SourceCharacter}.
754
+ Note: If non-printable ASCII characters are needed in a string value, a standard
755
+ quoted string with appropriate escape sequences must be used instead of a
756
+ block string.
745
757
746
- MultiLineStringCharacter :: ` \""" `
758
+ ** Semantics **
747
759
748
- * Return the character sequence ` """ ` .
760
+ StringValue :: ` " ` StringCharacter* ` " `
761
+
762
+ * Return the Unicode character sequence of all {StringCharacter}
763
+ Unicode character values (which may be an empty sequence).
749
764
750
765
StringCharacter :: SourceCharacter but not ` " ` or \ or LineTerminator
751
766
@@ -771,6 +786,50 @@ StringCharacter :: \ EscapedCharacter
771
786
| ` r ` | U+000D | carriage return |
772
787
| ` t ` | U+0009 | horizontal tab |
773
788
789
+ StringValue :: ` """ ` BlockStringCharacter* ` """ `
790
+
791
+ * Let {rawValue} be the Unicode character sequence of all
792
+ {BlockStringCharacter} Unicode character values (which may be an empty
793
+ sequence).
794
+ * Return the result of {BlockStringValue(rawValue)}.
795
+
796
+ BlockStringCharacter :: SourceCharacter but not ` """ ` or ` \""" `
797
+
798
+ * Return the character value of {SourceCharacter}.
799
+
800
+ BlockStringCharacter :: ` \""" `
801
+
802
+ * Return the character sequence ` """ ` .
803
+
804
+ BlockStringValue(rawValue):
805
+
806
+ * Let {lines} be the result of splitting {rawValue} by {LineTerminator}.
807
+ * Let {commonIndent} be {null}.
808
+ * For each {line} in {lines}:
809
+ * If {line} is the first item in {lines}, continue to the next line.
810
+ * Let {length} be the number of characters in {line}.
811
+ * Let {indent} be the number of leading consecutive {WhiteSpace} characters
812
+ in {line}.
813
+ * If {indent} is less than {length}:
814
+ * If {commonIndent} is {null} or {indent} is less than {commonIndent}:
815
+ * Let {commonIndent} be {indent}.
816
+ * If {commonIndent} is not {null}:
817
+ * For each {line} in {lines}:
818
+ * If {line} is the first item in {lines}, continue to the next line.
819
+ * Remove {commonIndent} characters from the beginning of {line}.
820
+ * While the first item {line} in {lines} contains only {WhiteSpace}:
821
+ * Remove the first item from {lines}.
822
+ * While the last item {line} in {lines} contains only {WhiteSpace}:
823
+ * Remove the last item from {lines}.
824
+ * Let {formatted} be the empty character sequence.
825
+ * For each {line} in {lines}:
826
+ * If {line} is the first item in {lines}:
827
+ * Append {formatted} with {line}.
828
+ * Otherwise:
829
+ * Append {formatted} with a line feed character (U+000A).
830
+ * Append {formatted} with {line}.
831
+ * Return {formatted}.
832
+
774
833
775
834
### Null Value
776
835
0 commit comments