This course is no longer maintained and may be out-of-date. While it remains available for reference, its content may not reflect the latest updates, best practices, or supported features.
更新待办事项 - 变更
在本教程的这一部分中,您将学习如何使用 GraphQL 变更将现有的待办事项标记为已完成。
让我们定义一个 graphql 查询,以对待办事项进行变更。
mutation toggleTodo ($id: Int!, $isCompleted: Boolean!) {update_todos(where: {id: {_eq: $id}}, _set: {is_completed: $isCompleted}) {affected_rows}}
你还需要传入变量的值。
在 GraphiQL 中针对应用程序数据库尝试此变更,以查看响应是什么样的。
现在让我们将这个 graphql 变更集成到我们的 React 应用程序中。
Did you find this page helpful?
Start with GraphQL on Hasura for Free
Build apps and APIs 10x faster
Built-in authorization and caching
8x more performant than hand-rolled APIs

