This video is available to students only

Require manual approval before displaying comments

Right now, all the comments are public instantly. However, we may want to review the comments before showing them to other users. This is what we'll cover in this lesson.

Right now, all the comments are public. When a user adds a comment, other people can see it instantly (when they open a particular page). However, we may not want to do this and instead be able to review the comments before showing them to other users. And that's what we're going to do in this lesson. We'll add a possibility to mark comments as hidden by default and only show them publically after manual approval.

As the first step, we need to store the information — whether a comment is visible or not — somewhere. For that, we'll go to the Hasura Console and modify the comments table a bit.

We'll add a new column called hidden with Boolean type and default valuetrue.

We also need to update permissions, as we don't want client applications to fetch hidden comments. We'll go to the permissions tab and click on select permissions for role anonymous. In the Row Select Permissions, we'll choose with custom check. Inside, we'll set the configuration tohidden is equal to false so that the anonymous role has access only to the public, accepted comments.

We also need to provide access to the hidden column. We can do this by toggling it in the Column select permissions section:

Start a new discussion. All notification go to the author.