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 查询以获取所需数据。
query getMyTodos {todos(where: { is_public: { _eq: false} }, order_by: { created_at: desc }) {idtitlecreated_atis_completed}}
在 GraphiQL 中针对应用程序数据库尝试此查询,以查看响应是什么样的。
注:您需要在查询前传递Authorization: Bearer <token>
标头,以获取结果。在通过Auth0登录后,该令牌会在用户界面中自动填充。
该查询是实际的graphql查询,我们将在我们的React应用中使用,因此对其进行测试是为了确保它能按预期运行。
现在让我们将这个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

