Hi Community,
I have one scenario where I am stuck right now. I have some users which are differentiated base on their roles. Based on their roles, I have set permissions on the table for read and write. For this i have set some custom filters. My scenario is to allow users to see other users of same role. For this i have set custom_filter in user table like below
{
“OR”: [
{
“roles”: {
“some”: {
“name”: {
“contains”: “Regular”
}
}
}
}
]
}
It set perfectly but When I am trying it on API_explorer with this query -
query MyQuery {
usersList {
items {
firstName
email
}
}
}
It showing me details of all users except for same role users. Can anyone guide me here what wrong I am doing it here?
Hey @nikhil.kumar
You can test Custom Filters in the API Explorer be making them a variable. For example:
Your Query
query ($customFilter: UserFilter) {
usersList(filter: $customFIilter) {
count
}
}
Your Variable/Filter
{
"customFilter": {
"name": {
"contains": "Steve"
}
}
}
For a filter that allows Users to see other users with the same roles, this approach should work.
For setting a static role name.
{
"roles": {
"some": {
"name": {
"equals": "[MY_ROLE_NAME]"
}
}
}
}
For a single role that should let a user see other users that belong to the roles they are a user of.
{
"roles": {
"some": {
"users": {
"some": {
"roles": {
"some": {
"users": {
"some": {
"is_self": true
}
}
}
}
}
}
}
}
}
1 Like
Pretty awesome, thanks @sebastian.scholl. I setup this with custom filter query as you also mentioned, when I tested it over Postman, it worked for me. Will try out the variable way.
1 Like