API Stability Long-Term

The usersPage() GraphQL query returns a list of users in an organization. You can get all users, or limit the list to a specific search value.

To use this query field, you'll need root access, organization owner access, or permission to manage users in at least one repository or view.

For information on organization settings, see the Organization Settings documentation page. For information on user authorization, see the Manage users & permissions documentation page.

This field is not yet available. It's described here as a preview and is used for getting a new pagination pattern.

Syntax

Below is the syntax for the usersPage() query field:

graphql
usersPage(
     search: string
     orderBy: OrderByUserFieldInput
     pageSize: integer!
     pageNumber: integer!
   ): UsersPage!

The search takes a simple string within quotes. For the input OrderByUserFieldInput, you'll have to specify within curly-brackets one of three possible sorting fields (see the Given Datatypes section below). With pageSize you specify the number of records you want per page. Imagining that you have a list of users that would span several pages, use pageNumber to stipulate which page you want returned.

Look at this example for better understanding. The rest of the syntax (i.e., the UsersPage portion) is explained afterwards.

Show:
graphql
query{
  usersPage(
    search: "company.com"
    orderBy: {userField: USERNAME, order: ASC}
    pageSize: 10
    pageNumber: 1
  ) {
    page {
      id, username, displayName
    }
    pageInfo {
      number
      totalNumberOfRows
      total
    }
  }
}
Example Responses
Show:
json
{
  "data": {
    "usersPage": {
      "page": [
        {
          "id": "TMc2x9a2APnkGvyMJQbxgcOU",
          "username": "bob",
          "displayName": "Bob Newhart"
        },
        {
          "id": "mQ2oDkHSLhTG6l6ppsmxJYHJ",
          "username": "steve",
          "displayName": "Steve McQueen"
        },
        {
          "id": "czN4YDhpmZ1JrZnJ4bkQzK52",
          "username": "tom",
          "displayName": "Tom Hanks"
        }
      ],
      "pageInfo": {
        "number": 1,
        "totalNumberOfRows": 3,
        "total": 3
      }
    }
  }
}

For the UsersPage (see Returned Datatypes below), you have to enter page with the fields you want returned. As for pageInfo, all three of the parameters are required and returned.

Given Datatypes

For the given datatype, OrderByUserFieldInput, there are several parameters that may be given. Below is a list of them along with their datatypes and a description of each:

Table: OrderByUserFieldInput

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Sep 19, 2024
orderOrderByDirectionyes Long-TermHow to sort users information. See OrderByDirection.
userFieldOrderByUserFieldyes Long-TermThe user field by which to sort user information. See OrderByDirection.

Returned Datatypes

The returned datatype UsersPage has a few parameters and sub-parameter. Below is a list of them:

Table: UsersPage

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Oct 4, 2024
page[User]yes Long-TermThe users included in the page. See User.
pageInfoPageTypeyes Long-TermThe page settings. See PageType.