User Related Queries

The following queries are SAMPLES. As a consumer of the Scope GraphQL API, you can design and use any properly formed query to retrieve the data that you require.

For more information, see “Introduction to the Scope GraphQL API“.

Here are common use-cases for various User operations like creating, finding, updating or deleting a user.

Creating a User

The mutation query below can be used to create a new user. For reference, you can look at the CreateUserMutation schema.

Arguments

There are some argument considerations

  • requestedOriginGroup - The origin group to request. Must be a valid group name UPPERCASED. This parameter is only used when the requested licenses include an admin or author license. Otherwise this should be omitted.

  • requestedLicenses - The licenses to request. Must be an array of LicenseType.ENUM values.

  • requestedGroups - The groups to request. Must be an array of UPPERCASE strings, ie. [DEFAULT, GROUP1, GROUP2]

To receive error messages when creating a user, make sure to add the errors in the return object as seen below in the query example.

Example

mutation { createUser( input: { user: { firstName: "Luke", lastName: "Skywalker", credentials: { username: "luke_skywalker", password: "womprats!1977" }, email: "luke.skywalker@jedi.org" }, requestedOriginGroup: "DEFAULT" requestedLicenses: [VIEWER], requestedGroups: ["DEFAULT", "JEDI", "REBEL"] ) { errors { path message fullMessage } user { id username email } } }

Finding Users By Email Addresses

This query can be used to find a user(s) based on their email address. Multiple users can be returned if the email address is similar. Additional input arguments can be included to make selection more specific.

Example 1:

This query “digs” through the viewer’s current organization and returns the members.

Variables

{ "first": 1, "fullText": "luke@jedi.org" }

Query

query FetchMembers($fullText: String, $first: Int!) { viewer { currentOrganization { members(fullText: $fullText, first: $first) { nodes { firstName lastName username email } } } } }

Example 2:

This query uses the users query field, which is available on v2.28.1 and above.

Query

 

Updating a User

When updating a user, the ID retrieved earlier is required. The groups, and origin group use the group name. The licenses need a value from the LicenseTypeEnum.

Variables

Query

Deleting Users

Multiple users can be removed at the same time by using the ids provided by the User queries. There are some exceptions and considerations to this operation:

  • A user cannot remove themselves

  • Invalid IDs will be skipped and valid IDs will be used to delete users. Errors of these invalid IDs will be returned.

  • It does not delete the last company admin. A single company admin must remain in the system.

  • It does not delete Scope/Support admin users. This will allow the support team to assist.

Variables

Query