Graphql-engine: What i must input into X-Hasura-User-Id when role is anonymous?

Created on 9 Jun 2020  路  3Comments  路  Source: hasura/graphql-engine

image

question

All 3 comments

No, maybe you don't need it. X-Hasura-User-Id is optional that is used for permission. For anonymous role, it won't be used if your anonymous role doesn't use it. The sample just set it as placeholder. You can remove it if you want

@hgiasac but i use this variable in permission to view "current_user", by rule {id: {_eq: "X-Hasura-User-Id" }}, and this must return null to anonymous user, but if i not give any permission anonymous to "current_user" view, graphql query from not loginnet user throw GraphQL error "current_user not exists in schema", so I have to give at least some permission, even to an anonymous user. so that he can get null without errors and understand what is anonymous, and draw a SignIn button.

@MaxmaxmaximusGitHub This is expected behavior. The user only can fetch permission GraphQL schema. So for anonymous role, you should add a select permission for current_user, but with dummy condition that is always false, e.g { "id": { "_eq": -1 } }. Anonymous users always get empty result

Was this page helpful?
0 / 5 - 0 ratings