Adding and Deleting with Mutations

Summary

Mutations that add, create, or delete objects follow predictable naming patterns in the LogScale GraphQL API. Understanding these patterns makes it easier to find the right mutation without searching the full alphabetical reference. For the basics of running mutations, see Mutation Tutorials.

Add versus Create

Mutations that start with add typically add an item to an existing collection or associate one object with another. Mutations that start with create typically create a new, standalone object.

  • addUsersToGroup() โ€” adds existing users to an existing group. Both the users and the group must already exist.

  • createDashboard() โ€” creates a new dashboard object. Nothing of that type existed before the mutation ran.

Create mutations typically return the created object, so you can confirm the result and retrieve its generated ID for use in subsequent mutations.

Delete versus Remove

Mutations that start with delete typically destroy an object permanently. Mutations that start with remove typically disassociate or unlink objects, or operate on a secondary identifier such as a username rather than an object ID.

  • deleteDashboardV3() โ€” permanently removes a dashboard and all its contents.

  • removeUsersFromGroup() โ€” unlinks users from a group. The users and the group continue to exist afterward.

  • removeUser() โ€” deletes a user account using the username as the identifier, rather than an internal object ID.

Example: Adding a User to a Group

The following example adds an existing user to an existing group. You need the group's internal ID. To get a list of groups and their IDs, run the groups() query first.

graphql
mutation {
   addUsersToGroup(
      groupId: "group-id"
      users: ["username@example.com"]
   ) {
      id
      name
   }
}

A successful response returns the updated group with the fields you requested:

json
{
   "data": {
      "addUsersToGroup": {
         "id": "group-id",
         "name": "group-name"
      }
   }
}

Example: Removing a User from a Group

The following example removes one or more users from a group. You need the same group ID and the usernames of the users to remove.

graphql
mutation {
   removeUsersFromGroup(
      groupId: "group-id"
      users: ["username@example.com"]
   ) {
      id
      name
   }
}

A successful response confirms the group's updated state:

json
{
   "data": {
      "removeUsersFromGroup": {
         "id": "group-id",
         "name": "group-name"
      }
   }
}