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.
todoの更新 - mutation
ここでは、GraphQL Mutationsを使って既存のtodoの完了をマークする方法を学びます。
todosでmutationを行うためのgraphql queryを定義します。
mutation toggleTodo ($id: Int!, $isCompleted: Boolean!) {update_todos(where: {id: {_eq: $id}}, _set: {is_completed: $isCompleted}) {affected_rows}}
また、variablesに値を渡す必要もあります。
アプリケーションデータベースに対してGraphiQLでこのmutationを試して、どのような応答が得られるかを確認します。
それでは、このgraphql mutationを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

