Class BpQlApplication
- Namespace
- BpNexT.NET.GraphQL.Application
- Assembly
- BpNexT.NET.GraphQL.dll
GraphQL alternative to BpApplication.
Provides a compatible LINQ interface for accessing microtech ERP data via the GraphQL API.
public class BpQlApplication : IBpQlApplication, IDisposable
- Inheritance
-
objectBpQlApplication
- Implements
Constructors
BpQlApplication(string, IGraphQlAuthProvider, ILoggerFactory?)
Initializes a new instance with a custom auth provider.
public BpQlApplication(string endpoint, IGraphQlAuthProvider authProvider, ILoggerFactory? loggerFactory = null)
Parameters
endpointstringThe GraphQL endpoint URL.
authProviderIGraphQlAuthProviderThe authentication provider.
loggerFactoryILoggerFactoryOptional logger factory. If null, SDK logging is disabled for this application.
BpQlApplication(string, GraphQlAuthorizationCodeOptions, ILoggerFactory?)
Initializes a new instance that authenticates via the OAuth 2.0 authorization code flow with
PKCE, using a stored refresh token and/or microtech ERP user credentials (see
GraphQlAuthorizationCodeOptions). The authorize and token endpoints are derived
from endpoint. Tokens are acquired lazily on the first request; use the
static factories (LoginWithCredentialsAsync(string, string, string, string, string, string?, string?, Action<GraphQlTokenSet>?, ILoggerFactory?, CancellationToken), FromRefreshTokenAsync(string, string, string, string?, Action<GraphQlTokenSet>?, ILoggerFactory?, CancellationToken),
LoginWithBrowserAsync(string, string, string?, string?, int?, Action<GraphQlTokenSet>?, ILoggerFactory?, CancellationToken)) to authenticate eagerly or interactively.
public BpQlApplication(string endpoint, GraphQlAuthorizationCodeOptions options, ILoggerFactory? loggerFactory = null)
Parameters
endpointstringThe GraphQL endpoint URL (ending in
/graphql/v1).optionsGraphQlAuthorizationCodeOptionsThe authorization code flow options.
loggerFactoryILoggerFactoryOptional logger factory. If null, SDK logging is disabled for this application.
Exceptions
- ArgumentException
Thrown when the options contain no usable credential source.
BpQlApplication(string, string, ILoggerFactory?)
Initializes a new instance with a static bearer token.
public BpQlApplication(string endpoint, string token, ILoggerFactory? loggerFactory = null)
Parameters
endpointstringThe GraphQL endpoint URL.
tokenstringThe static bearer token.
loggerFactoryILoggerFactoryOptional logger factory. If null, SDK logging is disabled for this application.
BpQlApplication(string, string, string, string, ILoggerFactory?)
Initializes a new instance with OAuth 2.0 client credentials.
public BpQlApplication(string endpoint, string tokenEndpoint, string clientId, string clientSecret, ILoggerFactory? loggerFactory = null)
Parameters
endpointstringThe GraphQL endpoint URL.
tokenEndpointstringThe OAuth token endpoint.
clientIdstringThe OAuth client ID.
clientSecretstringThe OAuth client secret.
loggerFactoryILoggerFactoryOptional logger factory. If null, SDK logging is disabled for this application.
Properties
Client
Gets the underlying GraphQL client for direct query execution.
public GraphQlClient Client { get; }
Property Value
Projekte
GraphQL helper for project archive functions.
[Obsolete("Use projekt.MoveToArchiv() / projektArchiv.MoveFromArchiv() on the entity.")]
public GraphQlProjekteClient Projekte { get; }
Property Value
Vorgaenge
GraphQL helper for creating Vorgänge with positions.
public GraphQlVorgaengeClient Vorgaenge { get; }
Property Value
Methods
AddDataSet<T>()
Creates a new tracked dataset entity that can be persisted via Save().
public T AddDataSet<T>() where T : IDataSetEntity, new()
Returns
- T
Type Parameters
T
Batch()
Creates a fluent read batch to execute multiple GraphQL queries in a single request.
public GraphQlReadBatch Batch()
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
FromRefreshTokenAsync(string, string, string, string?, Action<GraphQlTokenSet>?, ILoggerFactory?, CancellationToken)
Creates an application from a stored refresh token without any browser interaction —
intended for non-interactive hosts such as Windows services.
Provision the refresh token once interactively (e.g. via LoginWithBrowserAsync(string, string, string?, string?, int?, Action<GraphQlTokenSet>?, ILoggerFactory?, CancellationToken) on a
workstation) and persist every rotation via onTokensUpdated; the session stays
alive as long as the host refreshes within the refresh token's lifetime (about 30 days).
If the host can hold user credentials, prefer LoginWithCredentialsAsync(string, string, string, string, string, string?, string?, Action<GraphQlTokenSet>?, ILoggerFactory?, CancellationToken) — it
self-heals when the refresh token expires.
public static Task<BpQlApplication> FromRefreshTokenAsync(string endpoint, string clientId, string refreshToken, string? clientSecret = null, Action<GraphQlTokenSet>? onTokensUpdated = null, ILoggerFactory? loggerFactory = null, CancellationToken cancellationToken = default)
Parameters
endpointstringThe GraphQL endpoint URL (ending in
/graphql/v1).clientIdstringThe OAuth client ID.
refreshTokenstringThe stored refresh token.
clientSecretstringThe client secret for confidential clients, or null for public clients.
onTokensUpdatedAction<GraphQlTokenSet>Optional callback raised after every token acquisition; persist RefreshToken here.
loggerFactoryILoggerFactoryOptional logger factory. If null, SDK logging is disabled for this application.
cancellationTokenCancellationTokenToken to cancel the initial token acquisition.
Returns
Exceptions
- GraphQlAuthenticationException
Thrown when the refresh token is invalid, expired, or revoked.
GetVersion()
Gets the version of BpNexT.NET.GraphQL.
public static string GetVersion()
Returns
LoginWithBrowserAsync(string, string, string?, string?, int?, Action<GraphQlTokenSet>?, ILoggerFactory?, CancellationToken)
Performs an interactive browser login (OAuth 2.0 authorization code flow with PKCE) and returns
a ready application. The authorize and token endpoints are derived from endpoint
({base}/authorize and {base}/token).
Subscribe via onTokensUpdated to persist the (rotating) refresh token and pass it
back as refreshToken on the next start to skip the browser; the browser is only
opened when no valid refresh token is available.
For non-interactive hosts (e.g. Windows services) use FromRefreshTokenAsync(string, string, string, string?, Action<GraphQlTokenSet>?, ILoggerFactory?, CancellationToken) instead.
For web apps or custom hosts, compose an OAuthAuthorizationCodeClient and an
AuthorizationCodeTokenProvider yourself and use the
BpQlApplication(string, IGraphQlAuthProvider, ILoggerFactory?) constructor.
public static Task<BpQlApplication> LoginWithBrowserAsync(string endpoint, string clientId, string? clientSecret = null, string? refreshToken = null, int? redirectPort = null, Action<GraphQlTokenSet>? onTokensUpdated = null, ILoggerFactory? loggerFactory = null, CancellationToken cancellationToken = default)
Parameters
endpointstringThe GraphQL endpoint URL (ending in
/graphql/v1).clientIdstringThe OAuth client ID.
clientSecretstringThe client secret for confidential clients, or null for public clients.
refreshTokenstringOptional stored refresh token to resume the previous session without a browser.
redirectPortint?The loopback port of the registered redirect URI (
http://localhost:{port}/callback). If null, a free port is picked automatically.onTokensUpdatedAction<GraphQlTokenSet>Optional callback raised after every token acquisition; persist RefreshToken here.
loggerFactoryILoggerFactoryOptional logger factory. If null, SDK logging is disabled for this application.
cancellationTokenCancellationTokenToken to cancel the login.
Returns
Exceptions
- GraphQlAuthenticationException
Thrown when the login fails or the session is non-interactive.
LoginWithCredentialsAsync(string, string, string, string, string, string?, string?, Action<GraphQlTokenSet>?, ILoggerFactory?, CancellationToken)
Runs the authorization code flow with PKCE without a browser by authenticating the user at the
authorize endpoint with HTTP Basic auth (microtech ERP username and password) — suitable for headless
hosts such as Windows services. The endpoints are derived from endpoint.
When a stored refreshToken is supplied, it is used first and the credentials
only serve as fallback (e.g. after the refresh token expired), so the session self-heals without
any manual re-provisioning.
public static Task<BpQlApplication> LoginWithCredentialsAsync(string endpoint, string clientId, string username, string password, string redirectUri, string? clientSecret = null, string? refreshToken = null, Action<GraphQlTokenSet>? onTokensUpdated = null, ILoggerFactory? loggerFactory = null, CancellationToken cancellationToken = default)
Parameters
endpointstringThe GraphQL endpoint URL (ending in
/graphql/v1).clientIdstringThe OAuth client ID.
usernamestringThe microtech ERP username.
passwordstringThe microtech ERP password.
redirectUristringThe redirect URI registered for the client. It is never visited — the authorization code is read from the redirect Location header.
clientSecretstringThe client secret for confidential clients, or null for public clients.
refreshTokenstringOptional stored refresh token; used before falling back to the credentials.
onTokensUpdatedAction<GraphQlTokenSet>Optional callback raised after every token acquisition; persist RefreshToken here.
loggerFactoryILoggerFactoryOptional logger factory. If null, SDK logging is disabled for this application.
cancellationTokenCancellationTokenToken to cancel the login.
Returns
Exceptions
- GraphQlAuthenticationException
Thrown when the credentials are rejected or the login fails.
QueryChanged<T>(DateTime, string[]?)
Creates a queryable over the rows changed since the given date. The AendDat > date
condition is evaluated server-side as a slowFilter (AendDat is a calculated field and
not index-backed), so only the changed rows are transferred.
public IQueryable<T> QueryChanged<T>(DateTime date, string[]? includes = null) where T : class, IDataSetEntity, IHasAendDat, new()
Parameters
dateDateTimeThe date to filter changes from.
includesstring[]Optional field names to include in the query. If null, all fields are selected.
Returns
- IQueryable<T>
Type Parameters
T
QueryDataSet<T>(string[]?)
Creates a queryable interface for reading data via GraphQL. Uses rowsRead by default, auto-switches to conRead when Skip/Take are used.
public IQueryable<T> QueryDataSet<T>(string[]? includes = null) where T : IDataSetEntity, new()
Parameters
includesstring[]Optional field names to include in the query. If null, all fields are selected.
Returns
- IQueryable<T>
Type Parameters
T
ReadChanged<T>(DateTime, string[]?)
Creates a queryable over the rows changed since the given date. The AendDat > date
condition is evaluated server-side as a slowFilter (AendDat is a calculated field and
not index-backed), so only the changed rows are transferred.
public IQueryable<T> ReadChanged<T>(DateTime date, string[]? includes = null) where T : class, IDataSetEntity, IHasAendDat, new()
Parameters
dateDateTimeThe date to filter changes from.
includesstring[]Optional field names to include in the query. If null, all fields are selected.
Returns
- IQueryable<T>
Type Parameters
T
ReadDataSet<T>(string[]?)
Creates a queryable interface for reading data via GraphQL. Alias for QueryDataSet<T>(string[]?) — uses rowsRead by default, conRead with Skip/Take.
public IQueryable<T> ReadDataSet<T>(string[]? includes = null) where T : IDataSetEntity, new()
Parameters
includesstring[]Optional field names to include in the query. If null, all fields are selected.
Returns
- IQueryable<T>
Type Parameters
T