nhost-js
setRole()
Use nhost.setRole
to set the user role for all subsequent GraphQL, storage, and functions calls.
Underneath, this method sets the x-hasura-role
header on the graphql, storage,
and functions clients.
nhost.graphql.setHeaders({ 'x-hasura-role': role })
nhost.storage.setHeaders({ 'x-hasura-role': role })
nhost.functions.setHeaders({ 'x-hasura-role': role })
Note: Exercise caution when mixing the use of setRole
along with setHeaders
when setting the
x-hasura-role
header, as the last call will override any previous ones.
nhost.setRole('admin')
Parameters
role required string