LenzEng.Utilities.Cqrs.GraphQL
0.4.0
dotnet add package LenzEng.Utilities.Cqrs.GraphQL --version 0.4.0
NuGet\Install-Package LenzEng.Utilities.Cqrs.GraphQL -Version 0.4.0
<PackageReference Include="LenzEng.Utilities.Cqrs.GraphQL" Version="0.4.0" />
<PackageVersion Include="LenzEng.Utilities.Cqrs.GraphQL" Version="0.4.0" />
<PackageReference Include="LenzEng.Utilities.Cqrs.GraphQL" />
paket add LenzEng.Utilities.Cqrs.GraphQL --version 0.4.0
#r "nuget: LenzEng.Utilities.Cqrs.GraphQL, 0.4.0"
#:package LenzEng.Utilities.Cqrs.GraphQL@0.4.0
#addin nuget:?package=LenzEng.Utilities.Cqrs.GraphQL&version=0.4.0
#tool nuget:?package=LenzEng.Utilities.Cqrs.GraphQL&version=0.4.0
LenzEng.Utilities.Cqrs.GraphQL
GraphQL integration for LenzEng.Utilities.Cqrs — the GraphQL sibling of LenzEng.Utilities.Cqrs.Rest. Converts the raw results your command/query handlers return into the values a GraphQL resolver returns: a typed result for queries, a CommandPayload<TResult> for mutations. Depends on no GraphQL server library — use it with HotChocolate, GraphQL.NET, or anything else.
What It Provides
| Type | Purpose |
|---|---|
AddCqrsGraphQL() |
Registers IGraphQLCommandProcessor/IGraphQLQueryProcessor |
IGraphQLCommandProcessor / IGraphQLQueryProcessor |
Resolve and invoke the registered handler for a command/query, returning the resolver's value directly |
AddGraphQLMutation<TCommand, TResult>(...) |
Registers a command as a mutation → CommandPayload<TResult> |
AddGraphQLQuery<TQuery, TResult>(...) |
Registers a query → TResult? |
GraphQLCommandHandlerBase<T, TResult> / GraphQLQueryHandlerBase<T, TResult> |
Base classes for hand-written handlers the generic ones don't cover |
Key Behaviour
- "Not found" happens automatically when a handler returns
LenzEng.Utilities.Cqrs.NotFoundMarker— queries resolve tonull; mutations get aNOT_FOUND-coded entry inCommandPayload.Errors. - Validation errors land in
CommandPayload<TResult>.ErrorswhenLenzEng.Utilities.Cqrs.FluentValidation'sValidateCommandExceptionis thrown — this package doesn't reference that one, it just catches the exception type by name from the core package. - Conversion functions are typed as
Func<object, object>rather thanFunc<TDomain, TDto>on purpose, so the generic handlers stay decoupled from your domain/DTO types.
Quick Start
builder.Services.AddCqrs(typeof(CreateOrderCommandHandler).Assembly);
builder.Services.AddCqrsGraphQL();
builder.Services.AddGraphQLMutation<CreateOrderCommand, Order>(opts =>
opts.ConversionFunction = ServiceModelConverter.ConvertOrder);
builder.Services.AddGraphQLQuery<GetOrderByIdQuery, Order>();
public class Mutation
{
private readonly IGraphQLCommandProcessor _commands;
public Mutation(IGraphQLCommandProcessor commands) => _commands = commands;
public Task<CommandPayload<Order>> CreateOrder(CreateOrderCommand command, CancellationToken ct)
=> _commands.ProcessAsync<CreateOrderCommand, Order>(command, ct);
}
public class Query
{
private readonly IGraphQLQueryProcessor _queries;
public Query(IGraphQLQueryProcessor queries) => _queries = queries;
public Task<Order?> GetOrderById(Guid id, CancellationToken ct)
=> _queries.ProcessAsync<GetOrderByIdQuery, Order>(new GetOrderByIdQuery { OrderId = id }, ct);
}
Technical Documentation
Full reference, worked examples, and a detailed explanation of every place this package's design deviates from Cqrs.Rest (and why):
src/LenzEng.Utilities.Cqrs.GraphQL — GitLab
See the Packages Work Together
The sample project's README wires this package into the same movie-catalog sample Cqrs.Rest already uses — same handlers, two transports, running side by side in one process.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- LenzEng.Utilities.Cqrs (>= 0.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.4.0 | 39 | 7/15/2026 |