Created
February 7, 2022 07:34
-
-
Save undefobj/0c21cf58f5b0c931a31f90a5bcff534a to your computer and use it in GitHub Desktop.
Filter deleted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is an example with a simple TODO schema: | |
```graphql | |
type Todo @model { | |
id: ID! | |
name: String! | |
description: String | |
} | |
``` | |
From there run `amplify push` and then `amplify console api` -> Select GraphQL and go to the AppSync console. | |
Find the `input ModelTodoFilterInput { ... }` and add `_deleted: ModelBooleanInput` to it so it looks similar to this: | |
```graphql | |
input ModelTodoFilterInput { | |
id: ModelIDInput | |
name: ModelStringInput | |
description: ModelStringInput | |
and: [ModelTodoFilterInput] | |
or: [ModelTodoFilterInput] | |
not: ModelTodoFilterInput | |
_deleted: ModelBooleanInput | |
} | |
``` | |
Now you should be able to run a GraphQL query and not return the items which have been soft deleted: | |
```graphql | |
query q { | |
listTodos (filter: { | |
_deleted : { | |
ne: true | |
} | |
}) { | |
items { | |
id | |
name | |
description | |
_deleted | |
} | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment