diff --git a/website/src/docs/hotchocolate/fetching-data/filtering.md b/website/src/docs/hotchocolate/fetching-data/filtering.md index 022824e498b..f143bf582e6 100644 --- a/website/src/docs/hotchocolate/fetching-data/filtering.md +++ b/website/src/docs/hotchocolate/fetching-data/filtering.md @@ -186,6 +186,65 @@ public class Query } ``` +# AND / OR Filter + +There are two built in fields. + +- `AND`: Every condition has to be valid +- `OR` : At least one condition has to be valid + +Example: + +```graphql +query { + posts( + first: 5 + where: { OR: [{ title: {contains: "Doe" }}, { title: {contains: "John" }}] } + ) { + edges { + node { + id + title + } + } + } +} +``` + +**⚠️ OR does not work when you use it like this: ** + +```graphql +query { + posts( + first: 5 + where: { title: {contains: "John", OR: { title: {contains: "Doe" }}} } + ) { + edges { + node { + id + title + } + } + } +} +``` + +In this case the filters are applied like `title.Contains("John") && title.Contains("Doe")` rather than `title.Contains("John") || title.Contains("Doe")` how you probably intended it. + +## Removing AND / OR +If you do not want to expose `AND` and `OR` you can remove these fields with the descriptor API: + +```csharp +public class PersonFilterType + : FilterInputType +{ + protected override void Configure(IFilterInputTypeDescriptor descriptor) + { + descriptor.AllowAnd(false).AllowOr(false); + } +} +``` + # Filter Types ## Boolean Filter