这是indexloc提供的服务,不要输入任何密码
Skip to content

console: allow setting session_argument while tracking functions #4499

@rikinsk

Description

@rikinsk

Ref: https://hasura.io/docs/1.0/graphql/manual/api-reference/schema-metadata-api/custom-functions.html#track-function-v2

We can create custom postgres functions that are taking some arguments, for example:

CREATE TABLE text_result(
  result text
);

CREATE
OR REPLACE FUNCTION customFunctionWithSessionArg(
	customNameForSessionArg json, name text
) RETURNS SETOF text_result LANGUAGE sql STABLE AS $$
SELECT
  q.*
FROM
  (
    VALUES
      (customNameForSessionArg ->> 'x-hasura-role')
  ) q $$

Then we can track it with track_function v2:
https://hasura.io/docs/1.0/graphql/manual/api-reference/schema-metadata-api/custom-functions.html#

And tell Hasura to fill customNameForSessionArg with the session argument:

{
    "type": "track_function",
    "version": 2,
    "args": {
        "function": {
            "schema": "public",
            "name": "get_session_role"
        },
        "configuration": {
            "session_argument": "customNameForSessionArg"
        }
    }
}

What needs to be done:

  1. Add text input on the function modify page that allows users to set and edit session_argument.
  2. Track this function with the session argument.

Metadata

Metadata

Assignees

Labels

c/consoleRelated to consoledesign-rfcPicked up by product design team for RFCe/easycan be wrapped up in a couple of daysk/enhancementNew feature or improve an existing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions