Start a conversation

Add Users to a Role

Add new users to an existing role in bulk.

Adding users to a role using the GraphQL API in Aurora is possible using a mutation and can be performed on up to 20 users in a single request. These users are identified by their user ID.

Example Request

In this example, we will add 20 users at a time to the Example Role core role for the example-community community.

GraphQL

mutation addUsersToRole($roleKey: RoleKeyInput!) {
  addUsersToRole(roleKey: $roleKey) {
    result {
      id
      name
    }
  }
}

In addition to the variable defined as roleKey, we are requesting information in the response from the server, including the id and name of users using the result object.

The addUsersToRole function tells Aurora to add users identified in the request to the selected role.

JSON

{
  "roleKey": {
    "roleName": "",
    "nodeId": ""
  },
  "users": [
    {"id": ""},
    {"id": ""}
  ]
}

Here is a breakdown of the fields used in the example:

Name Description
roleName The name of the role we are assigning users to is Example Role as identified using this field.
nodeId This field identifies the node for which the role exists we are adding users to. If not filled out, the node defaults to the community.
users The users object lists target users by their unique identifiers.
id This field indicates the unique identifier for the user we add to the role.
Caution: Any more than 20 users being added at a time will result in an error from the server. Adding more than 20 members to a role can be achieved using multiple requests.

Example Response

A 200 response with the requested information returned indicates a successful operation.

JSON

{
  "data": {
    "addUsersToRole": {
      "result": {
        "id": "role:t:example",
        "users": {
          "totalCount": 20,
          "edges": [
            {
              "node": {
                "id": "user:1"
              }
            },
            {
              "node": {
                "id": "user:2"
              }
            }
            // ...
          ]
        }
      }
    }
  }
}
Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. ATLAS

  2. Posted
  3. Updated

Comments