FluentGraphQL 1.0.2

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

FluentGraphQL

FluentGraphQL is a lightweight, fluent C# library for dynamically building GraphQL queries. It allows developers to construct queries using a clean, chainable syntax—perfect for strongly typed scenarios or custom query generation needs.

License: MIT NuGet

✨ Features

  • ✅ Fluent API to build queries and mutations
  • ✅ Nested field selection with arguments and aliases
  • ✅ Inline fragments and directives support (coming soon)
  • ✅ Easy integration in .NET applications
  • ✅ Lightweight and dependency-free (except System.Text.Json)
  • ✅ Built-in performance benchmarks — see results

🤝 Comparison

There is already a great alternative available: graphql-query-builder-dotnet by Charles Devandiere. This project is not meant to discredit or replace it.

FluentGraphQL simply explores a different architectural approach, with a focus on fluent chaining, dynamic nested field construction, and performance fine-tuning. It was born independently and out of curiosity and learning, not competition.

📦 Installation

You can install via NuGet (once published):

dotnet add package FluentGraphQL

🚀 Quick Start

public class Account
{
    public Guid Id { get; set; }
    public string SocietyName { get; set; }
    public Adresse Adresse { get; set; }
    public IEnumerable<Contact> Contacts { get; set; }
}

public class Contact
{
    public Guid Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
    public string PhoneNumber { get; set; }
    public IEnumerable<Task> Tasks { get; set; }
}

public class Task
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime? DueDate { get; set; }
}
var builder = new FluentGraphQL();

var name = "Paul";
var cities = new string[] { "Paris", "London", "Madrid", "New York" };

builder
    .AddVariable("firstName", GraphQLParameterType.STRING, name)
    .AddVariable("cities", GraphQLParameterType.STRING_ARRAY, cities)
    .AddQuery(new GraphQLQueryObject<Account>("accounts")
        .AddEveryFields()
        .AddCollectionField(
          account => account.Contacts,
          contact => contact
            .AddEveryFields()
            .AddCollectionField(
              c => c.Tasks,
              task => task.AddEveryFields()
            )
        )
        .WithArguments(new
        {
            where = new
            {
                and = new object[]
                {
                    new
                    {
                        city = new
                        {
                            @in = "cities"
                        }
                    },
                    new
                    {
                        contacts = new
                        {
                            firstName = new
                            {
                                eq = "firstName"
                            }
                        }
                    }
                }
            }
        }));

var result = yourapi.Query(builder.Request);

Resulting query:

query ($firstName: String!, $cities: [String]!) {
  accounts(
    where: {
      and: [
        { city: { in: $cities } }
        { contacts: { firstName: { eq: $firstName } } }
      ]
    }
  ) {
    id
    societyName
    contacts {
      id
      firstName
      lastName
      email
      phoneNumber
      tasks {
        id
        name
        description
        startDate
        endDate
      }
    }
  }
}

🧪 Testing

Tests are written with xUnit and cover query generation scenarios. To run:

dotnet test

📄 License

MIT — see the LICENSE file for details.

🙌 Contribution

Feel free to open issues or submit pull requests to improve the library!


FluentGraphQL is maintained by @Nayruuu.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.0.2 118 7/30/2025