mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
doc/md: add info about using WhereInput as predicates (#2691)
* Add info about using `WhereInput` in with `.Where()` * Update doc/md/predicates.md Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * Update tutorial-todo-gql-filter-input.md * Update predicates.md * Update predicates.md * Update tutorial-todo-gql-filter-input.md Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
This commit is contained in:
@@ -311,6 +311,19 @@ We can use this new filtering as any other predicate:
|
||||
}
|
||||
```
|
||||
|
||||
### Usage of filter inputs as predicates
|
||||
|
||||
The `Filter` option lets use the generated `WhereInput`s as regular repdicates on any type of query:
|
||||
|
||||
```go
|
||||
query := ent.Todo.Query()
|
||||
query, err := input.Filter(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return query.All(ctx)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Well done! As you can see, by changing a few lines of code our application now exposes a type-safe GraphQL filters
|
||||
|
||||
Reference in New Issue
Block a user