Sign up for Hasura Newsletter
Loading...

todoの作成 - ミューテーション

ここでは、GraphQL Mutationを使って新しいtodoを作成する方法を学びます。

todoへの入力を実行するためのgraphql mutationを定義します。

mutation ($todo: String!, $isPublic: Boolean!) {
insert_todos(objects: {title: $todo, is_public: $isPublic}) {
affected_rows
returning {
id
title
created_at
is_completed
}
}
}

また、変数に値を渡す必要があります。

アプリケーションデータベースに対してGraphiQLを使ってこのミューテーションを 試して 、どのような応答が得られるか確認します。

このgraphql mutationをReactアプリに組み込みましょう。

Did you find this page helpful?
Start with GraphQL on Hasura for Free
  • ArrowBuild apps and APIs 10x faster
  • ArrowBuilt-in authorization and caching
  • Arrow8x more performant than hand-rolled APIs
Promo
footer illustration
Brand logo
© 2024 Hasura Inc. All rights reserved
Github
Titter
Discord
Facebook
Instagram
Youtube
Linkedin