@@ -116,24 +116,11 @@ public static IEnumerable<TSource> Filter<TSource, TParent>(
116
116
{
117
117
var orderByArg = context . GetArgument < IEnumerable < object > > ( "orderBy" ) ? . OfType < OrderBy > ( ) ;
118
118
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
- } ;
132
119
if ( context . Arguments . TryGetValue ( "filter" , out object filterArg ) && filterArg != null )
133
120
{
134
121
var rootFilter = ( ( IDictionary < string , object > ) filterArg ) . First ( ) ;
135
122
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 ) ;
137
124
138
125
source = source . Where ( x => filter . IsSatisfiedBy ( x ) ) ;
139
126
}
@@ -145,6 +132,7 @@ public static IEnumerable<TSource> Filter<TSource, TParent>(
145
132
146
133
object KeySelector ( TSource item )
147
134
{
135
+ var path = ( context . Path ?? new [ ] { "order" } ) . Concat ( new [ ] { fieldType . Name } ) ;
148
136
var value = fieldType . Resolver . Resolve ( new ResolveFieldContext
149
137
{
150
138
FieldName = order . Field ,
@@ -162,6 +150,7 @@ object KeySelector(TSource item)
162
150
CancellationToken = context . CancellationToken ,
163
151
Metrics = context . Metrics ,
164
152
Errors = context . Errors ,
153
+ Path = path
165
154
} ) ;
166
155
if ( value is Task < object > task )
167
156
{
@@ -188,31 +177,33 @@ object KeySelector(TSource item)
188
177
return source ;
189
178
}
190
179
191
- internal static IFilter ResolveFilter (
180
+ internal static IFilter ResolveFilter < TParentType > (
192
181
this IComplexGraphType filterType ,
193
182
KeyValuePair < string , object > value ,
194
- IObjectGraphType parentType ,
195
- ExecutionContext executionContext )
183
+ ResolveFieldContext < TParentType > context )
196
184
{
185
+ var path = ( context . Path ?? new [ ] { "filter" } ) . Concat ( new [ ] { value . Key } ) ;
197
186
var field = filterType . Fields . First ( x => x . Name == value . Key ) ;
187
+
198
188
return ( IFilter ) field . Resolver . Resolve (
199
189
new ResolveFieldContext
200
190
{
201
191
FieldName = field . Name ,
202
192
FieldAst = new Field ( null , new NameNode ( field . Name ) ) ,
203
193
FieldDefinition = field ,
204
- ParentType = parentType ,
194
+ ParentType = context . ParentType ,
205
195
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 ,
216
207
}
217
208
) ;
218
209
}
@@ -488,6 +479,7 @@ protected void AddFilterField(
488
479
{
489
480
object ResolveValue ( object source )
490
481
{
482
+ var path = ( context . Path ?? new [ ] { "filter" } ) . Concat ( new [ ] { fieldType . Name } ) ;
491
483
var value = fieldType . Resolver . Resolve (
492
484
new ResolveFieldContext
493
485
{
@@ -506,6 +498,7 @@ object ResolveValue(object source)
506
498
CancellationToken = context . CancellationToken ,
507
499
Metrics = context . Metrics ,
508
500
Errors = context . Errors ,
501
+ Path = path
509
502
}
510
503
) ;
511
504
@@ -533,28 +526,14 @@ protected void AddFilterField(
533
526
description ,
534
527
resolve : context =>
535
528
{
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
-
550
529
var value = ( IEnumerable < object > ) context . Source ;
551
530
var subFilters = new List < IFilter > ( ) ;
552
531
foreach ( var obj in value )
553
532
{
554
533
var dict = ( IDictionary < string , object > ) obj ;
555
534
foreach ( KeyValuePair < string , object > pair in dict )
556
535
{
557
- subFilters . Add ( this . ResolveFilter ( pair , ( IObjectGraphType ) parentType , executionContext ) ) ;
536
+ subFilters . Add ( this . ResolveFilter ( pair , context ) ) ;
558
537
}
559
538
}
560
539
return resolveFilter ( subFilters ) ;
0 commit comments