0

I was wondering if there is any way to do this in hasura without resorting to creating another service.

Let me explain, in an api a user sends his token, this is decoded in the backend and and so we know who the user is, this is useful for example to search and return records in the database that only belong to this user.

Is there any way to do that with Hasura? the only return the records that belong to a certain user using its token?.

geraktOfRivia
  • 325
  • 3
  • 7
  • 19
  • 1
    Are you asking about how to access x-hasura-user-id? If so, then you can access it in Row Security (for purposes similar as you explain ) , mutations, in functions registered with `hasura_session` argument. – Alex Yu Oct 23 '21 at 21:29

1 Answers1

3

Token data is available as session data so you can use hasura column presets to insert the user id and add permission to only fetch rows that have user id equal to user id from session https://hasura.io/docs/latest/graphql/core/databases/postgres/schema/default-values/column-presets.html#column-presets

Abdullah Saleem
  • 3,701
  • 1
  • 19
  • 30