You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-8Lines changed: 23 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -397,14 +397,29 @@ query TestQuery {
397
397
}
398
398
```
399
399
400
-
This filter is mapped by the middleware into the `ObjectListFilter` discriminated union, with cases such as `And`, `Or`, `Not`, `Equals`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan`, `LessThanOrEqual`, `In`, `StartsWith`, `EndsWith`, `Contains`, `OfTypes`, and `FilterField`.
401
-
402
-
- The cases `Equals`, `StartsWith`, `EndsWith`, and `Contains` accept a comparer parameter in the public discriminated union.
403
-
-`Equals` and `Contains` keep the non-generic `System.Collections.IComparer` because they also support non-string comparable values in the public discriminated union.
404
-
- When the filtered field is a string and you construct the DU cases directly, pass a `StringComparer` instance in that comparer slot. `StringComparer` is accepted there because it also implements `System.Collections.IComparer`. Use `StringComparer.Ordinal` for case-sensitive matching and `StringComparer.OrdinalIgnoreCase` for case-insensitive matching.
405
-
- The built-in case-sensitive operators (`===`, `=@@`, `@@=`, `@=@`) use the default comparer behavior.
406
-
-`Contains` is also used for collection membership checks, so the wrapped value type inside `FieldFilter<_>` stays `System.IComparable` instead of being limited to `string`.
407
-
- If you were previously constructing `Equals`, `StartsWith`, `EndsWith`, or `Contains` directly, update those call sites to provide the comparer argument explicitly.
400
+
This filter is mapped by the middleware inside an `ObjectListFilter` definition:
401
+
402
+
```fsharp
403
+
type FieldFilter<'Val> =
404
+
{ FieldName : string
405
+
Value : 'Val }
406
+
407
+
type ObjectListFilter =
408
+
| And of ObjectListFilter * ObjectListFilter
409
+
| Or of ObjectListFilter * ObjectListFilter
410
+
| Not of ObjectListFilter
411
+
| Equals of Filter : FieldFilter<System.IComparable> * Comparer : System.Collections.IComparer
412
+
| GreaterThan of FieldFilter<System.IComparable>
413
+
| GreaterThanOrEqual of FieldFilter<System.IComparable>
414
+
| LessThan of FieldFilter<System.IComparable>
415
+
| LessThanOrEqual of FieldFilter<System.IComparable>
416
+
| In of FieldFilter<obj list>
417
+
| StartsWith of Filter : FieldFilter<string> * Comparer : System.StringComparer
418
+
| EndsWith of Filter : FieldFilter<string> * Comparer : System.StringComparer
419
+
| Contains of Filter : FieldFilter<System.IComparable> * Comparer : System.Collections.IComparer
420
+
| OfTypes of System.Type list
421
+
| FilterField of FieldFilter<ObjectListFilter>
422
+
```
408
423
409
424
And the value recovered by the filter in the query is usable in the `ResolveFieldContext` of the resolve function of the field. To easily access it, you can use the extension method `Filter`, which returns an `ObjectListFilter voption` (it does not have a value if the object doesn't implement a list with the middleware generic definition, or if the user didn't provide a filter input).
0 commit comments