Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Publish
working-directory: docs/Linq2GraphQL.Docs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Create Release

on: [workflow_dispatch]
on: [ workflow_dispatch ]
jobs:
build:

Expand All @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- uses: dotnet/nbgv@master
id: nbgv
Expand Down
41 changes: 21 additions & 20 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.7.115" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.8.118" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="BlazorMonaco" Version="3.3.0" />
Expand All @@ -12,31 +12,32 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="HotChocolate.AspNetCore" Version="13.9.12" />
<PackageVersion Include="HotChocolate.Data" Version="13.9.12" />
<PackageVersion Include="HotChocolate.Types.Scalars" Version="13.9.12" />
<PackageVersion Include="HotChocolate.AspNetCore" Version="15.1.10" />
<PackageVersion Include="HotChocolate.Data" Version="15.1.10" />
<PackageVersion Include="HotChocolate.Types.Scalars" Version="15.1.10" />
<PackageVersion Include="HotChocolate.Types.Analyzers" Version="15.1.10" />
<PackageVersion Include="Macross.Json.Extensions" Version="3.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.9" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.9" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.9" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="System.CodeDom" Version="8.0.0" />
<PackageVersion Include="System.CodeDom" Version="9.0.9" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="System.Text.Json" Version="9.0.9" />
<PackageVersion Include="TabBlazor" Version="0.8.1.1-alpha" />
<PackageVersion Include="Websocket.Client" Version="5.1.2" />
<PackageVersion Include="Websocket.Client" Version="5.3.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2">
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
Expand Down
14 changes: 10 additions & 4 deletions Linq2GraphQL.sln
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartGG", "StartGG\StartGG.csproj", "{B59EEB8E-8B81-4470-9295-86DF27A769D2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nullable", "nullable", "{3D9B8FE2-6906-4190-9AB4-845BAB6E403C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nonnullable", "nonnullable", "{1F4F9593-3C19-4C2E-AF8C-C269659AA12A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -119,17 +123,19 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{AD8291B6-5979-4C43-B785-EAD4FF93C564} = {5BE1963B-E57D-4CF5-B03E-644D8F39B4D2}
{F412B4C3-F872-483C-A55D-B49782ACAAFE} = {5BE1963B-E57D-4CF5-B03E-644D8F39B4D2}
{F9EAFD31-9AF1-47DF-9C78-003C7AC67C5D} = {5BE1963B-E57D-4CF5-B03E-644D8F39B4D2}
{F0D6061C-3D3F-4323-AE4F-39737F5E2247} = {5BE1963B-E57D-4CF5-B03E-644D8F39B4D2}
{C1908816-34E7-4B41-9E39-2283C59DB017} = {5BE1963B-E57D-4CF5-B03E-644D8F39B4D2}
{8083E0AF-8429-4EA1-9BC9-8B6EE5EFB9B2} = {5BE1963B-E57D-4CF5-B03E-644D8F39B4D2}
{058B468F-CE72-4CFF-8847-87CEED642C4E} = {5BE1963B-E57D-4CF5-B03E-644D8F39B4D2}
{C0E1A444-A834-4FC0-8436-38066EA8D37D} = {F646B02D-53FC-4C88-8941-2255A2F4DAF6}
{A941BD4C-8B04-4273-AC0B-CF86D71D7E0B} = {884758A6-B667-4CA0-B186-AFB6331A24A5}
{3C66EF43-E66D-46DE-B2BB-434E7FC20487} = {884758A6-B667-4CA0-B186-AFB6331A24A5}
{B59EEB8E-8B81-4470-9295-86DF27A769D2} = {884758A6-B667-4CA0-B186-AFB6331A24A5}
{3D9B8FE2-6906-4190-9AB4-845BAB6E403C} = {5BE1963B-E57D-4CF5-B03E-644D8F39B4D2}
{1F4F9593-3C19-4C2E-AF8C-C269659AA12A} = {5BE1963B-E57D-4CF5-B03E-644D8F39B4D2}
{8083E0AF-8429-4EA1-9BC9-8B6EE5EFB9B2} = {3D9B8FE2-6906-4190-9AB4-845BAB6E403C}
{F0D6061C-3D3F-4323-AE4F-39737F5E2247} = {3D9B8FE2-6906-4190-9AB4-845BAB6E403C}
{AD8291B6-5979-4C43-B785-EAD4FF93C564} = {1F4F9593-3C19-4C2E-AF8C-C269659AA12A}
{F412B4C3-F872-483C-A55D-B49782ACAAFE} = {1F4F9593-3C19-4C2E-AF8C-C269659AA12A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {01DC7AB7-9900-4FCA-BACB-7DAAE825E25E}
Expand Down
50 changes: 35 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<div align='center'>

<img src=https://raw.githubusercontent.com/Linq2GraphQL/Linq2GraphQL.Client/main/Logo.svg alt="logo" width=100 height=100 />
Expand All @@ -13,9 +12,12 @@
</div>

# Introduction
Linq2GraphQL generates C# classes from the GraphQL schema and and togheter with the nuget package Linq2GraphQL.Client it makes it possible to query the server using Linq expressions.

Linq2GraphQL generates C# classes from the GraphQL schema and and togheter with the nuget package Linq2GraphQL.Client it
makes it possible to query the server using Linq expressions.

A simple query that will get the first 10 orders with the primitive properties of orders and the connected customer.

```cs
var orders = await sampleClient
.Query
Expand All @@ -26,6 +28,7 @@ var orders = await sampleClient
```

A example mutation where we add a new customer and return the Customer Id.

```cs
var customerId = await sampleClient
.Mutation
Expand All @@ -40,16 +43,19 @@ A example mutation where we add a new customer and return the Customer Id.
```

# Getting Started

## Generate Client code

There are two options to generate the client code from the GraphQL schema.
Use the online tool to <a href="https://linq2graphql.com/generate-client"> generate</a> or install Linq2GraphQL.Generator as a tool.
Use the online tool to <a href="https://linq2graphql.com/generate-client"> generate</a> or install
Linq2GraphQL.Generator as a tool.

Install/Update Tool:
Install/Update Tool:

dotnet tool update Linq2GraphQL.Generator -g --prerelease
Usage:

Usage:

Linq2GraphQL.Generator <endpoint> [options]

Arguments:
Expand All @@ -64,24 +70,29 @@ Install/Update Tool:
-es --enum-strategy If AddUnknownOption all enums will have an additional Unknown option
-nu --nullabel Nullable client [default: false]
-d --deprecated Include Deprecated as Obsolete

As an example:

Linq2GraphQL https://spacex-production.up.railway.app/ -c="SpaceXClient" -n="SpaceX" -o="Generated"

Would generate a client from url *https://spacex-production.up.railway.app/* with the name *SpaceXClient* in the namespace *SpaceX* to folder *Generated*
Would generate a client from url *https://spacex-production.up.railway.app/* with the name *SpaceXClient* in the
namespace *SpaceX* to folder *Generated*

## Add Nuget

Latest stable: [![Nuget](https://img.shields.io/nuget/v/Linq2GraphQL.Client.svg)](https://www.nuget.org/packages/Linq2GraphQL.Client)
Latest
stable: [![Nuget](https://img.shields.io/nuget/v/Linq2GraphQL.Client.svg)](https://www.nuget.org/packages/Linq2GraphQL.Client)
<br/>
Latest prerelease: [![Nuget](https://img.shields.io/nuget/vpre/Linq2GraphQL.Client.svg)](https://www.nuget.org/packages/Linq2GraphQL.Client)
Latest
prerelease: [![Nuget](https://img.shields.io/nuget/vpre/Linq2GraphQL.Client.svg)](https://www.nuget.org/packages/Linq2GraphQL.Client)

dotnet add package Linq2GraphQL.Client --prerelease

## Dependency Injection

The client adds a set of extensions to make it easier to add the client to dependency injection.
As an example this would add SpaceXClient to the container:

```cs
services
.SpaceXClient(x =>
Expand All @@ -94,15 +105,22 @@ services
httpClient.BaseAddress = new Uri("https://spacex-production.up.railway.app/");
});
```

## Safe Mode
Turning on *SafeMode* will make the client before the first request to do an introspection query to the endpoint. The schema will be used to make sure that any auto included properties are available. This is an advanced feature that require the endpoint to support introspection. By default safe mode is turned of.

Turning on *SafeMode* will make the client before the first request to do an introspection query to the endpoint. The
schema will be used to make sure that any auto included properties are available. This is an advanced feature that
require the endpoint to support introspection. By default safe mode is turned of.

# Acknowledgments
Linq2GraphQL is inspired by [GraphQLinq](https://github.com/Giorgi/GraphQLinq) , thank you [Giorgi](https://github.com/Giorgi)

Linq2GraphQL is inspired by [GraphQLinq](https://github.com/Giorgi/GraphQLinq) , thank
you [Giorgi](https://github.com/Giorgi)

## Contributing

Are you a developer looking to contribute to this project? Please see our [Developer Guide](DEVELOPER.md) for comprehensive information about:
Are you a developer looking to contribute to this project? Please see our [Developer Guide](DEVELOPER.md) for
comprehensive information about:

- T4 template development workflow
- Code generation system architecture
Expand All @@ -112,7 +130,9 @@ Are you a developer looking to contribute to this project? Please see our [Devel

## Development Workflow

**⚠️ Important for Developers:** When modifying T4 templates (`.tt` files), you must manually regenerate the corresponding `.cs` files using Visual Studio's "Run Custom Tool" feature. See [DEVELOPER.md](DEVELOPER.md) for detailed instructions.
**⚠️ Important for Developers:** When modifying T4 templates (`.tt` files), you must manually regenerate the
corresponding `.cs` files using Visual Studio's "Run Custom Tool" feature. See [DEVELOPER.md](DEVELOPER.md) for detailed
instructions.

[![Stargazers repo roster for @linq2graphql/linq2graphql.client](https://reporoster.com/stars/dark/linq2graphql/linq2graphql.client)](https://github.com/linq2graphql/linq2graphql.client/stargazers)

Expand Down
Loading