@@ -23,26 +23,39 @@ string ArgumentToExpression(object argument)
2323 } ;
2424 }
2525
26- var idsArgument = context . GetArgument ( typeof ( object ) , "ids" ) ;
27- var idArgument = context . GetArgument ( typeof ( object ) , "id" ) ;
28- if ( idsArgument is null && idArgument is null )
26+ if ( context . Arguments == null )
27+ {
28+ result = null ;
29+ return false ;
30+ }
31+
32+ var containsIds = context . Arguments . TryGetValue ( "ids" , out var ids ) ;
33+ var containsId = context . Arguments . TryGetValue ( "id" , out var id ) ;
34+
35+ if ( ! containsIds && ! containsId )
36+ {
37+ result = null ;
38+ return false ;
39+ }
40+
41+ if ( ids . Source == ArgumentSource . FieldDefault && id . Source == ArgumentSource . FieldDefault )
2942 {
3043 result = null ;
3144 return false ;
3245 }
3346
3447 var expressions = new List < string > ( ) ;
3548
36- if ( idArgument is not null )
49+ if ( id . Source != ArgumentSource . FieldDefault )
3750 {
38- expressions . Add ( ArgumentToExpression ( idArgument ) ) ;
51+ expressions . Add ( ArgumentToExpression ( id . Value ! ) ) ;
3952 }
4053
41- if ( idsArgument is not null )
54+ if ( ids . Source != ArgumentSource . FieldDefault )
4255 {
43- if ( idsArgument is not IEnumerable < object > objCollection )
56+ if ( ids . Value is not IEnumerable < object > objCollection )
4457 {
45- throw new ( $ "TryReadIds got an 'ids' argument of type '{ idsArgument . GetType ( ) . FullName } ' which is not supported.") ;
58+ throw new ( $ "TryReadIds got an 'ids' argument of type '{ ids . Value ! . GetType ( ) . FullName } ' which is not supported.") ;
4659 }
4760
4861 expressions . AddRange ( objCollection . Select ( ArgumentToExpression ) ) ;
@@ -62,6 +75,7 @@ public static bool TryReadSkip(IResolveFieldContext context, out int skip)
6275 throw new ( "Skip cannot be less than 0." ) ;
6376 }
6477 }
78+
6579 return result ;
6680 }
6781
@@ -75,6 +89,7 @@ public static bool TryReadTake(IResolveFieldContext context, out int take)
7589 throw new ( "Take cannot be less than 0." ) ;
7690 }
7791 }
92+
7893 return result ;
7994 }
8095
@@ -98,7 +113,7 @@ static bool TryReadInt(string name, IResolveFieldContext context, out int value)
98113 return false ;
99114 }
100115
101- value = ( int ) argument ;
116+ value = ( int ) argument ;
102117 return true ;
103118 }
104119}
0 commit comments