diff --git a/indexer-js-queue-handler/__snapshots__/hasura-client.test.js.snap b/indexer-js-queue-handler/__snapshots__/hasura-client.test.js.snap index cd1464589..b93fa6907 100644 --- a/indexer-js-queue-handler/__snapshots__/hasura-client.test.js.snap +++ b/indexer-js-queue-handler/__snapshots__/hasura-client.test.js.snap @@ -24,6 +24,7 @@ exports[`HasuraClient adds the specified permissions for the specified roles/tab { "args": { "permission": { + "backend_only": true, "check": {}, "columns": "*", "computed_fields": [], @@ -38,6 +39,42 @@ exports[`HasuraClient adds the specified permissions for the specified roles/tab }, "type": "pg_create_insert_permission", }, + { + "args": { + "permission": { + "backend_only": true, + "check": {}, + "columns": "*", + "computed_fields": [], + "filter": {}, + }, + "role": "role", + "source": "default", + "table": { + "name": "height", + "schema": "schema", + }, + }, + "type": "pg_create_update_permission", + }, + { + "args": { + "permission": { + "backend_only": true, + "check": {}, + "columns": "*", + "computed_fields": [], + "filter": {}, + }, + "role": "role", + "source": "default", + "table": { + "name": "height", + "schema": "schema", + }, + }, + "type": "pg_create_delete_permission", + }, { "args": { "permission": { @@ -59,6 +96,7 @@ exports[`HasuraClient adds the specified permissions for the specified roles/tab { "args": { "permission": { + "backend_only": true, "check": {}, "columns": "*", "computed_fields": [], @@ -73,6 +111,42 @@ exports[`HasuraClient adds the specified permissions for the specified roles/tab }, "type": "pg_create_insert_permission", }, + { + "args": { + "permission": { + "backend_only": true, + "check": {}, + "columns": "*", + "computed_fields": [], + "filter": {}, + }, + "role": "role", + "source": "default", + "table": { + "name": "width", + "schema": "schema", + }, + }, + "type": "pg_create_update_permission", + }, + { + "args": { + "permission": { + "backend_only": true, + "check": {}, + "columns": "*", + "computed_fields": [], + "filter": {}, + }, + "role": "role", + "source": "default", + "table": { + "name": "width", + "schema": "schema", + }, + }, + "type": "pg_create_delete_permission", + }, ], "type": "bulk", } diff --git a/indexer-js-queue-handler/hasura-client.js b/indexer-js-queue-handler/hasura-client.js index 4723928ff..395614aa1 100644 --- a/indexer-js-queue-handler/hasura-client.js +++ b/indexer-js-queue-handler/hasura-client.js @@ -230,7 +230,9 @@ export default class HasuraClient { check: {}, computed_fields: [], filter: {}, - ...(permission == 'select' && { allow_aggregations: true }) + ...(permission === "select" + ? { allow_aggregations: true } + : { backend_only: true }), }, source: 'default' }, diff --git a/indexer-js-queue-handler/hasura-client.test.js b/indexer-js-queue-handler/hasura-client.test.js index c64e5a173..150f846b9 100644 --- a/indexer-js-queue-handler/hasura-client.test.js +++ b/indexer-js-queue-handler/hasura-client.test.js @@ -114,7 +114,7 @@ describe('HasuraClient', () => { }); const client = new HasuraClient({ fetch }) - await client.addPermissionsToTables('schema', ['height', 'width'], 'role', ['select', 'insert']); + await client.addPermissionsToTables('schema', ['height', 'width'], 'role', ['select', 'insert', 'update', 'delete']); expect(fetch.mock.calls[0][1].headers['X-Hasura-Admin-Secret']).toBe(HASURA_ADMIN_SECRET) expect(JSON.parse(fetch.mock.calls[0][1].body)).toMatchSnapshot();