Linq2GraphQL.Client 1.0.108-prerelease

This is a prerelease version of Linq2GraphQL.Client.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Linq2GraphQL.Client --version 1.0.108-prerelease
                    
NuGet\Install-Package Linq2GraphQL.Client -Version 1.0.108-prerelease
                    
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="Linq2GraphQL.Client" Version="1.0.108-prerelease" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Linq2GraphQL.Client" Version="1.0.108-prerelease" />
                    
Directory.Packages.props
<PackageReference Include="Linq2GraphQL.Client" />
                    
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 Linq2GraphQL.Client --version 1.0.108-prerelease
                    
#r "nuget: Linq2GraphQL.Client, 1.0.108-prerelease"
                    
#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 Linq2GraphQL.Client@1.0.108-prerelease
                    
#: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=Linq2GraphQL.Client&version=1.0.108-prerelease&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Linq2GraphQL.Client&version=1.0.108-prerelease&prerelease
                    
Install as a Cake Tool

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 you Include. Object fields you don't include stay null.
  • An Include path 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, and Select what 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 null object or list anywhere along a path gives null, or the default of a value type, instead of throwing: above, Items is null when the order has no Lines. When the operation itself returns null, ExecuteAsync returns null.
  • Every field it mentions is requested, including fields it only tests: o.Lines == null requests all scalar fields of Lines. 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. Write o.Lines.Select(l => l.ItemNumber).ToList() ?? new List<string>() for an empty list instead of null.

Results and errors

  • ExecuteAsync() returns the data and throws GraphQueryExecutionException when the response has GraphQL errors (.Errors lists them).
  • ExecuteWithResultAsync() returns GraphResult<T> with Data, Errors and Extensions instead 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() gives NextPageAsync() and GetAllPagesAsync().

More: https://linq2graphql.com/selecting-fields, https://linq2graphql.com/error-handling, https://linq2graphql.com/paging.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed