Skip to content

v1.0.0-rc.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@hasura-bot hasura-bot released this 02 Dec 08:15
· 7932 commits to master since this release

Changelog

Accessing session information in functions

Functions can now access session information (JSON) when they are tracked via version 2 of the track_function metadata API (which allows specifying an input arg to access session information).

Example

Tracking a function and specifying the input arg:

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

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

Here's how you can access session information in function:

 -- A simple function which accesses role     
 -- information from the 'hasura_session' argument
 CREATE FUNCTION search_articles(hasura_session json)
 RETURNS SETOF articles AS $$
     SELECT * FROM articles where author_id = (hasura_session ->> 'x-hasura-user-id')
 $$ LANGUAGE sql STABLE;

Performance (#3012)

Configure GraphQL engine's internal operations cache size

The size of the operations plan cache used by GraphQL engine can now be limited. To keep the cache size constant, the older entries are discarded using LRU strategy.

Cache size (number of operations) can be configured through the command line argument --query-plan-cache-size and the env variable QUERY_PLAN_CACHE_SIZE (the numbers of GraphQL operations to be cached; 100 is a decent default value for most apps). The accepted values are from 0-65535 (0 disables the cache). When this value isn't specified, an unbounded cache is used which is the current behaviour. A future iteration of this change will change this behavious to default to a fixed cache size.

read-only run_sql API

A read_only parameter has been added to the run_sql metadata API. This sets the postgres transaction mode to ReadOnly. This can be used by the console, etc. to perform select operations without forcing cache/gctx recomputation.

Other server & CLI changes

Console changes

  • Display untrackable functions on schema page (close #2249) (#2773)
  • Fix console data hydration query (close #3342) (#3361)
  • Make cursor pointer on track and cascade checkboxes in console RawSQL (close #3276) (#3364)
  • Allow setting check constraints on existing tables from console (#3383)