Fluent.Unions.HotChocolate 1.1.0

dotnet add package Fluent.Unions.HotChocolate --version 1.1.0
                    
NuGet\Install-Package Fluent.Unions.HotChocolate -Version 1.1.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="Fluent.Unions.HotChocolate" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fluent.Unions.HotChocolate" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Fluent.Unions.HotChocolate" />
                    
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 Fluent.Unions.HotChocolate --version 1.1.0
                    
#r "nuget: Fluent.Unions.HotChocolate, 1.1.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 Fluent.Unions.HotChocolate@1.1.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=Fluent.Unions.HotChocolate&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Fluent.Unions.HotChocolate&version=1.1.0
                    
Install as a Cake Tool

Fluent.Unions

Fluent.Unions.HotChocolate

NuGet Downloads Publish Documentation

Lets HotChocolate resolvers return Result<T>, your own result type with a value (declared with [FluentResult<TError>]) and Option<T>. The schema shows T for a result and a nullable T for an option, and an error in a result is rethrown so HotChocolate's error handling and mutation conventions deal with it. It builds on Fluent.Unions and HotChocolate 16.

Installation

dotnet add package Fluent.Unions.HotChocolate

Usage

Register it once on the request executor builder.

using Fluent.Unions.HotChocolate;

builder.Services
    .AddGraphQL()
    .AddQueryType<Query>()
    .AddMutationType<Mutation>()
    .AddMutationConventions()
    .AddFluentUnions();

Return the unions from resolvers, also inside Task and ValueTask.

public class Query
{
    public Task<Result<Book>> GetBookAsync(int id, IBookStore store) => store.FindAsync(id);   // book(id: Int!): Book!

    public Option<Book> FindBook(string title, IBookStore store) => store.Search(title);       // findBook(title: String!): Book
}

An error in a result is thrown from the field, so it reaches error filters and mutation conventions as the original exception. An error that is not an exception, such as a record of your own result type, is thrown inside a ResultErrorException. A Result<Option<T>> field is a nullable T.

public class Mutation
{
    [Error<OutOfStockException>]
    public Result<Order> PlaceOrder(string sku, IOrders orders) => orders.Place(sku);
}

A ValidationErrors error becomes one GraphQL error per ValidationError, and a single ValidationError becomes one GraphQL error, with the member in extensions.member.

Documentation

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
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
1.1.0 97 11/22/2026
1.0.0 95 11/21/2026
0.3.0 105 11/20/2026