Metadata API Reference: Custom Functions

Introduction

Track/untrack a custom SQL function in the Hasura GraphQL engine.

Only tracked custom functions are available for querying/mutating/subscribing data over the GraphQL API.

pg_create_function_permission

pg_create_function_permission is used to add permission to an existing custom function. To add a function permission, the graphql-engine should have disabled inferring of function permissions and the provided role should have select permissions to the target table of the function.

POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
    "type": "pg_create_function_permission",
    "args": {
       "function": "get_articles",
       "role": "user"
    }
}

Args syntax

Key Required Schema Description
function true FunctionName Name of the SQL function
role true RoleName Name of the role
source false Text Name of the source of the SQL function

pg_drop_function_permission

pg_drop_function_permission is used to drop an existing function permission.

POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
    "type": "pg_drop_function_permission",
    "args": {
       "function": "get_articles",
       "role": "user"
    }
}

Args syntax

Key Required Schema Description
function true FunctionName Name of the SQL function
role true RoleName Name of the role
source false Text Name of the source of the SQL function