Table of Contents

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
object
BpQlApplication
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

endpoint string

The GraphQL endpoint URL.

authProvider IGraphQlAuthProvider

The authentication provider.

loggerFactory ILoggerFactory

Optional 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

endpoint string

The GraphQL endpoint URL (ending in /graphql/v1).

options GraphQlAuthorizationCodeOptions

The authorization code flow options.

loggerFactory ILoggerFactory

Optional 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

endpoint string

The GraphQL endpoint URL.

token string

The static bearer token.

loggerFactory ILoggerFactory

Optional 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

endpoint string

The GraphQL endpoint URL.

tokenEndpoint string

The OAuth token endpoint.

clientId string

The OAuth client ID.

clientSecret string

The OAuth client secret.

loggerFactory ILoggerFactory

Optional 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

GraphQlClient

Projekte

GraphQL helper for project archive functions.

[Obsolete("Use projekt.MoveToArchiv() / projektArchiv.MoveFromArchiv() on the entity.")]
public GraphQlProjekteClient Projekte { get; }

Property Value

GraphQlProjekteClient

Vorgaenge

GraphQL helper for creating Vorgänge with positions.

public GraphQlVorgaengeClient Vorgaenge { get; }

Property Value

GraphQlVorgaengeClient

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

GraphQlReadBatch

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

endpoint string

The GraphQL endpoint URL (ending in /graphql/v1).

clientId string

The OAuth client ID.

refreshToken string

The stored refresh token.

clientSecret string

The client secret for confidential clients, or null for public clients.

onTokensUpdated Action<GraphQlTokenSet>

Optional callback raised after every token acquisition; persist RefreshToken here.

loggerFactory ILoggerFactory

Optional logger factory. If null, SDK logging is disabled for this application.

cancellationToken CancellationToken

Token to cancel the initial token acquisition.

Returns

Task<BpQlApplication>

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

string

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

endpoint string

The GraphQL endpoint URL (ending in /graphql/v1).

clientId string

The OAuth client ID.

clientSecret string

The client secret for confidential clients, or null for public clients.

refreshToken string

Optional stored refresh token to resume the previous session without a browser.

redirectPort int?

The loopback port of the registered redirect URI (http://localhost:{port}/callback). If null, a free port is picked automatically.

onTokensUpdated Action<GraphQlTokenSet>

Optional callback raised after every token acquisition; persist RefreshToken here.

loggerFactory ILoggerFactory

Optional logger factory. If null, SDK logging is disabled for this application.

cancellationToken CancellationToken

Token to cancel the login.

Returns

Task<BpQlApplication>

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

endpoint string

The GraphQL endpoint URL (ending in /graphql/v1).

clientId string

The OAuth client ID.

username string

The microtech ERP username.

password string

The microtech ERP password.

redirectUri string

The redirect URI registered for the client. It is never visited — the authorization code is read from the redirect Location header.

clientSecret string

The client secret for confidential clients, or null for public clients.

refreshToken string

Optional stored refresh token; used before falling back to the credentials.

onTokensUpdated Action<GraphQlTokenSet>

Optional callback raised after every token acquisition; persist RefreshToken here.

loggerFactory ILoggerFactory

Optional logger factory. If null, SDK logging is disabled for this application.

cancellationToken CancellationToken

Token to cancel the login.

Returns

Task<BpQlApplication>

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

date DateTime

The date to filter changes from.

includes string[]

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

includes string[]

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

date DateTime

The date to filter changes from.

includes string[]

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

includes string[]

Optional field names to include in the query. If null, all fields are selected.

Returns

IQueryable<T>

Type Parameters

T