@@ -116,24 +116,11 @@ public static IEnumerable<TSource> Filter<TSource, TParent>(
116116 {
117117 var orderByArg = context . GetArgument < IEnumerable < object > > ( "orderBy" ) ? . OfType < OrderBy > ( ) ;
118118
119- var executionContext = new ExecutionContext
120- {
121- Schema = context . Schema ,
122- CancellationToken = context . CancellationToken ,
123- Document = context . Document ,
124- Errors = context . Errors ,
125- Fragments = context . Fragments ,
126- Metrics = context . Metrics ,
127- Operation = context . Operation ,
128- RootValue = context . RootValue ,
129- UserContext = context . UserContext ,
130- Variables = context . Variables
131- } ;
132119 if ( context . Arguments . TryGetValue ( "filter" , out object filterArg ) && filterArg != null )
133120 {
134121 var rootFilter = ( ( IDictionary < string , object > ) filterArg ) . First ( ) ;
135122 var filterType = ( IComplexGraphType ) context . FieldDefinition . Arguments . Find ( "filter" ) . ResolvedType ;
136- var filter = ResolveFilter ( filterType , rootFilter , context . ParentType , executionContext ) ;
123+ var filter = ResolveFilter ( filterType , rootFilter , context ) ;
137124
138125 source = source . Where ( x => filter . IsSatisfiedBy ( x ) ) ;
139126 }
@@ -145,6 +132,7 @@ public static IEnumerable<TSource> Filter<TSource, TParent>(
145132
146133 object KeySelector ( TSource item )
147134 {
135+ var path = ( context . Path ?? new [ ] { "order" } ) . Concat ( new [ ] { fieldType . Name } ) ;
148136 var value = fieldType . Resolver . Resolve ( new ResolveFieldContext
149137 {
150138 FieldName = order . Field ,
@@ -162,6 +150,7 @@ object KeySelector(TSource item)
162150 CancellationToken = context . CancellationToken ,
163151 Metrics = context . Metrics ,
164152 Errors = context . Errors ,
153+ Path = path
165154 } ) ;
166155 if ( value is Task < object > task )
167156 {
@@ -188,31 +177,33 @@ object KeySelector(TSource item)
188177 return source ;
189178 }
190179
191- internal static IFilter ResolveFilter (
180+ internal static IFilter ResolveFilter < TParentType > (
192181 this IComplexGraphType filterType ,
193182 KeyValuePair < string , object > value ,
194- IObjectGraphType parentType ,
195- ExecutionContext executionContext )
183+ ResolveFieldContext < TParentType > context )
196184 {
185+ var path = ( context . Path ?? new [ ] { "filter" } ) . Concat ( new [ ] { value . Key } ) ;
197186 var field = filterType . Fields . First ( x => x . Name == value . Key ) ;
187+
198188 return ( IFilter ) field . Resolver . Resolve (
199189 new ResolveFieldContext
200190 {
201191 FieldName = field . Name ,
202192 FieldAst = new Field ( null , new NameNode ( field . Name ) ) ,
203193 FieldDefinition = field ,
204- ParentType = parentType ,
194+ ParentType = context . ParentType ,
205195 Source = value . Value ,
206- Schema = executionContext . Schema ,
207- Document = executionContext . Document ,
208- Fragments = executionContext . Fragments ,
209- RootValue = executionContext . RootValue ,
210- UserContext = executionContext . UserContext ,
211- Operation = executionContext . Operation ,
212- Variables = executionContext . Variables ,
213- CancellationToken = executionContext . CancellationToken ,
214- Metrics = executionContext . Metrics ,
215- Errors = executionContext . Errors ,
196+ Schema = context . Schema ,
197+ Document = context . Document ,
198+ Fragments = context . Fragments ,
199+ RootValue = context . RootValue ,
200+ UserContext = context . UserContext ,
201+ Operation = context . Operation ,
202+ Variables = context . Variables ,
203+ CancellationToken = context . CancellationToken ,
204+ Metrics = context . Metrics ,
205+ Errors = context . Errors ,
206+ Path = path ,
216207 }
217208 ) ;
218209 }
@@ -488,6 +479,7 @@ protected void AddFilterField(
488479 {
489480 object ResolveValue ( object source )
490481 {
482+ var path = ( context . Path ?? new [ ] { "filter" } ) . Concat ( new [ ] { fieldType . Name } ) ;
491483 var value = fieldType . Resolver . Resolve (
492484 new ResolveFieldContext
493485 {
@@ -506,6 +498,7 @@ object ResolveValue(object source)
506498 CancellationToken = context . CancellationToken ,
507499 Metrics = context . Metrics ,
508500 Errors = context . Errors ,
501+ Path = path
509502 }
510503 ) ;
511504
@@ -533,28 +526,14 @@ protected void AddFilterField(
533526 description ,
534527 resolve : context =>
535528 {
536- var executionContext = new ExecutionContext
537- {
538- Schema = context . Schema ,
539- CancellationToken = context . CancellationToken ,
540- Document = context . Document ,
541- Errors = context . Errors ,
542- Fragments = context . Fragments ,
543- Metrics = context . Metrics ,
544- Operation = context . Operation ,
545- RootValue = context . RootValue ,
546- UserContext = context . UserContext ,
547- Variables = context . Variables
548- } ;
549-
550529 var value = ( IEnumerable < object > ) context . Source ;
551530 var subFilters = new List < IFilter > ( ) ;
552531 foreach ( var obj in value )
553532 {
554533 var dict = ( IDictionary < string , object > ) obj ;
555534 foreach ( KeyValuePair < string , object > pair in dict )
556535 {
557- subFilters . Add ( this . ResolveFilter ( pair , ( IObjectGraphType ) parentType , executionContext ) ) ;
536+ subFilters . Add ( this . ResolveFilter ( pair , context ) ) ;
558537 }
559538 }
560539 return resolveFilter ( subFilters ) ;
0 commit comments