Volume: Final (Bonus) API in action

Volume: Final (Bonus) API in action

·

2 min read

Recall

After more exploration of the Hasura Dashboard, I find another way to accomplish the API without much headache, so I wish to try it again.

Before was thinking about how a user can sub the API without being registered (authenticated), The app should be authenticated or the user, but now no need for that for any of the two above, user authentication or app authentication.

On the dashboard page, I added an environmental variable that is called HASURA_GRAPHQL_UNAUTHORIZED_ROLE which can be set to any value, then move to the permission page and add permission for select, insert, update, and delete with the same of the environmental vars. The permission has no checks for all, which means any user can perform CRUD operation anonymously.

Now make a query, mutation, or subscription request to the API URL

https://hasura-todo-api.hasura.app/v1/graphql

Use any technology you want.

The API also supports REST API requests, (GET, POST, PUT and DELETE) To get Todos with REST API, hit the following URL with ` GET request.

https://hasura-todo-api.hasura.app/api/rest/get-todos

For POST request

https://hasura-todo-api.hasura.app/api/rest/add-todo

For PUT request

https://hasura-todo-api.hasura.app/api/rest/update-todo

for DELETE

https://hasura-todo-api.hasura.app/api/rest/delete-todo/:id

For more info, hit over to this README file.

Todo App

I Build a todo App to use the API Above, It is simple. In most circumstances, a full-stack Todo app must include both a frontend (interface) and a backend (server) to handle requests from the frontend, TODO CRUD operations. This application takes advantage of the API to execute all CRUD (query, mutations, and subscriptions) tasks. Visit here for live preview, click here for the repo.

That is it for now, till we meet in the next volume

As always, you can follow me on Twitter at @mxhdiqaim, Github @Mahdi to see my progress. DMs are always open for work, friendship, and relationships :)