Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Info

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.

Table of Contents
minLevel1
maxLevel2

...

  • 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]

...

Note

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

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

...

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

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

Query

Code Block
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

Code Block
{
  users(
      fullText: "luke@jedi.org"
      first: 1
  )
   {
    errors {
      fullMessage
    }
    nodes {
      id
      firstName
      lastName
      username
      email
    }
    totalCount
  }
}

...

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

Code Block
{
  "input": {
    "id": <STRING>,
    "requestedGroups": Array<STRING>,
    "requestedLicenses": Array<STRING>,
    "requestedOriginGroup": <STRING>,
    "user": {
      "email": <STRING>,
      "firstName": <STRING>,
      "lastName": <STRING>,
      "phone": <STRING>,
      "jobTitle": <STRING>
    }
  }
}

...

  • 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

Code Block
languagejson
{"input": {"ids": Array<String> } }

...