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)
6060
6161 if ( RequirePagingBoundaries && first is null && last is null )
6262 {
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 (
6471 context . Selection . Field ,
6572 context . Path ) ;
6673 }
Original file line number Diff line number Diff line change 4242 <data name =" ThrowHelper_PagingHandler_NoBoundariesSet" xml : space =" preserve" >
4343 <value >You must provide a `first` or `last` value to properly paginate the `{0}`.</value >
4444 </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 >
4548 <data name =" Edge_Cursor_CursorAndResolverNull" xml : space =" preserve" >
4649 <value >The edge state is invalid and has no cursor.</value >
4750 </data >
Original file line number Diff line number Diff line change @@ -47,6 +47,19 @@ public static GraphQLException PagingHandler_NoBoundariesSet(
4747 . SetFieldCoordinate ( field . Coordinate )
4848 . Build ( ) ) ;
4949
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+
5063 public static SchemaException PagingObjectFieldDescriptorExtensions_InvalidType ( )
5164 => new SchemaException (
5265 SchemaErrorBuilder . New ( )
Original file line number Diff line number Diff line change @@ -115,6 +115,32 @@ await executor
115115 . MatchSnapshotAsync ( ) ;
116116 }
117117
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+
118144 [ Fact ]
119145 public async Task Attribute_Simple_StringList_Default_Items ( )
120146 {
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
354354 /// </summary>
355355 public const string NoPagingBoundaries = "HC0052" ;
356356
357+ /// <summary>
358+ /// You must provide a `first` value to properly paginate the connection.
359+ /// </summary>
360+ public const string FirstValueNotSet = "HC0090" ;
361+
357362 /// <summary>
358363 /// The requested number of values per page must be at least 0.
359364 /// </summary>
You can’t perform that action at this time.
0 commit comments