hasura
Today in this article we are going to build a secure todo list using GraphQL API with Hasura. First you have to know about Hasura. It is nothing but a postgreSQL database that automatically gives you a real-time data.
今天,在本文中,我们将使用带有Hasura的GraphQL API构建安全的待办事项列表。 首先,您必须了解Hasura。 它只是一个可以自动为您提供实时数据的postgreSQL数据库。
Before getting into the topic first let see about steps to be followed for creating this app.
首先进入主题,先了解创建此应用程序要遵循的步骤。
- Build backend. 建立后端。
- Create a data tables. 创建一个数据表。
- Authentication. 身份验证。
- Authorization. 授权。
- Build frontend. 建立前端。
- Deployment. 部署。
Now let’s get deep into the topic.
现在让我们深入探讨该主题。
建立后端 (Build backend)
Go to Hasura and create an new account. Hasura will ask to connect your database. Choose “Try a free database with heroku”.
转到Hasura并创建一个新帐户。 Hasura将要求连接您的数据库。 选择“ 使用heroku尝试免费数据库 ”。
After finishing the setup with heroku new instance is created and it is running at the url like this.
用heroku完成设置后,将创建一个新实例,它在url这样运行。
https://<YOUR_HEROKU_PROJECT>.herokuapp.com
https:// <YOUR_HEROKU_PROJECT> .herokuapp.com
And then navigate to project and click launch console to open Hasura dashboard.
然后导航到项目并单击启动控制台以打开Hasura仪表板。
创建数据表 (Create data tables)
Navigate to data and create a new table with name todos with columns like this,
导航到数据并创建一个名称为todos的新表,其中包含如下所示的列,
id : Integer
id :整数
title : Text
标题 :文字
is_completed : Boolean
is_completed :布尔值
user_id : Text
user_id :文本
created_at : Timestamp
created_at :时间戳
Set the id column as unique and primary key.
将id列设置为唯一键和主键。