The groupByDisplayName() GraphQL query groups results by a given display name.

For more information on user groups, see the Manage Groups documentation page.

Syntax

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

graphql
groupByDisplayName(
      displayName: string!
   ): Group!

To be able to get information on a particular group, with this query you have to provide the display name of the group.

For the return value Group, you'll need to specify at least one of its parameters (see the Returned Datatypes section below). Here's an example for more clarity:

Raw
graphql
query{
  groupByDisplayName(displayName: "chiefs") {
    id, users {
      id, username, displayName
    }
  }
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "query{ ^
  groupByDisplayName(displayName: \"chiefs\") { ^
    id, users { ^
      id, username, displayName ^
    } ^
  } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}'
"$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $json = '{"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}';
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL/graphql',
  path: '/graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "groupByDisplayName": {
      "id": "BHdJstvjgDUjXg10KrbjiybpSbOHIw1b",
      "users": [
        {
          "id": "czN4YDhpmZ1JrZnJ4bkQzK52",
          "username": "tom",
          "displayName": "Tom Hanks"
        },
        {
          "id": "mQ2oDkHSLhTG6l6ppsmxJYHJ",
          "username": "steve",
          "displayName": "Steve McQueen"
        },
        {
          "id": "TMc2x9a2APnkGvyMJQbxgcOU",
          "username": "bob",
          "displayName": "Bob Newhart"
        }
      ]
    }
  }
}

This example requests first the ID for the group, then a list or array of users in the group. For each user, it calls for the user's ID, the user name, and the display name of the user.

Returned Datatypes

The returned datatype group has its own parameters. Below is a list of them along with their datatypes and a description of each:

Table: Group

ParameterTypeRequired[a]DefaultDescription
idstringyes The identifier of the group.
displayNamestringyes The display name of the group.
colorstring  The display color associated with the group.
descriptionRole  The role associated with the group (see Role Table).
viewPermissionsstring  Any view permissions assigned to the group.
searchDomainCountintegeryes The number of search domains for the group.
roles[SearchDomainRole]yes The roles for the group (see SearchDomainRole Table).
searchDomainRoles(searchDomainId: string): [SearchDomainRole]yes The search domain roles assigned to the group (see SearchDomainRole Table).
searchDomainRolesByName(searchDomainName: string!): SearchDomainRoleyes The search domain roles assigned to the group, by name. The searchDomainName is a string value, not a complex datatype (see SearchDomainRole Table).
systemRoles[GroupSystemRole]yes The system roles of the group (see GroupSystemRole Table).
organizationRoles[GroupOrganizationRole]yes The roles of the organization associated with the group (see GroupOrganizationRole Table).
queryPrefixes[QueryPrefixes]yes The query prefixes for the group (see QueryPrefixes Table).
userCountintegeryes The number of users that are part of the group.
users[User]yes The list of users in the group (see User Table).

[a] Some arguments may be required, as indicated in this column. For some fields, this column indicates that a result will always be returned for it.