@@ -694,8 +694,8 @@ The two keywords `true` and `false` represent the two boolean values.
694
694
### String Value
695
695
696
696
StringValue ::
697
- - ` "" `
698
- - ` " ` StringCharacter+ ` " `
697
+ - ` " ` StringCharacter * ` " `
698
+ - ` """ ` BlockStringCharacter * ` "" "`
699
699
700
700
StringCharacter ::
701
701
- SourceCharacter but not ` " ` or \ or LineTerminator
@@ -706,24 +706,61 @@ EscapedUnicode :: /[0-9A-Fa-f]{4}/
706
706
707
707
EscapedCharacter :: one of ` " ` \ ` / ` b f n r t
708
708
709
+ BlockStringCharacter ::
710
+ - SourceCharacter but not ` """ ` or ` \""" `
711
+ - ` \""" `
712
+
709
713
Strings are sequences of characters wrapped in double-quotes (` " ` ). (ex.
710
714
` "Hello World" ` ). White space and other otherwise-ignored characters are
711
715
significant within a string value.
712
716
713
717
Note: Unicode characters are allowed within String value literals, however
714
- GraphQL source must not contain some ASCII control characters so escape
718
+ {SourceCharacter} must not contain some ASCII control characters so escape
715
719
sequences must be used to represent these characters.
716
720
717
- ** Semantics**
721
+ ** Block Strings**
722
+
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}.
727
+
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
+
732
+ For example, the following operation containing a block string:
733
+
734
+ ``` graphql
735
+ mutation {
736
+ sendEmail (message : " " "
737
+ Hello,
738
+ World!
739
+
740
+ Yours,
741
+ GraphQL.
742
+ """ )
743
+ }
744
+ ```
745
+
746
+ Is identical to the standard quoted string:
718
747
719
- StringValue :: ` "" `
748
+ ``` graphql
749
+ mutation {
750
+ sendEmail (message : " Hello,\n World!\n\n Yours,\n GraphQL." )
751
+ }
752
+ ```
720
753
721
- * Return an empty Unicode character sequence.
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.
722
757
723
- StringValue :: ` " ` StringCharacter+ ` " `
758
+ ** Semantics**
759
+
760
+ StringValue :: ` " ` StringCharacter* ` " `
724
761
725
762
* Return the Unicode character sequence of all {StringCharacter}
726
- Unicode character values.
763
+ Unicode character values (which may be an empty sequence) .
727
764
728
765
StringCharacter :: SourceCharacter but not ` " ` or \ or LineTerminator
729
766
@@ -749,6 +786,50 @@ StringCharacter :: \ EscapedCharacter
749
786
| ` r ` | U+000D | carriage return |
750
787
| ` t ` | U+0009 | horizontal tab |
751
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
+
752
833
753
834
### Null Value
754
835
0 commit comments