File tree Expand file tree Collapse file tree 7 files changed +164
-31
lines changed
Primitives/src/Primitives Expand file tree Collapse file tree 7 files changed +164
-31
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,14 @@ public void ValidateContext(IResolverContext context)
60
60
61
61
if ( RequirePagingBoundaries && first is null && last is null )
62
62
{
63
- throw ThrowHelper . PagingHandler_NoBoundariesSet (
63
+ if ( AllowBackwardPagination )
64
+ {
65
+ throw ThrowHelper . PagingHandler_NoBoundariesSet (
66
+ context . Selection . Field ,
67
+ context . Path ) ;
68
+ }
69
+
70
+ throw ThrowHelper . PagingHandler_FirstValueNotSet (
64
71
context . Selection . Field ,
65
72
context . Path ) ;
66
73
}
Original file line number Diff line number Diff line change 42
42
<data name =" ThrowHelper_PagingHandler_NoBoundariesSet" xml : space =" preserve" >
43
43
<value >You must provide a `first` or `last` value to properly paginate the `{0}`.</value >
44
44
</data >
45
+ <data name =" ThrowHelper_PagingHandler_FirstValueNotSet" xml : space =" preserve" >
46
+ <value >You must provide a `first` value to properly paginate the `{0}`.</value >
47
+ </data >
45
48
<data name =" Edge_Cursor_CursorAndResolverNull" xml : space =" preserve" >
46
49
<value >The edge state is invalid and has no cursor.</value >
47
50
</data >
Original file line number Diff line number Diff line change @@ -47,6 +47,19 @@ public static GraphQLException PagingHandler_NoBoundariesSet(
47
47
. SetFieldCoordinate ( field . Coordinate )
48
48
. Build ( ) ) ;
49
49
50
+ public static GraphQLException PagingHandler_FirstValueNotSet (
51
+ IOutputFieldDefinition field ,
52
+ Path path )
53
+ => new GraphQLException (
54
+ ErrorBuilder . New ( )
55
+ . SetMessage (
56
+ ThrowHelper_PagingHandler_FirstValueNotSet ,
57
+ field . Type . TypeName ( ) )
58
+ . SetCode ( ErrorCodes . Paging . FirstValueNotSet )
59
+ . SetPath ( path )
60
+ . SetFieldCoordinate ( field . Coordinate )
61
+ . Build ( ) ) ;
62
+
50
63
public static SchemaException PagingObjectFieldDescriptorExtensions_InvalidType ( )
51
64
=> new SchemaException (
52
65
SchemaErrorBuilder . New ( )
Original file line number Diff line number Diff line change @@ -115,6 +115,32 @@ await executor
115
115
. MatchSnapshotAsync ( ) ;
116
116
}
117
117
118
+ [ Fact ]
119
+ public async Task First_Value_Not_Set ( )
120
+ {
121
+ var executor =
122
+ await new ServiceCollection ( )
123
+ . AddGraphQL ( )
124
+ . AddQueryType < QueryType > ( )
125
+ . ModifyPagingOptions ( o =>
126
+ {
127
+ o . RequirePagingBoundaries = true ;
128
+ o . AllowBackwardPagination = false ;
129
+ } )
130
+ . Services
131
+ . BuildServiceProvider ( )
132
+ . GetRequestExecutorAsync ( ) ;
133
+
134
+ await executor
135
+ . ExecuteAsync ( @"
136
+ {
137
+ letters {
138
+ nodes
139
+ }
140
+ }" )
141
+ . MatchSnapshotAsync ( ) ;
142
+ }
143
+
118
144
[ Fact ]
119
145
public async Task Attribute_Simple_StringList_Default_Items ( )
120
146
{
Original file line number Diff line number Diff line change
1
+ {
2
+ " errors" : [
3
+ {
4
+ " message" : " You must provide a `first` value to properly paginate the `LettersConnection`." ,
5
+ " locations" : [
6
+ {
7
+ " line" : 3 ,
8
+ " column" : 21
9
+ }
10
+ ],
11
+ " path" : [
12
+ " letters"
13
+ ],
14
+ " extensions" : {
15
+ " code" : " HC0090" ,
16
+ " fieldCoordinate" : " Query.letters"
17
+ }
18
+ }
19
+ ],
20
+ " data" : {
21
+ " letters" : null
22
+ }
23
+ }
Original file line number Diff line number Diff line change @@ -354,6 +354,11 @@ public static class Paging
354
354
/// </summary>
355
355
public const string NoPagingBoundaries = "HC0052" ;
356
356
357
+ /// <summary>
358
+ /// You must provide a `first` value to properly paginate the connection.
359
+ /// </summary>
360
+ public const string FirstValueNotSet = "HC0090" ;
361
+
357
362
/// <summary>
358
363
/// The requested number of values per page must be at least 0.
359
364
/// </summary>
You can’t perform that action at this time.
0 commit comments