Sign up for Hasura Newsletter
Loading...

todoの取得 - query

最初に作成するgraphql queryでは、パーソナルtodoを取得します。ログインしたユーザーのデータベースからtodoデータを読み込む必要があります。必要なデータを取得するためのgraphql queryを定義します。

query getMyTodos {
todos(where: { is_public: { _eq: false} }, order_by: { created_at: desc }) {
id
title
created_at
is_completed
}
}

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

:queryして結果を取得する前に、 Authorization: Bearer <token> ヘッダーを渡す必要があります。Auto0経由でログインした後、トークンはUIにauto-fillされます。

このqueryは、Reactアプリで実際に使用するgraphql queryなので、期待通りに動作するか検証します。

このgraphql queryを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