-
Notifications
You must be signed in to change notification settings - Fork 0
api reference GraphQL Client
Phil Hennel edited this page Oct 20, 2025
·
1 revision
Complete API reference for the GraphQL client used to interact with GitLab's GraphQL API.
GitLabGraphQLClient is the primary interface for making GraphQL requests to GitLab. It handles authentication, pagination, token refresh, and error handling.
Location: src/api/gitlabGraphQLClient.ts
new GitLabGraphQLClient(
baseUrl: string,
accessToken: string,
options?: {
refreshToken?: string;
oauth2?: {
clientId: string;
clientSecret: string;
tokenEndpoint?: string;
};
}
)Parameters:
-
baseUrl(string): GitLab instance URL -
accessToken(string): Personal Access Token or OAuth2 access token -
options(object, optional):-
refreshToken(string): OAuth2 refresh token -
oauth2(object): OAuth2 configuration-
clientId(string): OAuth2 client ID -
clientSecret(string): OAuth2 client secret -
tokenEndpoint(string): Token endpoint URL
-
-
Example:
import { GitLabGraphQLClient } from './api';
const client = new GitLabGraphQLClient(
'https:--gitlab.com',
'glpat-xxxxxxxxxxxxxxxxxxxx'
);Execute a GraphQL query.
Signature:
async query<T>(
query: DocumentNode | string,
variables?: Record<string, any>
): Promise<T>Parameters:
-
query: GraphQL query (DocumentNode or string) -
variables: Query variables (optional)
Returns: Promise resolving to query result
Example:
const result = await client.query(USERS_QUERY, {
first: 100
});Automatically paginate through all pages.
Signature:
async fetchAllPages<T>(
query: DocumentNode | string,
path: string,
variables?: Record<string, any>,
maxPages?: number
): Promise<T[]>Returns: Array of all items from all pages
Example:
const allUsers = await client.fetchAllPages(
USERS_QUERY,
'users',
{ first: 100 }
);Last Updated: 2025-10-20