From 84b05c05cd19eaa0c146a787741563b2c5284968 Mon Sep 17 00:00:00 2001 From: frederikhors <41120635+frederikhors@users.noreply.github.com> Date: Mon, 27 Jun 2022 13:57:11 +0200 Subject: [PATCH] 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> --- doc/md/tutorial-todo-gql-filter-input.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/md/tutorial-todo-gql-filter-input.md b/doc/md/tutorial-todo-gql-filter-input.md index 2cdf95ab4..38d46d931 100755 --- a/doc/md/tutorial-todo-gql-filter-input.md +++ b/doc/md/tutorial-todo-gql-filter-input.md @@ -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