Linq2GraphQL.Client
1.0.110-prerelease
dotnet add package Linq2GraphQL.Client --version 1.0.110-prerelease
NuGet\Install-Package Linq2GraphQL.Client -Version 1.0.110-prerelease
<PackageReference Include="Linq2GraphQL.Client" Version="1.0.110-prerelease" />
<PackageVersion Include="Linq2GraphQL.Client" Version="1.0.110-prerelease" />
<PackageReference Include="Linq2GraphQL.Client" />
paket add Linq2GraphQL.Client --version 1.0.110-prerelease
#r "nuget: Linq2GraphQL.Client, 1.0.110-prerelease"
#:package Linq2GraphQL.Client@1.0.110-prerelease
#addin nuget:?package=Linq2GraphQL.Client&version=1.0.110-prerelease&prerelease
#tool nuget:?package=Linq2GraphQL.Client&version=1.0.110-prerelease&prerelease
Linq2GraphQL.Client
The runtime for typed GraphQL clients generated by Linq2GraphQL. You describe what to fetch with LINQ-style lambdas; the client turns them into a GraphQL query, sends it and deserializes the response.
Generate a client with the Linq2GraphQL.Generator dotnet tool. Its output folder also holds schema.graphql, the whole API in one file, and a README.md for that client.
Query
An operation returns a query builder. Nothing is sent until it is executed.
var order = await client.Query
.CustomerOrder(orderNumber: "1001")
.Select(o => new { o.OrderNumber, Items = o.Lines.Select(l => l.ItemNumber).ToList() })
.ExecuteAsync();
What is requested:
.Select(lambda)fetches exactly the fields the lambda reads, at any depth, and returns your shape. Prefer this when you need a few fields..Select()returns the generated types with every scalar field of the returned type, plus the objects youInclude. Object fields you don't include staynull.- An
Includepath fetches the scalar fields of its last object only:.Include(o => o.Lines.Select(l => l.Item))fetches the items, not the lines. Include each level you want. - Fields that take arguments are methods:
o.Lines(first: 10). - Mutations work the same way through
client.Mutation: build the input class, pass it, andSelectwhat the mutation returns.
Rules for the Select lambda
The lambda is used twice: the fields it reads decide what is requested, and then it runs, compiled, on the deserialized result.
- It is null-safe. A
nullobject or list anywhere along a path givesnull, or the default of a value type, instead of throwing: above,Itemsisnullwhen the order has noLines. When the operation itself returnsnull,ExecuteAsyncreturnsnull. - Every field it mentions is requested, including fields it only tests:
o.Lines == nullrequests all scalar fields ofLines. Null tests are not needed. - Method calls, constants and local variables run on the client and request nothing.
- In a nullable client,
!inside the lambda (o!.Head!.Number) only silences the compiler; at run time the lambda is null-safe anyway. - It is an expression tree, so C# rejects
?., collection expressions ([]) and statement bodies inside it. Writeo.Lines.Select(l => l.ItemNumber).ToList() ?? new List<string>()for an empty list instead ofnull.
Results and errors
ExecuteAsync()returns the data and throwsGraphQueryExecutionExceptionwhen the response has GraphQL errors (.Errorslists them).ExecuteWithResultAsync()returnsGraphResult<T>withData,ErrorsandExtensionsinstead of throwing.GetRequestAsync()returns the GraphQL text and variables without sending the query, useful to check what a lambda requests. With safe mode on (UseSafeMode), it first fetches the schema from the server once.- Operations that return
GraphCursorQuery<T>are cursor-paged:.Select(...).AsPager()givesNextPageAsync()andGetAllPagesAsync().
More: https://linq2graphql.com/selecting-fields, https://linq2graphql.com/error-handling, https://linq2graphql.com/paging.
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.Caching.Memory (>= 10.0.11)
- Microsoft.Extensions.Http (>= 10.0.11)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Linq2GraphQL.Client:
| Package | Downloads |
|---|---|
|
Linq2GraphQL.Client.Subscriptions
Linq2GraphQL Subscription support |
|
|
Linq2GraphQL.Client.AI
Agent mode for Linq2GraphQL: expose a scoped, validated GraphQL schema to AI agents |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.110-prerelease | 0 | 12/2/2026 |
| 1.0.108-prerelease | 0 | 12/2/2026 |
| 1.0.106-prerelease | 69 | 11/28/2026 |
| 1.0.102-prerelease | 113 | 11/25/2026 |
| 1.0.67-prerelease | 178 | 10/16/2026 |
| 1.0.60-prerelease | 115 | 10/15/2026 |
| 1.0.30-prerelease | 119 | 10/13/2026 |
| 1.0.22-prerelease | 140 | 9/8/2026 |
| 1.0.20-prerelease | 135 | 9/8/2026 |
| 1.0.4-prerelease | 139 | 9/3/2026 |
| 1.0.2-prerelease | 146 | 9/3/2026 |
| 0.13.127-prerelease | 176 | 4/21/2026 |
| 0.13.125-prerelease | 363 | 11/14/2025 |
| 0.13.123-prerelease | 283 | 11/6/2025 |
| 0.13.122-prerelease | 256 | 11/6/2025 |
| 0.13.116-prerelease | 257 | 10/7/2025 |
| 0.13.108-prerelease | 626 | 8/25/2025 |
| 0.13.106-prerelease | 355 | 8/25/2025 |
| 0.13.104-prerelease | 284 | 8/21/2025 |
| 0.12.64 | 3,171 | 11/1/2023 |