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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LenzEng.Utilities.Cqrs.GraphQL" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LenzEng.Utilities.Cqrs.GraphQL" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="LenzEng.Utilities.Cqrs.GraphQL" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LenzEng.Utilities.Cqrs.GraphQL --version 0.4.0
                    
#r "nuget: LenzEng.Utilities.Cqrs.GraphQL, 0.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LenzEng.Utilities.Cqrs.GraphQL@0.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LenzEng.Utilities.Cqrs.GraphQL&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=LenzEng.Utilities.Cqrs.GraphQL&version=0.4.0
                    
Install as a Cake Tool

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 to null; mutations get a NOT_FOUND-coded entry in CommandPayload.Errors.
  • Validation errors land in CommandPayload<TResult>.Errors when LenzEng.Utilities.Cqrs.FluentValidation's ValidateCommandException is 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 than Func<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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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