beerose / use-comments

React hook to effortlessly add a comment section to your website, and start the discussion on your content.
https://use-comments.netlify.app/
MIT License
171 stars 6 forks source link

Provide metadata version `'3'` #15

Open vahidtakro opened 3 years ago

vahidtakro commented 3 years ago

Hello, I want to test and use use-comments on heroku, but I am not able to import metadata, I get the following error: key "args" not found

Captkjure

vahidtakro commented 3 years ago

Okay I fixed this by exporting the provided metadata first, and integrated with the metadata provided in this package.

beerose commented 3 years ago

Ah yes, the metadata in this package (version 2) only works with Hasura's versions <= 1.3.x. I'll fix it and provide Hasura's metadata in version 3. Thanks for reporting! I'll reopen this issue to track this.

SaadBazaz commented 2 years ago

Facing the same issue. Would be great if this can be mentioned in the docs or the JSON can be uploaded.

note: Got it working using @vahidtakro 's suggestion.

SaadBazaz commented 2 years ago

My metadata.json file for Version 3:

{
   "resource_version":3,
   "metadata":{
      "version":3,
      "sources":[
         {
            "name":"default",
            "kind":"postgres",
            "tables":[
               {
                  "table":{
                     "schema":"public",
                     "name":"comments"
                  },
                  "insert_permissions":[
                     {
                        "role":"anonymous",
                        "permission":{
                           "check":{

                           },
                           "columns":[
                              "author",
                              "content",
                              "post_id"
                           ],
                           "backend_only":false
                        }
                     }
                  ],
                  "select_permissions":[
                     {
                        "role":"anonymous",
                        "permission":{
                           "columns":[
                              "author",
                              "content",
                              "created_at",
                              "hidden",
                              "id",
                              "post_id"
                           ],
                           "filter":{
                              "hidden":{
                                 "_ne":true
                              }
                           },
                           "allow_aggregations":true
                        }
                     }
                  ]
               }
            ],
            "configuration":{
               "connection_info":{
                  "use_prepared_statements":true,
                  "database_url":{
                     "from_env":"HASURA_GRAPHQL_DATABASE_URL"
                  },
                  "isolation_level":"read-committed",
                  "pool_settings":{
                     "connection_lifetime":600,
                     "retries":1,
                     "idle_timeout":180,
                     "max_connections":50
                  }
               }
            }
         }
      ]
   }
}
beerose commented 2 years ago

There were many significant changes to Hasura since I created this project. I think this is what we should cover in the docs:

  1. Suggest to use Hasura Cloud (there is a free tier and it's the easiest way to set up Hasura).

  2. Create a database via Hasura Console:

    Screenshot 2021-12-10 at 12 08 17

    Back when this issue was created, the new database URL was stored as a connection string in the metadata, which wasn't great for this project (we would need to tell user to additionally change the URL in the metadata). However, if you use Cloud and create a DB via Heroku, it's stored as PG_DATABASE_URL, which makes it simpler.

  3. Change the metadata content and include:

    "sources": [
      {
        "name": "default",
        "kind": "postgres",
        "tables": [],
        "configuration": {
          "connection_info": {
            "use_prepared_statements": false,
            "database_url": {
              "from_env": "PG_DATABASE_URL"
            },
            "isolation_level": "read-committed"
          }
        }
      }
    ]

What do you think?

SaadBazaz commented 2 years ago

I used Hasura as a Docker container and it set up perfectly. Found it faster than setting up an account, even. 😅

I then followed the steps on your website to get it working.

I think it's best to leave the installation method of choice to the Dev (more flexibility). Or mention that there are more options like local installation.

What if there was a list of metadata.json files for each version?

beerose commented 2 years ago

What if there was a list of metadata.json files for each version?

Yeah, that would be cool too.

I think it's best to leave the installation method of choice to the Dev (more flexibility

So maybe let's mention that on the cloud you have to create a DB on your own but then you can use ready metadata, and via Heroku, you'll have a DB but you'd need to set the database connection string.

SaadBazaz commented 2 years ago

That sounds great. Multiple options with their explained pros/cons is good.