1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
---
stage: Govern
group: Compliance
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments
---
# Create an audit report by using GraphQL
DETAILS:
**Tier:** Free, Premium, Ultimate
**Offering:** GitLab.com, Self-managed, GitLab Dedicated
You can create an audit report for a specific subset of users by using:
- GraphiQL.
- [`cURL`](getting_started.md#command-line).
## Use GraphiQL
You can use GraphiQL to query information about a subset of users.
1. Open GraphiQL:
- For GitLab.com, use: `https://gitlab.com/-/graphql-explorer`
- For self-managed GitLab, use: `https://gitlab.example.com/-/graphql-explorer`
1. Copy the following text and paste it in the left window.
This query searches for a subset of users by username. Alternately, you can use their
[Global ID](../../development/api_graphql_styleguide.md#global-ids).
```graphql
{
users(usernames: ["user1", "user2", "user3"]) {
pageInfo {
endCursor
startCursor
hasNextPage
}
nodes {
id
...memberships
}
}
}
fragment membership on MemberInterface {
createdAt
updatedAt
accessLevel {
integerValue
stringValue
}
createdBy {
id
}
}
fragment memberships on User {
groupMemberships {
nodes {
...membership
group {
id
name
}
}
}
projectMemberships {
nodes {
...membership
project {
id
name
}
}
}
}
```
1. Select **Play**.
NOTE:
[The GraphQL API returns a GlobalID, rather than a standard ID](getting_started.md#queries-and-mutations).
It also expects a GlobalID as an input rather than a single integer.
This query returns the groups and projects that the user has been explicitly made a member of.
- Because GraphiQL uses the session token to authorize access to resources,
the output is limited to the projects and groups accessible to the currently authenticated user.
- If you are signed in as an instance administrator, you have access to all resources.
## Pagination and graph nodes
The query includes:
- [`pageInfo`](#pageinfo)
- [`nodes`](#nodes)
### `pageInfo`
This contains the data needed to implement pagination. GitLab uses cursor-based
[pagination](getting_started.md#pagination). For more information, see
[Pagination](https://graphql.org/learn/pagination/) in the GraphQL documentation.
### `nodes`
In a GraphQL query, `nodes` represents a collection of [`nodes` on a graph](https://en.wikipedia.org/wiki/Vertex_(graph_theory)).
In this case, the collection of nodes is a collection of `User` objects. For each one,
the output includes:
- The user's `id`.
- The `membership` fragment, which represents project or group membership that belongs
to that user. Fragments are indicated by the `...memberships` notation.
## Related topics
- [GraphQL API reference](reference/index.md)
- [GraphQL-specific entities, like fragments and interfaces](https://graphql.org/learn/)
|