GraphQL.Query.Builder
3.0.0
dotnet add package GraphQL.Query.Builder --version 3.0.0
NuGet\Install-Package GraphQL.Query.Builder -Version 3.0.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="GraphQL.Query.Builder" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GraphQL.Query.Builder" Version="3.0.0" />
<PackageReference Include="GraphQL.Query.Builder" />
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 GraphQL.Query.Builder --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GraphQL.Query.Builder, 3.0.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 GraphQL.Query.Builder@3.0.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=GraphQL.Query.Builder&version=3.0.0
#tool nuget:?package=GraphQL.Query.Builder&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
GraphQL Query Builder .NET

A tool to build GraphQL query from a C# model.
See complete documentation here
See sample here
Upgrading from v2.x? See the migration guide.
Install
dotnet add package GraphQL.Query.Builder
Usage
Basic Query
IGraphQLField<Human> field = new GraphQLField<Human>("humans")
.AddArguments(new { id = "uE78f5hq" })
.AddField(h => h.FirstName)
.AddField(h => h.LastName)
.AddField(
h => h.HomePlanet,
sq => sq.AddField(p => p.Name)
)
.AddField<Human>(
h => h.Friends,
sq => sq
.AddField(f => f.FirstName)
.AddField(f => f.LastName)
);
string query = new GraphQLOperation(OperationType.Query)
.AddQuery(field)
.Build();
// Output:
// query{humans(id:"uE78f5hq"){FirstName LastName HomePlanet{Name} Friends{FirstName LastName}}}
Variables
var idVar = new GraphQLVariable("id", "ID!");
string query = new GraphQLOperation(OperationType.Query, "GetHuman")
.AddVariable(idVar)
.AddQuery(
new GraphQLField<Human>("human")
.AddArgument("id", idVar.Reference())
.AddField(h => h.FirstName)
.AddField(h => h.LastName))
.Build();
// Output:
// query GetHuman($id:ID!){human(id:$id){FirstName LastName}}
Directives
var showFriends = new GraphQLVariable("showFriends", "Boolean!");
new GraphQLField<Human>("human")
.AddField(h => h.FirstName)
.AddField<Human>(
h => h.Friends,
sq => sq.AddField(f => f.FirstName),
GraphQLDirective.Include(showFriends.Reference()));
// Field output:
// human{FirstName Friends @include(if:$showFriends){FirstName}}
Fragments
var nameFields = new GraphQLFragment("NameFields", "Human",
new GraphQLField<Human>("Human")
.AddField(h => h.FirstName)
.AddField(h => h.LastName));
string query = new GraphQLOperation(OperationType.Query)
.AddQuery(
new GraphQLField<Human>("hero").AddFragment(nameFields))
.AddQuery(
new GraphQLField<Human>("villain").AddFragment(nameFields))
.AddFragment(nameFields)
.Build();
// Output:
// query{hero{...NameFields} villain{...NameFields}} fragment NameFields on Human{FirstName LastName}
Multiple Root Fields
string query = new GraphQLOperation(OperationType.Query)
.AddQuery(new GraphQLField<Human>("hero").AddField(h => h.FirstName))
.AddQuery(new GraphQLField<Droid>("droid").AddArgument("id", 1).AddField(d => d.Name))
.Build();
// Output:
// query{hero{FirstName} droid(id:1){Name}}
Mutations
string mutation = new GraphQLOperation(OperationType.Mutation, "CreateHuman")
.AddQuery(
new GraphQLField<Human>("createHuman")
.AddArgument("name", "Luke")
.AddField(h => h.Id)
.AddField(h => h.FirstName))
.Build();
// Output:
// mutation CreateHuman{createHuman(name:"Luke"){Id FirstName}}
Options
// CamelCase field names
var options = new QueryOptions
{
Formatter = CamelCasePropertyNameFormatter.Format
};
new GraphQLField<Human>("human", options)
.AddField(h => h.FirstName);
// Field output: human{firstName}
// Control null property handling
var ignoreNullOptions = new QueryOptions
{
DefaultIgnoreCondition = QueryIgnoreCondition.WhenWritingNull
};
| Product | Versions 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. 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.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (7)
Showing the top 5 NuGet packages that depend on GraphQL.Query.Builder:
| Package | Downloads |
|---|---|
|
GraphQL.Client.Extensions
Extensions for GraphQL.Client to build graphQL queries from a C# model. |
|
|
AIC.Core.Data.GraphQL
Shared .NET library for Aerospace, Intelligence, and Cyber solutions. |
|
|
SharpPS.Sitecore.GraphQL.Client
Package Description |
|
|
CESMII.Opc.Ua.Cloud.Library.Client
CESMII fork of the OPC UA Cloud Library Client Class Library |
|
|
IkasAdminApiLibrary
ikas Admin API v2 için .NET istemci kütüphanesi. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 21 | 8/21/2026 |
| 2.2.1 | 413,271 | 10/28/2024 |
| 2.2.0 | 122,274 | 7/25/2024 |
| 2.1.0 | 3,309 | 7/22/2024 |
| 2.0.2 | 220,581 | 8/24/2023 |
| 2.0.1 | 374,885 | 9/5/2022 |
| 2.0.0 | 906,128 | 4/21/2022 |
| 1.6.0 | 59,232 | 4/4/2022 |
| 1.5.0 | 648 | 4/1/2022 |
| 1.4.0 | 697 | 3/30/2022 |
| 1.3.0 | 157,325 | 3/15/2022 |
| 1.2.1 | 459,471 | 1/5/2021 |
| 1.2.0 | 62,951 | 12/10/2020 |
| 1.1.3 | 1,059 | 12/10/2020 |
| 1.1.1 | 127,352 | 5/13/2020 |
| 1.0.1 | 8,418 | 5/13/2020 |
| 1.0.0 | 74,315 | 3/11/2020 |