File tree Expand file tree Collapse file tree 4 files changed +103
-0
lines changed Expand file tree Collapse file tree 4 files changed +103
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ public static unsafe string Format(Span<byte> buffer)
18
18
19
19
public static unsafe bool TryParse ( string cursor , out int index )
20
20
{
21
+ if ( string . IsNullOrWhiteSpace ( cursor ) )
22
+ {
23
+ index = - 1 ;
24
+ return false ;
25
+ }
26
+
21
27
fixed ( char * cPtr = cursor )
22
28
{
23
29
var count = _utf8 . GetByteCount ( cPtr , cursor . Length ) ;
Original file line number Diff line number Diff line change @@ -982,6 +982,30 @@ public async Task Invalid_After_Index_Cursor()
982
982
result . MatchSnapshot ( ) ;
983
983
}
984
984
985
+ [ Fact ]
986
+ public async Task Invalid_EmptyString_After_Index_Cursor ( )
987
+ {
988
+ var executor = await new ServiceCollection ( )
989
+ . AddGraphQL ( )
990
+ . AddQueryType < QueryType > ( )
991
+ . Services . BuildServiceProvider ( )
992
+ . GetRequestExecutorAsync ( ) ;
993
+
994
+ var result = await executor . ExecuteAsync (
995
+ """
996
+ {
997
+ letters(first: 2 after: "") {
998
+ edges {
999
+ cursor
1000
+ }
1001
+ }
1002
+ }
1003
+ """
1004
+ ) ;
1005
+
1006
+ result . MatchSnapshot ( ) ;
1007
+ }
1008
+
985
1009
[ Fact ]
986
1010
public async Task Invalid_Before_Index_Cursor ( )
987
1011
{
@@ -1007,6 +1031,31 @@ public async Task Invalid_Before_Index_Cursor()
1007
1031
result . MatchSnapshot ( ) ;
1008
1032
}
1009
1033
1034
+ [ Fact ]
1035
+ public async Task Invalid_EmptyString_Before_Index_Cursor ( )
1036
+ {
1037
+ var executor =
1038
+ await new ServiceCollection ( )
1039
+ . AddGraphQL ( )
1040
+ . AddQueryType < QueryType > ( )
1041
+ . Services
1042
+ . BuildServiceProvider ( )
1043
+ . GetRequestExecutorAsync ( ) ;
1044
+
1045
+ var result = await executor . ExecuteAsync (
1046
+ """
1047
+ {
1048
+ letters(first: 2 before: "") {
1049
+ edges {
1050
+ cursor
1051
+ }
1052
+ }
1053
+ }
1054
+ """ ) ;
1055
+
1056
+ result . MatchSnapshot ( ) ;
1057
+ }
1058
+
1010
1059
[ Fact ]
1011
1060
public async Task Simple_EnumerableValueType_ReturnsError ( )
1012
1061
{
Original file line number Diff line number Diff line change
1
+ {
2
+ " errors" : [
3
+ {
4
+ " message" : " The cursor specified in `after` has an invalid format." ,
5
+ " locations" : [
6
+ {
7
+ " line" : 2 ,
8
+ " column" : 3
9
+ }
10
+ ],
11
+ " path" : [
12
+ " letters"
13
+ ],
14
+ " extensions" : {
15
+ " argument" : " after" ,
16
+ " cursor" : " " ,
17
+ " code" : " HC0078"
18
+ }
19
+ }
20
+ ],
21
+ " data" : {
22
+ " letters" : null
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ " errors" : [
3
+ {
4
+ " message" : " The cursor specified in `before` has an invalid format." ,
5
+ " locations" : [
6
+ {
7
+ " line" : 2 ,
8
+ " column" : 3
9
+ }
10
+ ],
11
+ " path" : [
12
+ " letters"
13
+ ],
14
+ " extensions" : {
15
+ " argument" : " before" ,
16
+ " cursor" : " " ,
17
+ " code" : " HC0078"
18
+ }
19
+ }
20
+ ],
21
+ " data" : {
22
+ " letters" : null
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments