Class GraphQlClient
HTTP client wrapper for executing GraphQL queries. Injects bearer token authentication via IGraphQlAuthProvider.
public class GraphQlClient : IGraphQlClient
- Inheritance
-
objectGraphQlClient
- Implements
- Extension Methods
Constructors
GraphQlClient(string, IGraphQlAuthProvider, HttpClient?, ILoggerFactory?)
Initializes a new instance of the GraphQlClient class.
public GraphQlClient(string endpoint, IGraphQlAuthProvider authProvider, HttpClient? httpClient = null, ILoggerFactory? loggerFactory = null)
Parameters
endpointstringThe GraphQL endpoint URL.
authProviderIGraphQlAuthProviderThe authentication provider.
httpClientHttpClientOptional HTTP client instance. When provided, its lifetime is owned by the caller.
loggerFactoryILoggerFactoryOptional logger factory. If null, SDK logging is disabled for this client.
Methods
ExecuteAsync(string, object?, CancellationToken)
Executes a GraphQL query and returns the raw JSON response.
public Task<JObject> ExecuteAsync(string query, object? variables = null, CancellationToken cancellationToken = default)
Parameters
querystringThe GraphQL query string.
variablesobjectOptional variables for the query.
cancellationTokenCancellationTokenToken to cancel the request.
Returns
- Task<JObject>
The parsed JSON response object.