hasura / hasura/graphql-engine

Permissions array operators: Check if array column contains value

Open
#7,346 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

I am currently testing Hasura for use in a productive system and am quite impressed, good work!

Unfortunately, I have not yet been able to realise an auhtorisation use case, the following scenario:

_A customer has several divisions, users can belong to several divisions and have several different roles there.
To map this, there is a table userDivisionRoles in the database with the columns userId, divisionId and roles (an array of the enum DivisionRole)._

I would like to check for incoming requests in the table userDivisionRoles:
- userId = X-Hasura-User-Id
- divisionId = X-Hasura Division-Id
- roles: Contains X-Hasura-Role / X-Hasura-Default-Role (= user has the appropriate role in the division).

So basically what is needed is an array operator "contains" that checks whether a certain value (right side) is contained in a column of type array (left side).

Does such an operator exist and have I overlooked it, or is this simply not possible so far?
How could this be modelled instead?

Thank you very much!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.