RevalQuery.Core 0.3.0

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

RevalQuery.Core

Type-safe async data fetching and caching library. Used by RevalQuery.Blazor.

Installation

// Server/Program.cs (for Blazor WebAssembly with prerendering)
builder.Services.AddRevalQuery();

// Client/Program.cs
builder.Services.AddRevalQuery();

Table of Contents


QueryClient

Main entry point for query management.

public sealed class QueryClient
{
    // Subscribe component to query - returns observer
    public QueryObserver<TRes> Subscribe<TKey, TRes>(
        QueryOptions<TKey, TRes> options,
        Action onStateHasChanged
    );

    // Fire-and-forget prefetch
    public void PrefetchQuery<TKey, TRes>(QueryOptions<TKey, TRes> options);

    // Awaitable fetch - throws on error
    public async Task<TRes> FetchQueryAsync<TKey, TRes>(QueryOptions<TKey, TRes> options);

    // Invalidate cache
    public void Invalidate(ITuple key);
    public void Invalidate(string key);

    // Cancel in-flight fetch
    public void Cancel(ITuple key);
}

QueryOptions

Immutable query configuration.

// Create with fluent builder
var options = QueryOptions.Create(
    key: ("users",),
    handler: async static ctx => await ctx.ServiceProvider.GetRequiredService<IUserService>().GetAll()
);

// Extend configuration
options.ConfigureFetch(f => f.StaleTime(TimeSpan.FromMinutes(5)));
options.ConfigureRetry(r => r.Retry(3));
options.ConfigureCache(c => c.GcTime(TimeSpan.FromMinutes(10)));
options.Enabled(true);

MutationOptions

Configuration for write operations. Supports callbacks.

var mutationOptions = MutationOptions.Create<CreateUserRequest, User>(
    async static ctx => await ctx.ServiceProvider.GetRequiredService<IUserService>().CreateAsync(ctx.Params)
)
.OnResolved(async (user, req) => Console.WriteLine($"Created {user.Name}"))
.OnException(async (ex, req) => Console.WriteLine($"Error: {ex.Message}"))
.OnSettled(async (data, ex, req) => Console.WriteLine("Mutation complete"))
.ConfigureRetry(r => r.Retry(3));

QueryFactory Pattern

Standardized way to organize and reuse queries (ADR-016).

public static class UserQueries
{
    private const string Token = "users";

    // For invalidation
    public static (string, int) GetKey(int userId) => (Token, userId);

    // Returns builder - can be extended in components
    public static QueryOptionsBuilder<(string, int), User> GetUserOptions(int userId)
    {
        return QueryOptions.Create(
            key: (Token, userId),
            handler: async static ctx =>
                await ctx.ServiceProvider.GetRequiredService<IUserService>().GetByIdAsync(ctx.Key.Item2)
        );
    }
}

Usage:

// In component or QueryClient
var query = client.Subscribe(UserQueries.GetUserOptions(userId), OnStateChanged);

// For invalidation
client.Invalidate(UserQueries.GetKey(userId));

Configuration

Global options via RevalQueryOptions.

services.AddRevalQuery(options =>
{
    // Default fetch options (RefetchInterval, StaleTime)
    options.FetchOptions = new CoreFetchOptions(
        RefetchInterval: TimeSpan.FromMinutes(5),
        StaleTime: TimeSpan.FromMinutes(1)
    );

    // Default retry options
    options.RetryOptions = new CoreRetryOptions(3, attempt => TimeSpan.FromSeconds(attempt));

    // Cache TTL options
    options.CacheOptions = new CoreCacheOptions(
        GcTime: TimeSpan.FromMinutes(10),
        GcInterval: TimeSpan.FromMinutes(2)
    );

    // Add plugins
    options.QueryPluginsPipeline.Add(new MyPlugin());
});

Plugin System

Extensibility via IQueryPlugin middleware.

public class MyPlugin : IQueryPlugin
{
    public QueryOptions<TKey, TRes> OnQueryInitialize<TKey, TRes>(
        QueryOptions<TKey, TRes> options,
        Func<QueryOptions<TKey, TRes>, QueryOptions<TKey, TRes>> next
    )
    {
        // Transform or validate options
        return next(options);
    }
}

Built-in validation plugin:

// In development - enforces static handlers
services.AddSingleton<IQueryPlugin, QueryPluginHandlersStatelessValidation>();

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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 (1)

Showing the top 1 NuGet packages that depend on RevalQuery.Core:

Package Downloads
RevalQuery.Blazor

A high-performance, Result-oriented data fetching and state management library for Blazor. Heavily inspired by TanStack Query, featuring strongly-typed Trie-based caching, stateless handlers, and built-in support for CQRS architectures.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 84 5/7/2026
0.2.0 114 4/8/2026
0.1.3 123 3/25/2026
0.1.2 116 3/24/2026
0.1.1 118 3/24/2026