Hasura Data API + Postman collection
Hasura Data API + Postman collection Part I
In this blog I would introduce you with Hasura Data API available for accessing database. I have used Postman tool to interact with Hasura Postgres database. To refer data modeling of my app, check out this link.
What is Postman?
Postman is a Google Chrome app for interacting with HTTP APIs. It presents you with a friendly GUI for constructing requests and reading responses.
You can download and install postman from this link.
How to use Postman to fire basic database queries on Hasura data API?
1) Sign-up Query:
The authentication API has been accessed using AUTH URL provided by Hasura along with signup request.
In body section, username and password is provided for new user to signup in JASON format. In response to this query, we get Authentication code that will be used in further database queries.
2) Select Query:
While firing any query through Postman(except signup/logout), Authentication code is necessary. This code helps to track session of a logged-in user. In Postman, under Header section, I have copied the authentication code which was received during sign-up request. Under Body section, raw along with JSON format is selected for query.
The screen-shot and Query and Result is as below.
3) Insert/Update Queries:
For firing DML/DDL queries we need to set up roles for user in Hasura portal. We have to update permission for user role. Hasura support three roles- admin, user and anonymous. Since we don't want to allow anonymous user to update our database, we will add suitable permissions for user role.
Following screen-shot shows simple query to add information in student table.
In this blog I would introduce you with Hasura Data API available for accessing database. I have used Postman tool to interact with Hasura Postgres database. To refer data modeling of my app, check out this link.
What is Postman?
Postman is a Google Chrome app for interacting with HTTP APIs. It presents you with a friendly GUI for constructing requests and reading responses.
You can download and install postman from this link.
How to use Postman to fire basic database queries on Hasura data API?
1) Sign-up Query:
The authentication API has been accessed using AUTH URL provided by Hasura along with signup request.
In body section, username and password is provided for new user to signup in JASON format. In response to this query, we get Authentication code that will be used in further database queries.
2) Select Query:
While firing any query through Postman(except signup/logout), Authentication code is necessary. This code helps to track session of a logged-in user. In Postman, under Header section, I have copied the authentication code which was received during sign-up request. Under Body section, raw along with JSON format is selected for query.
The screen-shot and Query and Result is as below.
3) Insert/Update Queries:
For firing DML/DDL queries we need to set up roles for user in Hasura portal. We have to update permission for user role. Hasura support three roles- admin, user and anonymous. Since we don't want to allow anonymous user to update our database, we will add suitable permissions for user role.
Following screen-shot shows simple query to add information in student table.
Comments
Post a Comment