File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1182
1182
graphql_write_value(V , Options ).
1183
1183
1184
1184
1185
+ %! graphql_write_string(+Codes, +Options)// is det.
1186
+ %
1187
+ % Generates Codes, except that codes in Codes that are not allowed in
1188
+ % GraphQL string values are replaced by their escape sequences.
1185
1189
graphql_write_string ([] , _Options ) --> ! , [] .
1186
1190
graphql_write_string ([0 '\"|T ], Options ) -->
1187
1191
! ,
1191
1195
! ,
1192
1196
"\\\\" ,
1193
1197
graphql_write_string(T , Options ).
1198
+ graphql_write_string ([0 '\n |T ], Options ) -->
1199
+ ! ,
1200
+ "\\n" ,
1201
+ graphql_write_string(T , Options ).
1202
+ graphql_write_string ([0 '\r |T ], Options ) -->
1203
+ ! ,
1204
+ "\\r" ,
1205
+ graphql_write_string(T , Options ).
1194
1206
graphql_write_string ([H |T ], Options ) -->
1195
1207
[H ],
1196
1208
graphql_write_string(T , Options ).
Original file line number Diff line number Diff line change 54
54
graphql_read_document(codes(Codes ), Doc , [] ).
55
55
56
56
:- end_tests(graphql_round_trip ).
57
+
58
+
59
+ :- begin_tests(graphql_strings ).
60
+
61
+ test (escape_line_terminators ) :-
62
+ String = "Hello,\r\nnewline!" ,
63
+ graphql_document_to_string(
64
+ {| graphql(String ) ||
65
+ query { foo(bar : < String >
66
+ baz : "" "
67
+ Hello ,
68
+ multi -
69
+ lines !
70
+ "" "
71
+ ) } |},
72
+ Text ,
73
+ []
74
+ ),
75
+ string_lines(Text , [_ ]).
76
+
77
+ :- end_tests(graphql_strings ).
You can’t perform that action at this time.
0 commit comments