Skip to content

Commit

Permalink
feat: Add setRole method to NhostClient
Browse files Browse the repository at this point in the history
  • Loading branch information
onehassan committed May 9, 2024
1 parent 73e939a commit b06cd1a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/nhost-js/src/clients/nhost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,20 @@ export class NhostClient {
// this.functions.setAdminSecret(newValue)
// this.graphql.setAdminSecret(newValue)
}

/**
* Use `nhost.setRole` to set the user role for all subsequent graphql, storage and functions calls
*
* @example
* ```ts
* nhost.setRole('admin')
* ```
*
* @docs https://docs.nhost.io/reference/javascript/set-role
*/
setRole(role: string) {
this.graphql.setHeaders({ 'x-hasura-role': role })
this.storage.setHeaders({ 'x-hasura-role': role })
this.functions.setHeaders({ 'x-hasura-role': role })
}
}

0 comments on commit b06cd1a

Please sign in to comment.