hasura / hasura/graphql-engine

Server: Ability to use `current_setting('hasura.user')` in Views

Open
#8,824 3 comments 1 reaction 0 assignees View on GitHub
c/server k/enhancement t/native-dbs
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

right now for mutation transactions have `hasura.user` available to them but It would be nice to have it available for views as well so we can do something like
```sql
CREATE VIEW user_articles AS
SELECT id, title, content from articles
where author_id = current_setting('hasura.user') :: json ->> 'x-hasura-user-id'
```

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by comparing how hasura.user is made available during mutation transactions with how PostgreSQL views are executed; done means the setting is available to views so the demonstrated current_setting query can filter rows as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.