11static class ArgumentReader
22{
3- public static bool TryReadWhere ( Func < Type , string , object ? > getArgument , out IEnumerable < WhereExpression > expression )
3+ public static bool TryReadWhere ( IResolveFieldContext context , out IEnumerable < WhereExpression > expression )
44 {
5- expression = getArgument . ReadList < WhereExpression > ( "where" ) ;
5+ expression = ReadList < WhereExpression > ( context , "where" ) ;
66
77 return expression . Any ( ) ;
88 }
99
10- public static IEnumerable < OrderBy > ReadOrderBy ( Func < Type , string , object ? > getArgument ) => getArgument . ReadList < OrderBy > ( "orderBy" ) ;
10+ public static IEnumerable < OrderBy > ReadOrderBy ( IResolveFieldContext context ) =>
11+ ReadList < OrderBy > ( context , "orderBy" ) ;
1112
12- public static bool TryReadIds ( Func < Type , string , object ? > getArgument , [ NotNullWhen ( true ) ] out string [ ] ? result )
13+ public static bool TryReadIds ( IResolveFieldContext context , [ NotNullWhen ( true ) ] out string [ ] ? result )
1314 {
1415 string ArgumentToExpression ( object argument )
1516 {
@@ -22,8 +23,8 @@ string ArgumentToExpression(object argument)
2223 } ;
2324 }
2425
25- var idsArgument = getArgument ( typeof ( object ) , "ids" ) ;
26- var idArgument = getArgument ( typeof ( object ) , "id" ) ;
26+ var idsArgument = context . GetArgument ( typeof ( object ) , "ids" ) ;
27+ var idArgument = context . GetArgument ( typeof ( object ) , "id" ) ;
2728 if ( idsArgument is null && idArgument is null )
2829 {
2930 result = null ;
@@ -51,9 +52,9 @@ string ArgumentToExpression(object argument)
5152 return true ;
5253 }
5354
54- public static bool TryReadSkip ( Func < Type , string , object ? > getArgument , out int skip )
55+ public static bool TryReadSkip ( IResolveFieldContext context , out int skip )
5556 {
56- var result = getArgument . TryReadInt ( "skip" , out skip ) ;
57+ var result = TryReadInt ( "skip" , context , out skip ) ;
5758 if ( result )
5859 {
5960 if ( skip < 0 )
@@ -64,9 +65,9 @@ public static bool TryReadSkip(Func<Type, string, object?> getArgument, out int
6465 return result ;
6566 }
6667
67- public static bool TryReadTake ( Func < Type , string , object ? > getArgument , out int take )
68+ public static bool TryReadTake ( IResolveFieldContext context , out int take )
6869 {
69- var result = getArgument . TryReadInt ( "take" , out take ) ;
70+ var result = TryReadInt ( "take" , context , out take ) ;
7071 if ( result )
7172 {
7273 if ( take < 0 )
@@ -77,9 +78,9 @@ public static bool TryReadTake(Func<Type, string, object?> getArgument, out int
7778 return result ;
7879 }
7980
80- static IEnumerable < T > ReadList < T > ( this Func < Type , string , object ? > getArgument , string name )
81+ static IEnumerable < T > ReadList < T > ( IResolveFieldContext context , string name )
8182 {
82- var argument = getArgument ( typeof ( T [ ] ) , name ) ;
83+ var argument = context . GetArgument ( typeof ( T [ ] ) , name ) ;
8384 if ( argument is null )
8485 {
8586 return Enumerable . Empty < T > ( ) ;
@@ -88,9 +89,9 @@ static IEnumerable<T> ReadList<T>(this Func<Type, string, object?> getArgument,
8889 return ( T [ ] ) argument ;
8990 }
9091
91- static bool TryReadInt ( this Func < Type , string , object ? > getArgument , string name , out int value )
92+ static bool TryReadInt ( string name , IResolveFieldContext context , out int value )
9293 {
93- var argument = getArgument ( typeof ( int ) , name ) ;
94+ var argument = context . GetArgument ( typeof ( int ) , name ) ;
9495 if ( argument is null )
9596 {
9697 value = 0 ;
0 commit comments