diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 121c0efa..95d15b9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0da54c05..38e50cf2 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52a1797b..61aa3e78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,6 @@ name: Create Release -on: [workflow_dispatch] +on: [ workflow_dispatch ] jobs: build: @@ -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 diff --git a/Directory.Packages.props b/Directory.Packages.props index ca66cbd4..5b085587 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,7 +3,7 @@ true - + @@ -12,31 +12,32 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + + - + - + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Linq2GraphQL.sln b/Linq2GraphQL.sln index 2bcddff9..f8b71272 100644 --- a/Linq2GraphQL.sln +++ b/Linq2GraphQL.sln @@ -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 @@ -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} diff --git a/README.md b/README.md index 8079bb45..2ff42a6e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -
logo @@ -13,9 +12,12 @@
# 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 @@ -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 @@ -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 generate or install Linq2GraphQL.Generator as a tool. +Use the online tool to generate or install +Linq2GraphQL.Generator as a tool. -Install/Update Tool: +Install/Update Tool: dotnet tool update Linq2GraphQL.Generator -g --prerelease - - Usage: - + +Usage: + Linq2GraphQL.Generator [options] Arguments: @@ -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)
-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 => @@ -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 @@ -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) diff --git a/StartGG/Client/Generated/Client/MutationMethods.cs b/StartGG/Client/Generated/Client/MutationMethods.cs index e0f00f0d..fdd44076 100644 --- a/StartGG/Client/Generated/Client/MutationMethods.cs +++ b/StartGG/Client/Generated/Client/MutationMethods.cs @@ -5,8 +5,6 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System.Collections.Generic; -using System; using Linq2GraphQL.Client; namespace StartGG.Client; @@ -22,192 +20,172 @@ public MutationMethods(GraphClient client) public GraphQuery DeletePhase(ID phaseId) { - var arguments = new List - { - new("phaseId","ID!", phaseId), - }; + var arguments = new List { new("phaseId", "ID!", phaseId) }; - return new GraphQuery(client, "deletePhase", OperationType.Mutation, arguments); + return new(client, "deletePhase", OperationType.Mutation, arguments); } public GraphQuery DeleteStation(ID stationId) { - var arguments = new List - { - new("stationId","ID!", stationId), - }; + var arguments = new List { new("stationId", "ID!", stationId) }; - return new GraphQuery(client, "deleteStation", OperationType.Mutation, arguments); + return new(client, "deleteStation", OperationType.Mutation, arguments); } public GraphQuery DeleteWave(ID waveId) { - var arguments = new List - { - new("waveId","ID!", waveId), - }; + var arguments = new List { new("waveId", "ID!", waveId) }; - return new GraphQuery(client, "deleteWave", OperationType.Mutation, arguments); + return new(client, "deleteWave", OperationType.Mutation, arguments); } public GraphQuery GenerateRegistrationToken(TournamentRegistrationInput registration, ID userId) { - var arguments = new List + var arguments = new List { - new("registration","TournamentRegistrationInput!", registration), - new("userId","ID!", userId), + new("registration", "TournamentRegistrationInput!", registration), new("userId", "ID!", userId) }; - return new GraphQuery(client, "generateRegistrationToken", OperationType.Mutation, arguments); + return new(client, "generateRegistrationToken", OperationType.Mutation, arguments); } public GraphQuery MarkSetCalled(ID setId) { - var arguments = new List - { - new("setId","ID!", setId), - }; + var arguments = new List { new("setId", "ID!", setId) }; - return new GraphQuery(client, "markSetCalled", OperationType.Mutation, arguments); + return new(client, "markSetCalled", OperationType.Mutation, arguments); } public GraphQuery MarkSetInProgress(ID setId) { - var arguments = new List - { - new("setId","ID!", setId), - }; + var arguments = new List { new("setId", "ID!", setId) }; - return new GraphQuery(client, "markSetInProgress", OperationType.Mutation, arguments); + return new(client, "markSetInProgress", OperationType.Mutation, arguments); } - public GraphQuery RegisterForTournament(TournamentRegistrationInput registration = null, string registrationToken = null) + public GraphQuery RegisterForTournament(TournamentRegistrationInput registration = null, + string registrationToken = null) { - var arguments = new List + var arguments = new List { - new("registration","TournamentRegistrationInput", registration), - new("registrationToken","String", registrationToken), + new("registration", "TournamentRegistrationInput", registration), + new("registrationToken", "String", registrationToken) }; - return new GraphQuery(client, "registerForTournament", OperationType.Mutation, arguments); + return new(client, "registerForTournament", OperationType.Mutation, arguments); } - public GraphQuery> ReportBracketSet(ID setId, ID winnerId = null, bool? isDQ = null, List gameData = null) + public GraphQuery> ReportBracketSet(ID setId, ID winnerId = null, bool? isDQ = null, + List gameData = null) { - var arguments = new List + var arguments = new List { - new("setId","ID!", setId), - new("winnerId","ID", winnerId), - new("isDQ","Boolean", isDQ), - new("gameData","[BracketSetGameDataInput]", gameData), + new("setId", "ID!", setId), + new("winnerId", "ID", winnerId), + new("isDQ", "Boolean", isDQ), + new("gameData", "[BracketSetGameDataInput]", gameData) }; - return new GraphQuery>(client, "reportBracketSet", OperationType.Mutation, arguments); + return new(client, "reportBracketSet", OperationType.Mutation, arguments); } public GraphQuery ResetSet(ID setId, bool? resetDependentSets = null) { - var arguments = new List + var arguments = new List { - new("setId","ID!", setId), - new("resetDependentSets","Boolean", resetDependentSets), + new("setId", "ID!", setId), new("resetDependentSets", "Boolean", resetDependentSets) }; - return new GraphQuery(client, "resetSet", OperationType.Mutation, arguments); + return new(client, "resetSet", OperationType.Mutation, arguments); } public GraphQuery> ResolveScheduleConflicts(ID tournamentId, ResolveConflictsOptions options = null) { - var arguments = new List + var arguments = new List { - new("tournamentId","ID!", tournamentId), - new("options","ResolveConflictsOptions", options), + new("tournamentId", "ID!", tournamentId), new("options", "ResolveConflictsOptions", options) }; - return new GraphQuery>(client, "resolveScheduleConflicts", OperationType.Mutation, arguments); + return new(client, "resolveScheduleConflicts", OperationType.Mutation, arguments); } public GraphQuery> SwapSeeds(ID phaseId, ID seed1Id, ID seed2Id) { - var arguments = new List + var arguments = new List { - new("phaseId","ID!", phaseId), - new("seed1Id","ID!", seed1Id), - new("seed2Id","ID!", seed2Id), + new("phaseId", "ID!", phaseId), new("seed1Id", "ID!", seed1Id), new("seed2Id", "ID!", seed2Id) }; - return new GraphQuery>(client, "swapSeeds", OperationType.Mutation, arguments); + return new(client, "swapSeeds", OperationType.Mutation, arguments); } - public GraphQuery UpdateBracketSet(ID setId, ID winnerId = null, bool? isDQ = null, List gameData = null) + public GraphQuery UpdateBracketSet(ID setId, ID winnerId = null, bool? isDQ = null, + List gameData = null) { - var arguments = new List + var arguments = new List { - new("setId","ID!", setId), - new("winnerId","ID", winnerId), - new("isDQ","Boolean", isDQ), - new("gameData","[BracketSetGameDataInput]", gameData), + new("setId", "ID!", setId), + new("winnerId", "ID", winnerId), + new("isDQ", "Boolean", isDQ), + new("gameData", "[BracketSetGameDataInput]", gameData) }; - return new GraphQuery(client, "updateBracketSet", OperationType.Mutation, arguments); + return new(client, "updateBracketSet", OperationType.Mutation, arguments); } public GraphQuery> UpdatePhaseGroups(List groupConfigs) { - var arguments = new List - { - new("groupConfigs","[PhaseGroupUpdateInput]!", groupConfigs), - }; + var arguments = new List { new("groupConfigs", "[PhaseGroupUpdateInput]!", groupConfigs) }; - return new GraphQuery>(client, "updatePhaseGroups", OperationType.Mutation, arguments); + return new(client, "updatePhaseGroups", OperationType.Mutation, arguments); } - public GraphQuery UpdatePhaseSeeding(ID phaseId, List seedMapping, UpdatePhaseSeedingOptions options = null) + public GraphQuery UpdatePhaseSeeding(ID phaseId, List seedMapping, + UpdatePhaseSeedingOptions options = null) { - var arguments = new List + var arguments = new List { - new("phaseId","ID!", phaseId), - new("seedMapping","[UpdatePhaseSeedInfo]!", seedMapping), - new("options","UpdatePhaseSeedingOptions", options), + new("phaseId", "ID!", phaseId), + new("seedMapping", "[UpdatePhaseSeedInfo]!", seedMapping), + new("options", "UpdatePhaseSeedingOptions", options) }; - return new GraphQuery(client, "updatePhaseSeeding", OperationType.Mutation, arguments); + return new(client, "updatePhaseSeeding", OperationType.Mutation, arguments); } public GraphQuery UpsertPhase(PhaseUpsertInput payload, ID phaseId = null, ID eventId = null) { - var arguments = new List + var arguments = new List { - new("phaseId","ID", phaseId), - new("eventId","ID", eventId), - new("payload","PhaseUpsertInput!", payload), + new("phaseId", "ID", phaseId), + new("eventId", "ID", eventId), + new("payload", "PhaseUpsertInput!", payload) }; - return new GraphQuery(client, "upsertPhase", OperationType.Mutation, arguments); + return new(client, "upsertPhase", OperationType.Mutation, arguments); } public GraphQuery UpsertStation(StationUpsertInput fields, ID stationId = null, ID tournamentId = null) { - var arguments = new List + var arguments = new List { - new("stationId","ID", stationId), - new("tournamentId","ID", tournamentId), - new("fields","StationUpsertInput!", fields), + new("stationId", "ID", stationId), + new("tournamentId", "ID", tournamentId), + new("fields", "StationUpsertInput!", fields) }; - return new GraphQuery(client, "upsertStation", OperationType.Mutation, arguments); + return new(client, "upsertStation", OperationType.Mutation, arguments); } public GraphQuery UpsertWave(WaveUpsertInput fields, ID waveId = null, ID tournamentId = null) { - var arguments = new List + var arguments = new List { - new("waveId","ID", waveId), - new("tournamentId","ID", tournamentId), - new("fields","WaveUpsertInput!", fields), + new("waveId", "ID", waveId), + new("tournamentId", "ID", tournamentId), + new("fields", "WaveUpsertInput!", fields) }; - return new GraphQuery(client, "upsertWave", OperationType.Mutation, arguments); - } - + return new(client, "upsertWave", OperationType.Mutation, arguments); } +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Client/StartGGClient.cs b/StartGG/Client/Generated/Client/StartGGClient.cs index 3f395ddd..e55eb4b1 100644 --- a/StartGG/Client/Generated/Client/StartGGClient.cs +++ b/StartGG/Client/Generated/Client/StartGGClient.cs @@ -6,22 +6,21 @@ //--------------------------------------------------------------------- using Linq2GraphQL.Client; -using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace StartGG.Client; public class StartGGClient -{ - public StartGGClient(HttpClient httpClient, [FromKeyedServices("StartGGClient")]IOptions options, IServiceProvider provider) +{ + public StartGGClient(HttpClient httpClient, + [FromKeyedServices("StartGGClient")] IOptions options, IServiceProvider provider) { - var client = new GraphClient(httpClient, options, provider, false); - Query = new QueryMethods(client); - Mutation = new MutationMethods(client); + var client = new GraphClient(httpClient, options, provider); + Query = new(client); + Mutation = new(client); } public QueryMethods Query { get; private set; } public MutationMethods Mutation { get; private set; } - } \ No newline at end of file diff --git a/StartGG/Client/Generated/Client/StartGGClientExtensions.cs b/StartGG/Client/Generated/Client/StartGGClientExtensions.cs index bbec8195..1215cd4f 100644 --- a/StartGG/Client/Generated/Client/StartGGClientExtensions.cs +++ b/StartGG/Client/Generated/Client/StartGGClientExtensions.cs @@ -11,21 +11,22 @@ namespace StartGG.Client; -public static class StartGGClientExtensions +public static class StartGGClientExtensions { private const string ClientName = "StartGGClient"; - + public static IGraphClientBuilder AddStartGGClient(this IServiceCollection services) { var graphClientOptions = new GraphClientOptions(); return GraphClientBuilder(services, graphClientOptions); } - - public static IGraphClientBuilder AddStartGGClient(this IServiceCollection services, Action opts) + + public static IGraphClientBuilder AddStartGGClient(this IServiceCollection services, + Action opts) { var graphClientOptions = new GraphClientOptions(); opts(graphClientOptions); - + return GraphClientBuilder(services, graphClientOptions); } @@ -33,8 +34,8 @@ private static IGraphClientBuilder GraphClientBuilder(IServiceCol GraphClientOptions graphClientOptions) { var opts = Options.Create(graphClientOptions); - services.AddKeyedSingleton(ClientName, opts); - services.AddMemoryCache(); + services.AddKeyedSingleton(ClientName, opts); + services.AddMemoryCache(); return new ClientBuilder(ClientName, services); } } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/ActivityState.cs b/StartGG/Client/Generated/Enums/ActivityState.cs index 920ed0ac..77a7ddae 100644 --- a/StartGG/Client/Generated/Enums/ActivityState.cs +++ b/StartGG/Client/Generated/Enums/ActivityState.cs @@ -5,27 +5,20 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum ActivityState { - [EnumMember(Value = "CREATED")] - Created, - [EnumMember(Value = "ACTIVE")] - Active, - [EnumMember(Value = "COMPLETED")] - Completed, - [EnumMember(Value = "READY")] - Ready, - [EnumMember(Value = "INVALID")] - Invalid, - [EnumMember(Value = "CALLED")] - Called, - [EnumMember(Value = "QUEUED")] - Queued, + [EnumMember(Value = "CREATED")] Created, + [EnumMember(Value = "ACTIVE")] Active, + [EnumMember(Value = "COMPLETED")] Completed, + [EnumMember(Value = "READY")] Ready, + [EnumMember(Value = "INVALID")] Invalid, + [EnumMember(Value = "CALLED")] Called, + [EnumMember(Value = "QUEUED")] Queued } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/AuthorizationType.cs b/StartGG/Client/Generated/Enums/AuthorizationType.cs index 6d103d77..e84a88bd 100644 --- a/StartGG/Client/Generated/Enums/AuthorizationType.cs +++ b/StartGG/Client/Generated/Enums/AuthorizationType.cs @@ -5,29 +5,21 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum AuthorizationType { - [EnumMember(Value = "TWITTER")] - Twitter, - [EnumMember(Value = "TWITCH")] - Twitch, - [EnumMember(Value = "STEAM")] - Steam, - [EnumMember(Value = "DISCORD")] - Discord, - [EnumMember(Value = "XBOX")] - Xbox, - [EnumMember(Value = "EPIC")] - Epic, - [EnumMember(Value = "BATTLENET")] - Battlenet, - [EnumMember(Value = "MIXER")] - Mixer, + [EnumMember(Value = "TWITTER")] Twitter, + [EnumMember(Value = "TWITCH")] Twitch, + [EnumMember(Value = "STEAM")] Steam, + [EnumMember(Value = "DISCORD")] Discord, + [EnumMember(Value = "XBOX")] Xbox, + [EnumMember(Value = "EPIC")] Epic, + [EnumMember(Value = "BATTLENET")] Battlenet, + [EnumMember(Value = "MIXER")] Mixer } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/BracketType.cs b/StartGG/Client/Generated/Enums/BracketType.cs index 3ebd453e..2aa030e7 100644 --- a/StartGG/Client/Generated/Enums/BracketType.cs +++ b/StartGG/Client/Generated/Enums/BracketType.cs @@ -5,9 +5,9 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; @@ -16,22 +16,19 @@ public enum BracketType { [EnumMember(Value = "SINGLE_ELIMINATION")] SingleElimination, + [EnumMember(Value = "DOUBLE_ELIMINATION")] DoubleElimination, - [EnumMember(Value = "ROUND_ROBIN")] - RoundRobin, - [EnumMember(Value = "SWISS")] - Swiss, - [EnumMember(Value = "EXHIBITION")] - Exhibition, + [EnumMember(Value = "ROUND_ROBIN")] RoundRobin, + [EnumMember(Value = "SWISS")] Swiss, + [EnumMember(Value = "EXHIBITION")] Exhibition, + [EnumMember(Value = "CUSTOM_SCHEDULE")] CustomSchedule, - [EnumMember(Value = "MATCHMAKING")] - Matchmaking, + [EnumMember(Value = "MATCHMAKING")] Matchmaking, + [EnumMember(Value = "ELIMINATION_ROUNDS")] EliminationRounds, - [EnumMember(Value = "RACE")] - Race, - [EnumMember(Value = "CIRCUIT")] - Circuit, + [EnumMember(Value = "RACE")] Race, + [EnumMember(Value = "CIRCUIT")] Circuit } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/Comparator.cs b/StartGG/Client/Generated/Enums/Comparator.cs index 5d82383f..d4e0e12f 100644 --- a/StartGG/Client/Generated/Enums/Comparator.cs +++ b/StartGG/Client/Generated/Enums/Comparator.cs @@ -5,23 +5,22 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum Comparator { - [EnumMember(Value = "GREATER_THAN")] - GreaterThan, + [EnumMember(Value = "GREATER_THAN")] GreaterThan, + [EnumMember(Value = "GREATER_THAN_OR_EQUAL")] GreaterThanOrEqual, - [EnumMember(Value = "EQUAL")] - Equal, + [EnumMember(Value = "EQUAL")] Equal, + [EnumMember(Value = "LESS_THAN_OR_EQUAL")] LessThanOrEqual, - [EnumMember(Value = "LESS_THAN")] - LessThan, + [EnumMember(Value = "LESS_THAN")] LessThan } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/GameSelectionType.cs b/StartGG/Client/Generated/Enums/GameSelectionType.cs index 45f819e7..1118ac2d 100644 --- a/StartGG/Client/Generated/Enums/GameSelectionType.cs +++ b/StartGG/Client/Generated/Enums/GameSelectionType.cs @@ -5,15 +5,14 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum GameSelectionType { - [EnumMember(Value = "CHARACTER")] - Character, + [EnumMember(Value = "CHARACTER")] Character } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/MatchConfigVerificationMethod.cs b/StartGG/Client/Generated/Enums/MatchConfigVerificationMethod.cs index fefd6d1a..0fc18384 100644 --- a/StartGG/Client/Generated/Enums/MatchConfigVerificationMethod.cs +++ b/StartGG/Client/Generated/Enums/MatchConfigVerificationMethod.cs @@ -5,23 +5,18 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum MatchConfigVerificationMethod { - [EnumMember(Value = "TWITCH")] - Twitch, - [EnumMember(Value = "STREAM_ME")] - StreamMe, - [EnumMember(Value = "ANY")] - Any, - [EnumMember(Value = "MIXER")] - Mixer, - [EnumMember(Value = "YOUTUBE")] - Youtube, + [EnumMember(Value = "TWITCH")] Twitch, + [EnumMember(Value = "STREAM_ME")] StreamMe, + [EnumMember(Value = "ANY")] Any, + [EnumMember(Value = "MIXER")] Mixer, + [EnumMember(Value = "YOUTUBE")] Youtube } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/SetSortType.cs b/StartGG/Client/Generated/Enums/SetSortType.cs index 42a5c79e..a7974859 100644 --- a/StartGG/Client/Generated/Enums/SetSortType.cs +++ b/StartGG/Client/Generated/Enums/SetSortType.cs @@ -5,25 +5,19 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum SetSortType { - [EnumMember(Value = "NONE")] - None, - [EnumMember(Value = "CALL_ORDER")] - CallOrder, - [EnumMember(Value = "MAGIC")] - Magic, - [EnumMember(Value = "RECENT")] - Recent, - [EnumMember(Value = "STANDARD")] - Standard, - [EnumMember(Value = "ROUND")] - Round, + [EnumMember(Value = "NONE")] None, + [EnumMember(Value = "CALL_ORDER")] CallOrder, + [EnumMember(Value = "MAGIC")] Magic, + [EnumMember(Value = "RECENT")] Recent, + [EnumMember(Value = "STANDARD")] Standard, + [EnumMember(Value = "ROUND")] Round } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/SocialConnectionType.cs b/StartGG/Client/Generated/Enums/SocialConnectionType.cs index c51ab1d6..7a6a1de1 100644 --- a/StartGG/Client/Generated/Enums/SocialConnectionType.cs +++ b/StartGG/Client/Generated/Enums/SocialConnectionType.cs @@ -5,23 +5,18 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum SocialConnectionType { - [EnumMember(Value = "TWITTER")] - Twitter, - [EnumMember(Value = "TWITCH")] - Twitch, - [EnumMember(Value = "DISCORD")] - Discord, - [EnumMember(Value = "MIXER")] - Mixer, - [EnumMember(Value = "XBOX")] - Xbox, + [EnumMember(Value = "TWITTER")] Twitter, + [EnumMember(Value = "TWITCH")] Twitch, + [EnumMember(Value = "DISCORD")] Discord, + [EnumMember(Value = "MIXER")] Mixer, + [EnumMember(Value = "XBOX")] Xbox } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/StreamSource.cs b/StartGG/Client/Generated/Enums/StreamSource.cs index c35777dc..f24e995d 100644 --- a/StartGG/Client/Generated/Enums/StreamSource.cs +++ b/StartGG/Client/Generated/Enums/StreamSource.cs @@ -5,23 +5,18 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum StreamSource { - [EnumMember(Value = "TWITCH")] - Twitch, - [EnumMember(Value = "HITBOX")] - Hitbox, - [EnumMember(Value = "STREAMME")] - Streamme, - [EnumMember(Value = "MIXER")] - Mixer, - [EnumMember(Value = "YOUTUBE")] - Youtube, + [EnumMember(Value = "TWITCH")] Twitch, + [EnumMember(Value = "HITBOX")] Hitbox, + [EnumMember(Value = "STREAMME")] Streamme, + [EnumMember(Value = "MIXER")] Mixer, + [EnumMember(Value = "YOUTUBE")] Youtube } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/StreamType.cs b/StartGG/Client/Generated/Enums/StreamType.cs index 73c16c49..5bc66a11 100644 --- a/StartGG/Client/Generated/Enums/StreamType.cs +++ b/StartGG/Client/Generated/Enums/StreamType.cs @@ -5,19 +5,16 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum StreamType { - [EnumMember(Value = "TWITCH")] - Twitch, - [EnumMember(Value = "MIXER")] - Mixer, - [EnumMember(Value = "YOUTUBE")] - Youtube, + [EnumMember(Value = "TWITCH")] Twitch, + [EnumMember(Value = "MIXER")] Mixer, + [EnumMember(Value = "YOUTUBE")] Youtube } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/TeamMemberStatus.cs b/StartGG/Client/Generated/Enums/TeamMemberStatus.cs index c3ea17d7..9ad02cde 100644 --- a/StartGG/Client/Generated/Enums/TeamMemberStatus.cs +++ b/StartGG/Client/Generated/Enums/TeamMemberStatus.cs @@ -5,27 +5,20 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum TeamMemberStatus { - [EnumMember(Value = "UNKNOWN")] - Unknown, - [EnumMember(Value = "ACCEPTED")] - Accepted, - [EnumMember(Value = "INVITED")] - Invited, - [EnumMember(Value = "REQUEST")] - Request, - [EnumMember(Value = "ALUM")] - Alum, - [EnumMember(Value = "HIATUS")] - Hiatus, - [EnumMember(Value = "OPEN_SPOT")] - OpenSpot, + [EnumMember(Value = "UNKNOWN")] Unknown, + [EnumMember(Value = "ACCEPTED")] Accepted, + [EnumMember(Value = "INVITED")] Invited, + [EnumMember(Value = "REQUEST")] Request, + [EnumMember(Value = "ALUM")] Alum, + [EnumMember(Value = "HIATUS")] Hiatus, + [EnumMember(Value = "OPEN_SPOT")] OpenSpot } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/TeamMemberType.cs b/StartGG/Client/Generated/Enums/TeamMemberType.cs index 46087d29..4678b2fe 100644 --- a/StartGG/Client/Generated/Enums/TeamMemberType.cs +++ b/StartGG/Client/Generated/Enums/TeamMemberType.cs @@ -5,17 +5,15 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum TeamMemberType { - [EnumMember(Value = "PLAYER")] - Player, - [EnumMember(Value = "STAFF")] - Staff, + [EnumMember(Value = "PLAYER")] Player, + [EnumMember(Value = "STAFF")] Staff } \ No newline at end of file diff --git a/StartGG/Client/Generated/Enums/TournamentPaginationSort.cs b/StartGG/Client/Generated/Enums/TournamentPaginationSort.cs index c464b898..c5928c76 100644 --- a/StartGG/Client/Generated/Enums/TournamentPaginationSort.cs +++ b/StartGG/Client/Generated/Enums/TournamentPaginationSort.cs @@ -5,21 +5,21 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(JsonStringEnumMemberConverter))] public enum TournamentPaginationSort { - [EnumMember(Value = "startAt")] - Startat, - [EnumMember(Value = "endAt")] - Endat, + [EnumMember(Value = "startAt")] Startat, + [EnumMember(Value = "endAt")] Endat, + [EnumMember(Value = "eventRegistrationClosesAt")] Eventregistrationclosesat, + [EnumMember(Value = "computedUpdatedAt")] - Computedupdatedat, + Computedupdatedat } \ No newline at end of file diff --git a/StartGG/Client/Generated/Inputs/EventEntrantPageQueryFilter.cs b/StartGG/Client/Generated/Inputs/EventEntrantPageQueryFilter.cs index 56af9308..b00ef5a5 100644 --- a/StartGG/Client/Generated/Inputs/EventEntrantPageQueryFilter.cs +++ b/StartGG/Client/Generated/Inputs/EventEntrantPageQueryFilter.cs @@ -5,22 +5,19 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(GraphInputConverter))] -public partial class EventEntrantPageQueryFilter : GraphInputBase +public class EventEntrantPageQueryFilter : GraphInputBase { - [GraphQLMember("name")] - [JsonPropertyName("name")] - public string Name - { - get => GetValue("name"); - set => SetValue("name", value); - } - + [GraphQLMember("name")] + [JsonPropertyName("name")] + public string Name + { + get => GetValue("name"); + set => SetValue("name", value); + } } \ No newline at end of file diff --git a/StartGG/Client/Generated/Inputs/PhaseGroupPageQueryFilter.cs b/StartGG/Client/Generated/Inputs/PhaseGroupPageQueryFilter.cs index 818f8fea..9b5b3796 100644 --- a/StartGG/Client/Generated/Inputs/PhaseGroupPageQueryFilter.cs +++ b/StartGG/Client/Generated/Inputs/PhaseGroupPageQueryFilter.cs @@ -5,30 +5,27 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(GraphInputConverter))] -public partial class PhaseGroupPageQueryFilter : GraphInputBase +public class PhaseGroupPageQueryFilter : GraphInputBase { - [GraphQLMember("id")] - [JsonPropertyName("id")] - public List Id - { - get => GetValue>("id"); - set => SetValue("id", value); - } - - [GraphQLMember("waveId")] - [JsonPropertyName("waveId")] - public ID WaveId - { - get => GetValue("waveId"); - set => SetValue("waveId", value); - } + [GraphQLMember("id")] + [JsonPropertyName("id")] + public List Id + { + get => GetValue>("id"); + set => SetValue("id", value); + } + [GraphQLMember("waveId")] + [JsonPropertyName("waveId")] + public ID WaveId + { + get => GetValue("waveId"); + set => SetValue("waveId", value); + } } \ No newline at end of file diff --git a/StartGG/Client/Generated/Inputs/ShopOrderMessagesQuery.cs b/StartGG/Client/Generated/Inputs/ShopOrderMessagesQuery.cs index 272452f6..6e8574a1 100644 --- a/StartGG/Client/Generated/Inputs/ShopOrderMessagesQuery.cs +++ b/StartGG/Client/Generated/Inputs/ShopOrderMessagesQuery.cs @@ -5,38 +5,35 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(GraphInputConverter))] -public partial class ShopOrderMessagesQuery : GraphInputBase +public class ShopOrderMessagesQuery : GraphInputBase { - [GraphQLMember("page")] - [JsonPropertyName("page")] - public int? Page - { - get => GetValue("page"); - set => SetValue("page", value); - } + [GraphQLMember("page")] + [JsonPropertyName("page")] + public int? Page + { + get => GetValue("page"); + set => SetValue("page", value); + } - [GraphQLMember("perPage")] - [JsonPropertyName("perPage")] - public int? PerPage - { - get => GetValue("perPage"); - set => SetValue("perPage", value); - } - - [GraphQLMember("sortBy")] - [JsonPropertyName("sortBy")] - public string SortBy - { - get => GetValue("sortBy"); - set => SetValue("sortBy", value); - } + [GraphQLMember("perPage")] + [JsonPropertyName("perPage")] + public int? PerPage + { + get => GetValue("perPage"); + set => SetValue("perPage", value); + } + [GraphQLMember("sortBy")] + [JsonPropertyName("sortBy")] + public string SortBy + { + get => GetValue("sortBy"); + set => SetValue("sortBy", value); + } } \ No newline at end of file diff --git a/StartGG/Client/Generated/Inputs/TeamPaginationQuery.cs b/StartGG/Client/Generated/Inputs/TeamPaginationQuery.cs index 9aa2c66d..be89d978 100644 --- a/StartGG/Client/Generated/Inputs/TeamPaginationQuery.cs +++ b/StartGG/Client/Generated/Inputs/TeamPaginationQuery.cs @@ -5,46 +5,43 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(GraphInputConverter))] -public partial class TeamPaginationQuery : GraphInputBase +public class TeamPaginationQuery : GraphInputBase { - [GraphQLMember("page")] - [JsonPropertyName("page")] - public int? Page - { - get => GetValue("page"); - set => SetValue("page", value); - } + [GraphQLMember("page")] + [JsonPropertyName("page")] + public int? Page + { + get => GetValue("page"); + set => SetValue("page", value); + } - [GraphQLMember("perPage")] - [JsonPropertyName("perPage")] - public int? PerPage - { - get => GetValue("perPage"); - set => SetValue("perPage", value); - } + [GraphQLMember("perPage")] + [JsonPropertyName("perPage")] + public int? PerPage + { + get => GetValue("perPage"); + set => SetValue("perPage", value); + } - [GraphQLMember("sortBy")] - [JsonPropertyName("sortBy")] - public string SortBy - { - get => GetValue("sortBy"); - set => SetValue("sortBy", value); - } - - [GraphQLMember("filter")] - [JsonPropertyName("filter")] - public TeamPaginationFilter Filter - { - get => GetValue("filter"); - set => SetValue("filter", value); - } + [GraphQLMember("sortBy")] + [JsonPropertyName("sortBy")] + public string SortBy + { + get => GetValue("sortBy"); + set => SetValue("sortBy", value); + } + [GraphQLMember("filter")] + [JsonPropertyName("filter")] + public TeamPaginationFilter Filter + { + get => GetValue("filter"); + set => SetValue("filter", value); + } } \ No newline at end of file diff --git a/StartGG/Client/Generated/Inputs/WaveUpsertInput.cs b/StartGG/Client/Generated/Inputs/WaveUpsertInput.cs index 5a35e5df..ad8422a3 100644 --- a/StartGG/Client/Generated/Inputs/WaveUpsertInput.cs +++ b/StartGG/Client/Generated/Inputs/WaveUpsertInput.cs @@ -5,38 +5,35 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; namespace StartGG.Client; [JsonConverter(typeof(GraphInputConverter))] -public partial class WaveUpsertInput : GraphInputBase +public class WaveUpsertInput : GraphInputBase { - [GraphQLMember("identifier")] - [JsonPropertyName("identifier")] - public string Identifier - { - get => GetValue("identifier"); - set => SetValue("identifier", value); - } + [GraphQLMember("identifier")] + [JsonPropertyName("identifier")] + public string Identifier + { + get => GetValue("identifier"); + set => SetValue("identifier", value); + } - [GraphQLMember("startAt")] - [JsonPropertyName("startAt")] - public Timestamp StartAt - { - get => GetValue("startAt"); - set => SetValue("startAt", value); - } - - [GraphQLMember("endAt")] - [JsonPropertyName("endAt")] - public Timestamp EndAt - { - get => GetValue("endAt"); - set => SetValue("endAt", value); - } + [GraphQLMember("startAt")] + [JsonPropertyName("startAt")] + public Timestamp StartAt + { + get => GetValue("startAt"); + set => SetValue("startAt", value); + } + [GraphQLMember("endAt")] + [JsonPropertyName("endAt")] + public Timestamp EndAt + { + get => GetValue("endAt"); + set => SetValue("endAt", value); + } } \ No newline at end of file diff --git a/StartGG/Client/Generated/Interfaces/ActionSet.cs b/StartGG/Client/Generated/Interfaces/ActionSet.cs index 605db65f..98327579 100644 --- a/StartGG/Client/Generated/Interfaces/ActionSet.cs +++ b/StartGG/Client/Generated/Interfaces/ActionSet.cs @@ -5,7 +5,6 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; @@ -16,8 +15,6 @@ namespace StartGG.Client; public static class ActionSetExtentions { - - [GraphInterface] public static TeamActionSet TeamActionSet(this ActionSet value) { @@ -25,39 +22,34 @@ public static TeamActionSet TeamActionSet(this ActionSet value) { return (TeamActionSet)value; } + return null; } } - internal class ActionSetConverter : InterfaceJsonConverter { - public override ActionSet Deserialize(string typeName, JsonObject json) => typeName switch + public override ActionSet Deserialize(string typeName, JsonObject json) { - "TeamActionSet" => json.Deserialize(), - _ => json.Deserialize< ActionSet__Concrete>() - }; + return typeName switch + { + "TeamActionSet" => json.Deserialize(), + _ => json.Deserialize() + }; + } } - - - [JsonConverter(typeof(ActionSetConverter))] -public interface ActionSet +public interface ActionSet { - [GraphQLMember("id")] - public ID Id { get; set; } - [GraphQLMember("__typename")] - public string __TypeName { get; set; } + [GraphQLMember("id")] public ID Id { get; set; } + [GraphQLMember("__typename")] public string __TypeName { get; set; } } internal class ActionSet__Concrete : ActionSet { - [GraphQLMember("id")] - public ID Id { get; set; } - - [GraphQLMember("__typename")] - public string __TypeName { get; set; } + [GraphQLMember("id")] public ID Id { get; set; } + [GraphQLMember("__typename")] public string __TypeName { get; set; } } \ No newline at end of file diff --git a/StartGG/Client/Generated/Interfaces/BracketConfig.cs b/StartGG/Client/Generated/Interfaces/BracketConfig.cs index 328672f9..dd607ef2 100644 --- a/StartGG/Client/Generated/Interfaces/BracketConfig.cs +++ b/StartGG/Client/Generated/Interfaces/BracketConfig.cs @@ -5,7 +5,6 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; @@ -16,8 +15,6 @@ namespace StartGG.Client; public static class BracketConfigExtentions { - - [GraphInterface] public static RaceBracketConfig RaceBracketConfig(this BracketConfig value) { @@ -25,43 +22,38 @@ public static RaceBracketConfig RaceBracketConfig(this BracketConfig value) { return (RaceBracketConfig)value; } + return null; } } - internal class BracketConfigConverter : InterfaceJsonConverter { - public override BracketConfig Deserialize(string typeName, JsonObject json) => typeName switch + public override BracketConfig Deserialize(string typeName, JsonObject json) { - "RaceBracketConfig" => json.Deserialize(), - _ => json.Deserialize< BracketConfig__Concrete>() - }; + return typeName switch + { + "RaceBracketConfig" => json.Deserialize(), + _ => json.Deserialize() + }; + } } - - - [JsonConverter(typeof(BracketConfigConverter))] -public interface BracketConfig +public interface BracketConfig { - [GraphQLMember("id")] - public ID Id { get; set; } - [GraphQLMember("bracketType")] - public BracketType? BracketType { get; set; } - [GraphQLMember("__typename")] - public string __TypeName { get; set; } + [GraphQLMember("id")] public ID Id { get; set; } + + [GraphQLMember("bracketType")] public BracketType? BracketType { get; set; } + [GraphQLMember("__typename")] public string __TypeName { get; set; } } internal class BracketConfig__Concrete : BracketConfig { - [GraphQLMember("id")] - public ID Id { get; set; } - [GraphQLMember("bracketType")] - public BracketType? BracketType { get; set; } + [GraphQLMember("id")] public ID Id { get; set; } - [GraphQLMember("__typename")] - public string __TypeName { get; set; } + [GraphQLMember("bracketType")] public BracketType? BracketType { get; set; } + [GraphQLMember("__typename")] public string __TypeName { get; set; } } \ No newline at end of file diff --git a/StartGG/Client/Generated/Interfaces/MatchConfig.cs b/StartGG/Client/Generated/Interfaces/MatchConfig.cs index 324d931b..038d2adc 100644 --- a/StartGG/Client/Generated/Interfaces/MatchConfig.cs +++ b/StartGG/Client/Generated/Interfaces/MatchConfig.cs @@ -5,7 +5,6 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; @@ -16,8 +15,6 @@ namespace StartGG.Client; public static class MatchConfigExtentions { - - [GraphInterface] public static RaceMatchConfig RaceMatchConfig(this MatchConfig value) { @@ -25,43 +22,38 @@ public static RaceMatchConfig RaceMatchConfig(this MatchConfig value) { return (RaceMatchConfig)value; } + return null; } } - internal class MatchConfigConverter : InterfaceJsonConverter { - public override MatchConfig Deserialize(string typeName, JsonObject json) => typeName switch + public override MatchConfig Deserialize(string typeName, JsonObject json) { - "RaceMatchConfig" => json.Deserialize(), - _ => json.Deserialize< MatchConfig__Concrete>() - }; + return typeName switch + { + "RaceMatchConfig" => json.Deserialize(), + _ => json.Deserialize() + }; + } } - - - [JsonConverter(typeof(MatchConfigConverter))] -public interface MatchConfig +public interface MatchConfig { - [GraphQLMember("id")] - public ID Id { get; set; } - [GraphQLMember("bracketType")] - public BracketType? BracketType { get; set; } - [GraphQLMember("__typename")] - public string __TypeName { get; set; } + [GraphQLMember("id")] public ID Id { get; set; } + + [GraphQLMember("bracketType")] public BracketType? BracketType { get; set; } + [GraphQLMember("__typename")] public string __TypeName { get; set; } } internal class MatchConfig__Concrete : MatchConfig { - [GraphQLMember("id")] - public ID Id { get; set; } - [GraphQLMember("bracketType")] - public BracketType? BracketType { get; set; } + [GraphQLMember("id")] public ID Id { get; set; } - [GraphQLMember("__typename")] - public string __TypeName { get; set; } + [GraphQLMember("bracketType")] public BracketType? BracketType { get; set; } + [GraphQLMember("__typename")] public string __TypeName { get; set; } } \ No newline at end of file diff --git a/StartGG/Client/Generated/Scalars/ID.cs b/StartGG/Client/Generated/Scalars/ID.cs index 8b38c077..3f303b56 100644 --- a/StartGG/Client/Generated/Scalars/ID.cs +++ b/StartGG/Client/Generated/Scalars/ID.cs @@ -6,15 +6,17 @@ //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; - /// - /// The `ID` scalar type represents a unique identifier, often used to -/// refetch an object or as key for a cache. When expected as an input type, any string (such as `"4"`) or integer -/// (such as `4`) input value will be accepted as an ID. - /// - [JsonConverter(typeof(CustomScalarConverter))] - public partial class ID : CustomScalar {} \ No newline at end of file +/// +/// The `ID` scalar type represents a unique identifier, often used to +/// refetch an object or as key for a cache. When expected as an input type, any string (such as `"4"`) or integer +/// (such as `4`) input value will be accepted as an ID. +/// +[JsonConverter(typeof(CustomScalarConverter))] +public class ID : CustomScalar +{ +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Scalars/JSON.cs b/StartGG/Client/Generated/Scalars/JSON.cs index 947223de..b61c5763 100644 --- a/StartGG/Client/Generated/Scalars/JSON.cs +++ b/StartGG/Client/Generated/Scalars/JSON.cs @@ -6,14 +6,16 @@ //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; - /// - /// The `JSON` scalar type represents JSON values as specified by -/// [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). - /// - [JsonConverter(typeof(CustomScalarConverter))] - public partial class JSON : CustomScalar {} \ No newline at end of file +/// +/// The `JSON` scalar type represents JSON values as specified by +/// [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). +/// +[JsonConverter(typeof(CustomScalarConverter))] +public class JSON : CustomScalar +{ +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Scalars/Timestamp.cs b/StartGG/Client/Generated/Scalars/Timestamp.cs index 13555198..e1da00f5 100644 --- a/StartGG/Client/Generated/Scalars/Timestamp.cs +++ b/StartGG/Client/Generated/Scalars/Timestamp.cs @@ -6,14 +6,16 @@ //--------------------------------------------------------------------- -using Linq2GraphQL.Client; using System.Text.Json.Serialization; +using Linq2GraphQL.Client; namespace StartGG.Client; - /// - /// Represents a Unix Timestamp. Supports up to 53 bit int values, -/// as that is JavaScript's internal memory allocation for integer values. - /// - [JsonConverter(typeof(CustomScalarConverter))] - public partial class Timestamp : CustomScalar {} \ No newline at end of file +/// +/// Represents a Unix Timestamp. Supports up to 53 bit int values, +/// as that is JavaScript's internal memory allocation for integer values. +/// +[JsonConverter(typeof(CustomScalarConverter))] +public class Timestamp : CustomScalar +{ +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/Address.cs b/StartGG/Client/Generated/Types/Address.cs index e3e765cd..b67b73b5 100644 --- a/StartGG/Client/Generated/Types/Address.cs +++ b/StartGG/Client/Generated/Types/Address.cs @@ -5,19 +5,16 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - /// -/// A user's address +/// A user's address /// -public partial class Address : GraphQLTypeBase +public class Address : GraphQLTypeBase { [GraphQLMember("id")] [JsonPropertyName("id")] @@ -42,5 +39,4 @@ public partial class Address : GraphQLTypeBase [GraphQLMember("stateId")] [JsonPropertyName("stateId")] public int? StateId { get; set; } - -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/ContactInfo.cs b/StartGG/Client/Generated/Types/ContactInfo.cs index cc5b37d1..b70175c5 100644 --- a/StartGG/Client/Generated/Types/ContactInfo.cs +++ b/StartGG/Client/Generated/Types/ContactInfo.cs @@ -5,40 +5,37 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - /// -/// Name, address, etc +/// Name, address, etc /// -public partial class ContactInfo : GraphQLTypeBase +public class ContactInfo : GraphQLTypeBase { [GraphQLMember("id")] [JsonPropertyName("id")] public ID Id { get; set; } /// - /// Participant City Name + /// Participant City Name /// [GraphQLMember("city")] [JsonPropertyName("city")] public string City { get; set; } /// - /// Participant Country Name + /// Participant Country Name /// [GraphQLMember("country")] [JsonPropertyName("country")] public string Country { get; set; } /// - /// Participant Country (region) id + /// Participant Country (region) id /// [GraphQLMember("countryId")] [JsonPropertyName("countryId")] @@ -49,38 +46,37 @@ public partial class ContactInfo : GraphQLTypeBase public string Name { get; set; } /// - /// First Name + /// First Name /// [GraphQLMember("nameFirst")] [JsonPropertyName("nameFirst")] public string NameFirst { get; set; } /// - /// Last Name + /// Last Name /// [GraphQLMember("nameLast")] [JsonPropertyName("nameLast")] public string NameLast { get; set; } /// - /// Participant State Name + /// Participant State Name /// [GraphQLMember("state")] [JsonPropertyName("state")] public string State { get; set; } /// - /// Participant State (region) id + /// Participant State (region) id /// [GraphQLMember("stateId")] [JsonPropertyName("stateId")] public int? StateId { get; set; } /// - /// Zip or Postal Code + /// Zip or Postal Code /// [GraphQLMember("zipcode")] [JsonPropertyName("zipcode")] public string Zipcode { get; set; } - -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/EntrantConnection.cs b/StartGG/Client/Generated/Types/EntrantConnection.cs index f7dc74fb..3b590c74 100644 --- a/StartGG/Client/Generated/Types/EntrantConnection.cs +++ b/StartGG/Client/Generated/Types/EntrantConnection.cs @@ -5,23 +5,19 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - -public partial class EntrantConnection : GraphQLTypeBase, Linq2GraphQL.Client.Common.ICursorPaging +public class EntrantConnection : GraphQLTypeBase, ICursorPaging { - [GraphQLMember("pageInfo")] - [JsonPropertyName("pageInfo")] - public Linq2GraphQL.Client.Common.PageInfo PageInfo { get; set; } - [GraphQLMember("nodes")] [JsonPropertyName("nodes")] public List Nodes { get; set; } -} + [GraphQLMember("pageInfo")] + [JsonPropertyName("pageInfo")] + public PageInfo PageInfo { get; set; } +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/Phase.cs b/StartGG/Client/Generated/Types/Phase.cs index 6303ddab..13bca5c4 100644 --- a/StartGG/Client/Generated/Types/Phase.cs +++ b/StartGG/Client/Generated/Types/Phase.cs @@ -5,115 +5,121 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - public static class PhaseExtensions { [GraphQLMember("phaseGroups")] - public static PhaseGroupConnection PhaseGroups(this Phase phase, [GraphQLArgument("query", "PhaseGroupPageQuery")] PhaseGroupPageQuery query = null) + public static PhaseGroupConnection PhaseGroups(this Phase phase, + [GraphQLArgument("query", "PhaseGroupPageQuery")] PhaseGroupPageQuery query = null) { return phase.GetMethodValue("phaseGroups", query); } [GraphQLMember("seeds")] - public static SeedConnection Seeds(this Phase phase, [GraphQLArgument("query", "SeedPaginationQuery!")] SeedPaginationQuery query, [GraphQLArgument("eventId", "ID")] ID eventId = null) + public static SeedConnection Seeds(this Phase phase, + [GraphQLArgument("query", "SeedPaginationQuery!")] SeedPaginationQuery query, + [GraphQLArgument("eventId", "ID")] ID eventId = null) { return phase.GetMethodValue("seeds", query, eventId); } [GraphQLMember("sets")] - public static SetConnection Sets(this Phase phase, [GraphQLArgument("page", "Int")] int? page = null, [GraphQLArgument("perPage", "Int")] int? perPage = null, [GraphQLArgument("sortType", "SetSortType")] SetSortType? sortType = null, [GraphQLArgument("filters", "SetFilters")] SetFilters filters = null) + public static SetConnection Sets(this Phase phase, [GraphQLArgument("page", "Int")] int? page = null, + [GraphQLArgument("perPage", "Int")] int? perPage = null, + [GraphQLArgument("sortType", "SetSortType")] SetSortType? sortType = null, + [GraphQLArgument("filters", "SetFilters")] SetFilters filters = null) { return phase.GetMethodValue("sets", page, perPage, sortType, filters); } - } /// -/// A phase in an event +/// A phase in an event /// -public partial class Phase : GraphQLTypeBase +public class Phase : GraphQLTypeBase { + private readonly LazyProperty _phaseGroups = new(); + + private readonly LazyProperty _seeds = new(); + + private readonly LazyProperty _sets = new(); + [GraphQLMember("id")] [JsonPropertyName("id")] public ID Id { get; set; } /// - /// The bracket type of this phase. + /// The bracket type of this phase. /// [GraphQLMember("bracketType")] [JsonPropertyName("bracketType")] public BracketType? BracketType { get; set; } /// - /// The Event that this phase belongs to + /// The Event that this phase belongs to /// [GraphQLMember("event")] [JsonPropertyName("event")] public Event Event { get; set; } /// - /// Number of phase groups in this phase + /// Number of phase groups in this phase /// [GraphQLMember("groupCount")] [JsonPropertyName("groupCount")] public int? GroupCount { get; set; } /// - /// Is the phase an exhibition or not. + /// Is the phase an exhibition or not. /// [GraphQLMember("isExhibition")] [JsonPropertyName("isExhibition")] public bool? IsExhibition { get; set; } /// - /// Name of phase e.g. Round 1 Pools + /// Name of phase e.g. Round 1 Pools /// [GraphQLMember("name")] [JsonPropertyName("name")] public string Name { get; set; } /// - /// The number of seeds this phase contains. + /// The number of seeds this phase contains. /// [GraphQLMember("numSeeds")] [JsonPropertyName("numSeeds")] public int? NumSeeds { get; set; } - private LazyProperty _phaseGroups = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// - public PhaseGroupConnection PhaseGroups => _phaseGroups.Value(() => GetFirstMethodValue("phaseGroups")); + public PhaseGroupConnection PhaseGroups => + _phaseGroups.Value(() => GetFirstMethodValue("phaseGroups")); /// - /// The relative order of this phase within an event + /// The relative order of this phase within an event /// [GraphQLMember("phaseOrder")] [JsonPropertyName("phaseOrder")] public int? PhaseOrder { get; set; } - private LazyProperty _seeds = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public SeedConnection Seeds => _seeds.Value(() => GetFirstMethodValue("seeds")); - private LazyProperty _sets = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public SetConnection Sets => _sets.Value(() => GetFirstMethodValue("sets")); /// - /// State of the phase + /// State of the phase /// [GraphQLMember("state")] [JsonPropertyName("state")] @@ -122,5 +128,4 @@ public partial class Phase : GraphQLTypeBase [GraphQLMember("waves")] [JsonPropertyName("waves")] public List Waves { get; set; } - -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/RaceMatchConfig.cs b/StartGG/Client/Generated/Types/RaceMatchConfig.cs index c9218172..d6644dd1 100644 --- a/StartGG/Client/Generated/Types/RaceMatchConfig.cs +++ b/StartGG/Client/Generated/Types/RaceMatchConfig.cs @@ -5,50 +5,47 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - /// -/// Race specific match configuration +/// Race specific match configuration /// -public partial class RaceMatchConfig : GraphQLTypeBase, MatchConfig +public class RaceMatchConfig : GraphQLTypeBase, MatchConfig { - [GraphQLMember("id")] - [JsonPropertyName("id")] - public ID Id { get; set; } - - [GraphQLMember("bracketType")] - [JsonPropertyName("bracketType")] - public BracketType? BracketType { get; set; } - /// - /// Can players report results? + /// Can players report results? /// [GraphQLMember("playerReportingEnabled")] [JsonPropertyName("playerReportingEnabled")] public bool? PlayerReportingEnabled { get; set; } /// - /// Accepted methods of verification that players can use + /// Accepted methods of verification that players can use /// [GraphQLMember("verificationMethods")] [JsonPropertyName("verificationMethods")] public List VerificationMethods { get; set; } /// - /// Are players required to submit verification of their reported results? + /// Are players required to submit verification of their reported results? /// [GraphQLMember("verificationRequired")] [JsonPropertyName("verificationRequired")] public bool? VerificationRequired { get; set; } + [GraphQLMember("id")] + [JsonPropertyName("id")] + public ID Id { get; set; } + + [GraphQLMember("bracketType")] + [JsonPropertyName("bracketType")] + public BracketType? BracketType { get; set; } + [GraphQLMember("__typename")] [JsonPropertyName("__typename")] public string __TypeName { get; set; } -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/Set.cs b/StartGG/Client/Generated/Types/Set.cs index 19e6fa03..40973fab 100644 --- a/StartGG/Client/Generated/Types/Set.cs +++ b/StartGG/Client/Generated/Types/Set.cs @@ -5,89 +5,92 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - public static class SetExtensions { [GraphQLMember("displayScore")] - public static string DisplayScore(this Set set, [GraphQLArgument("mainEntrantId", "ID")] ID mainEntrantId = null) + public static string DisplayScore(this Set set, [GraphQLArgument("mainEntrantId", "ID")] ID mainEntrantId = null) { return set.GetMethodValue("displayScore", mainEntrantId); } [GraphQLMember("game")] - public static Game Game(this Set set, [GraphQLArgument("orderNum", "Int!")] int orderNum) + public static Game Game(this Set set, [GraphQLArgument("orderNum", "Int!")] int orderNum) { return set.GetMethodValue("game", orderNum); } [GraphQLMember("images")] - public static List Images(this Set set, [GraphQLArgument("type", "String")] string type = null) + public static List Images(this Set set, [GraphQLArgument("type", "String")] string type = null) { return set.GetMethodValue>("images", type); } [GraphQLMember("slots")] - public static List Slots(this Set set, [GraphQLArgument("includeByes", "Boolean")] bool? includeByes = null) + public static List Slots(this Set set, + [GraphQLArgument("includeByes", "Boolean")] bool? includeByes = null) { return set.GetMethodValue>("slots", includeByes); } - } /// -/// A set +/// A set /// -public partial class Set : GraphQLTypeBase +public class Set : GraphQLTypeBase { + private readonly LazyProperty _displayScore = new(); + + private readonly LazyProperty _game = new(); + + private readonly LazyProperty> _images = new(); + + private readonly LazyProperty> _slots = new(); + [GraphQLMember("id")] [JsonPropertyName("id")] public ID Id { get; set; } /// - /// The time this set was marked as completed + /// The time this set was marked as completed /// [GraphQLMember("completedAt")] [JsonPropertyName("completedAt")] public Timestamp CompletedAt { get; set; } /// - /// The time this set was created + /// The time this set was created /// [GraphQLMember("createdAt")] [JsonPropertyName("createdAt")] public Timestamp CreatedAt { get; set; } - private LazyProperty _displayScore = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public string DisplayScore => _displayScore.Value(() => GetFirstMethodValue("displayScore")); /// - /// Event that this set belongs to. + /// Event that this set belongs to. /// [GraphQLMember("event")] [JsonPropertyName("event")] public Event Event { get; set; } /// - /// Full round text of this set. + /// Full round text of this set. /// [GraphQLMember("fullRoundText")] [JsonPropertyName("fullRoundText")] public string FullRoundText { get; set; } - private LazyProperty _game = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public Game Game => _game.Value(() => GetFirstMethodValue("game")); @@ -96,22 +99,21 @@ public partial class Set : GraphQLTypeBase public List Games { get; set; } /// - /// Whether this set contains a placeholder entrant + /// Whether this set contains a placeholder entrant /// [GraphQLMember("hasPlaceholder")] [JsonPropertyName("hasPlaceholder")] public bool? HasPlaceholder { get; set; } /// - /// The letters that describe a unique identifier within the pool. Eg. F, AT + /// The letters that describe a unique identifier within the pool. Eg. F, AT /// [GraphQLMember("identifier")] [JsonPropertyName("identifier")] public string Identifier { get; set; } - private LazyProperty> _images = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public List Images => _images.Value(() => GetFirstMethodValue>("images")); @@ -120,42 +122,42 @@ public partial class Set : GraphQLTypeBase public int? LPlacement { get; set; } /// - /// Phase group that this Set belongs to. + /// Phase group that this Set belongs to. /// [GraphQLMember("phaseGroup")] [JsonPropertyName("phaseGroup")] public PhaseGroup PhaseGroup { get; set; } /// - /// The sets that are affected from resetting this set + /// The sets that are affected from resetting this set /// [GraphQLMember("resetAffectedData")] [JsonPropertyName("resetAffectedData")] public ResetAffectedData ResetAffectedData { get; set; } /// - /// The round number of the set. Negative numbers are losers bracket + /// The round number of the set. Negative numbers are losers bracket /// [GraphQLMember("round")] [JsonPropertyName("round")] public int? Round { get; set; } /// - /// Indicates whether the set is in best of or total games mode. This instructs -/// which field is used to figure out how many games are in this set. + /// Indicates whether the set is in best of or total games mode. This instructs + /// which field is used to figure out how many games are in this set. /// [GraphQLMember("setGamesType")] [JsonPropertyName("setGamesType")] public int? SetGamesType { get; set; } - private LazyProperty> _slots = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public List Slots => _slots.Value(() => GetFirstMethodValue>("slots")); /// - /// The start time of the Set. If there is no startAt time on the Set, will pull it from phaseGroup rounds configuration. + /// The start time of the Set. If there is no startAt time on the Set, will pull it from phaseGroup rounds + /// configuration. /// [GraphQLMember("startAt")] [JsonPropertyName("startAt")] @@ -170,28 +172,28 @@ public partial class Set : GraphQLTypeBase public int? State { get; set; } /// - /// Tournament event station for a set + /// Tournament event station for a set /// [GraphQLMember("station")] [JsonPropertyName("station")] public Stations Station { get; set; } /// - /// Tournament event stream for a set + /// Tournament event stream for a set /// [GraphQLMember("stream")] [JsonPropertyName("stream")] public Streams Stream { get; set; } /// - /// If setGamesType is in total games mode, this defined the number of games in the set. + /// If setGamesType is in total games mode, this defined the number of games in the set. /// [GraphQLMember("totalGames")] [JsonPropertyName("totalGames")] public int? TotalGames { get; set; } /// - /// Url of a VOD for this set + /// Url of a VOD for this set /// [GraphQLMember("vodUrl")] [JsonPropertyName("vodUrl")] @@ -204,5 +206,4 @@ public partial class Set : GraphQLTypeBase [GraphQLMember("winnerId")] [JsonPropertyName("winnerId")] public int? WinnerId { get; set; } - -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/SetSlot.cs b/StartGG/Client/Generated/Types/SetSlot.cs index 6165bbe5..a9172ee2 100644 --- a/StartGG/Client/Generated/Types/SetSlot.cs +++ b/StartGG/Client/Generated/Types/SetSlot.cs @@ -5,19 +5,16 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - /// -/// A slot in a set where a seed currently or will eventually exist in order to participate in the set. +/// A slot in a set where a seed currently or will eventually exist in order to participate in the set. /// -public partial class SetSlot : GraphQLTypeBase +public class SetSlot : GraphQLTypeBase { [GraphQLMember("id")] [JsonPropertyName("id")] @@ -28,21 +25,21 @@ public partial class SetSlot : GraphQLTypeBase public Entrant Entrant { get; set; } /// - /// Pairs with prereqType, is the ID of the prereq. + /// Pairs with prereqType, is the ID of the prereq. /// [GraphQLMember("prereqId")] [JsonPropertyName("prereqId")] public string PrereqId { get; set; } /// - /// Given a set prereq type, defines the placement required in the origin set to end up in this slot. + /// Given a set prereq type, defines the placement required in the origin set to end up in this slot. /// [GraphQLMember("prereqPlacement")] [JsonPropertyName("prereqPlacement")] public int? PrereqPlacement { get; set; } /// - /// Describes where the entity in this slot comes from. + /// Describes where the entity in this slot comes from. /// [GraphQLMember("prereqType")] [JsonPropertyName("prereqType")] @@ -53,17 +50,16 @@ public partial class SetSlot : GraphQLTypeBase public Seed Seed { get; set; } /// - /// The index of the slot. Unique per set. + /// The index of the slot. Unique per set. /// [GraphQLMember("slotIndex")] [JsonPropertyName("slotIndex")] public int? SlotIndex { get; set; } /// - /// The standing within this set for the seed currently assigned to this slot. + /// The standing within this set for the seed currently assigned to this slot. /// [GraphQLMember("standing")] [JsonPropertyName("standing")] public Standing Standing { get; set; } - -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/ShopLevel.cs b/StartGG/Client/Generated/Types/ShopLevel.cs index d336f9c3..4666af9f 100644 --- a/StartGG/Client/Generated/Types/ShopLevel.cs +++ b/StartGG/Client/Generated/Types/ShopLevel.cs @@ -5,30 +5,28 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - public static class ShopLevelExtensions { [GraphQLMember("images")] - public static List Images(this ShopLevel shopLevel, [GraphQLArgument("type", "String")] string type = null) + public static List Images(this ShopLevel shopLevel, [GraphQLArgument("type", "String")] string type = null) { return shopLevel.GetMethodValue>("images", type); } - } /// -/// A shop level +/// A shop level /// -public partial class ShopLevel : GraphQLTypeBase +public class ShopLevel : GraphQLTypeBase { + private readonly LazyProperty> _images = new(); + [GraphQLMember("id")] [JsonPropertyName("id")] public ID Id { get; set; } @@ -45,14 +43,12 @@ public partial class ShopLevel : GraphQLTypeBase [JsonPropertyName("goalAmount")] public double? GoalAmount { get; set; } - private LazyProperty> _images = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public List Images => _images.Value(() => GetFirstMethodValue>("images")); [GraphQLMember("name")] [JsonPropertyName("name")] public string Name { get; set; } - -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/ShopOrderMessageConnection.cs b/StartGG/Client/Generated/Types/ShopOrderMessageConnection.cs index 58388535..a524dd5c 100644 --- a/StartGG/Client/Generated/Types/ShopOrderMessageConnection.cs +++ b/StartGG/Client/Generated/Types/ShopOrderMessageConnection.cs @@ -5,23 +5,19 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - -public partial class ShopOrderMessageConnection : GraphQLTypeBase, Linq2GraphQL.Client.Common.ICursorPaging +public class ShopOrderMessageConnection : GraphQLTypeBase, ICursorPaging { - [GraphQLMember("pageInfo")] - [JsonPropertyName("pageInfo")] - public Linq2GraphQL.Client.Common.PageInfo PageInfo { get; set; } - [GraphQLMember("nodes")] [JsonPropertyName("nodes")] public List Nodes { get; set; } -} + [GraphQLMember("pageInfo")] + [JsonPropertyName("pageInfo")] + public PageInfo PageInfo { get; set; } +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/StreamQueue.cs b/StartGG/Client/Generated/Types/StreamQueue.cs index d61fd50e..ff76d644 100644 --- a/StartGG/Client/Generated/Types/StreamQueue.cs +++ b/StartGG/Client/Generated/Types/StreamQueue.cs @@ -5,36 +5,32 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - /// -/// A Stream queue object +/// A Stream queue object /// -public partial class StreamQueue : GraphQLTypeBase +public class StreamQueue : GraphQLTypeBase { [GraphQLMember("id")] [JsonPropertyName("id")] public string Id { get; set; } /// - /// The sets on the stream + /// The sets on the stream /// [GraphQLMember("sets")] [JsonPropertyName("sets")] public List Sets { get; set; } /// - /// The stream on the queue + /// The stream on the queue /// [GraphQLMember("stream")] [JsonPropertyName("stream")] public Streams Stream { get; set; } - -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/TeamActionSet.cs b/StartGG/Client/Generated/Types/TeamActionSet.cs index 25496765..54aa6db2 100644 --- a/StartGG/Client/Generated/Types/TeamActionSet.cs +++ b/StartGG/Client/Generated/Types/TeamActionSet.cs @@ -5,19 +5,16 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - /// -/// A set of actions available for a team to take +/// A set of actions available for a team to take /// -public partial class TeamActionSet : GraphQLTypeBase, ActionSet +public class TeamActionSet : GraphQLTypeBase, ActionSet { [GraphQLMember("id")] [JsonPropertyName("id")] @@ -26,4 +23,4 @@ public partial class TeamActionSet : GraphQLTypeBase, ActionSet [GraphQLMember("__typename")] [JsonPropertyName("__typename")] public string __TypeName { get; set; } -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/TournamentConnection.cs b/StartGG/Client/Generated/Types/TournamentConnection.cs index e7b3d5e1..68512e94 100644 --- a/StartGG/Client/Generated/Types/TournamentConnection.cs +++ b/StartGG/Client/Generated/Types/TournamentConnection.cs @@ -5,23 +5,19 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - -public partial class TournamentConnection : GraphQLTypeBase, Linq2GraphQL.Client.Common.ICursorPaging +public class TournamentConnection : GraphQLTypeBase, ICursorPaging { - [GraphQLMember("pageInfo")] - [JsonPropertyName("pageInfo")] - public Linq2GraphQL.Client.Common.PageInfo PageInfo { get; set; } - [GraphQLMember("nodes")] [JsonPropertyName("nodes")] public List Nodes { get; set; } -} + [GraphQLMember("pageInfo")] + [JsonPropertyName("pageInfo")] + public PageInfo PageInfo { get; set; } +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/User.cs b/StartGG/Client/Generated/Types/User.cs index 906ea6c6..f5554ad5 100644 --- a/StartGG/Client/Generated/Types/User.cs +++ b/StartGG/Client/Generated/Types/User.cs @@ -5,59 +5,69 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - public static class UserExtensions { [GraphQLMember("authorizations")] - public static List Authorizations(this User user, [GraphQLArgument("types", "[SocialConnectionType]")] List types = null) + public static List Authorizations(this User user, + [GraphQLArgument("types", "[SocialConnectionType]")] List types = null) { return user.GetMethodValue>("authorizations", types); } [GraphQLMember("events")] - public static EventConnection Events(this User user, [GraphQLArgument("query", "UserEventsPaginationQuery")] UserEventsPaginationQuery query = null) + public static EventConnection Events(this User user, + [GraphQLArgument("query", "UserEventsPaginationQuery")] UserEventsPaginationQuery query = null) { return user.GetMethodValue("events", query); } [GraphQLMember("images")] - public static List Images(this User user, [GraphQLArgument("type", "String")] string type = null) + public static List Images(this User user, [GraphQLArgument("type", "String")] string type = null) { return user.GetMethodValue>("images", type); } [GraphQLMember("leagues")] - public static LeagueConnection Leagues(this User user, [GraphQLArgument("query", "UserLeaguesPaginationQuery")] UserLeaguesPaginationQuery query = null) + public static LeagueConnection Leagues(this User user, + [GraphQLArgument("query", "UserLeaguesPaginationQuery")] UserLeaguesPaginationQuery query = null) { return user.GetMethodValue("leagues", query); } [GraphQLMember("tournaments")] - public static TournamentConnection Tournaments(this User user, [GraphQLArgument("query", "UserTournamentsPaginationQuery")] UserTournamentsPaginationQuery query = null) + public static TournamentConnection Tournaments(this User user, + [GraphQLArgument("query", "UserTournamentsPaginationQuery")] UserTournamentsPaginationQuery query = null) { return user.GetMethodValue("tournaments", query); } - } /// -/// A user +/// A user /// -public partial class User : GraphQLTypeBase +public class User : GraphQLTypeBase { - private LazyProperty> _authorizations = new(); + private readonly LazyProperty> _authorizations = new(); + + private readonly LazyProperty _events = new(); + + private readonly LazyProperty> _images = new(); + + private readonly LazyProperty _leagues = new(); + + private readonly LazyProperty _tournaments = new(); + /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// - public List Authorizations => _authorizations.Value(() => GetFirstMethodValue>("authorizations")); + public List Authorizations => + _authorizations.Value(() => GetFirstMethodValue>("authorizations")); [GraphQLMember("id")] [JsonPropertyName("id")] @@ -68,14 +78,14 @@ public partial class User : GraphQLTypeBase public string Bio { get; set; } /// - /// Public facing user birthday that respects user publishing settings + /// Public facing user birthday that respects user publishing settings /// [GraphQLMember("birthday")] [JsonPropertyName("birthday")] public string Birthday { get; set; } /// - /// Uniquely identifying token for user. Same as the hashed part of the slug + /// Uniquely identifying token for user. Same as the hashed part of the slug /// [GraphQLMember("discriminator")] [JsonPropertyName("discriminator")] @@ -85,9 +95,8 @@ public partial class User : GraphQLTypeBase [JsonPropertyName("email")] public string Email { get; set; } - private LazyProperty _events = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public EventConnection Events => _events.Value(() => GetFirstMethodValue("events")); @@ -95,34 +104,32 @@ public partial class User : GraphQLTypeBase [JsonPropertyName("genderPronoun")] public string GenderPronoun { get; set; } - private LazyProperty> _images = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public List Images => _images.Value(() => GetFirstMethodValue>("images")); - private LazyProperty _leagues = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public LeagueConnection Leagues => _leagues.Value(() => GetFirstMethodValue("leagues")); /// - /// Public location info for this user + /// Public location info for this user /// [GraphQLMember("location")] [JsonPropertyName("location")] public Address Location { get; set; } /// - /// Public facing user name that respects user publishing settings + /// Public facing user name that respects user publishing settings /// [GraphQLMember("name")] [JsonPropertyName("name")] public string Name { get; set; } /// - /// player for user + /// player for user /// [GraphQLMember("player")] [JsonPropertyName("player")] @@ -132,10 +139,9 @@ public partial class User : GraphQLTypeBase [JsonPropertyName("slug")] public string Slug { get; set; } - private LazyProperty _tournaments = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// - public TournamentConnection Tournaments => _tournaments.Value(() => GetFirstMethodValue("tournaments")); - -} + public TournamentConnection Tournaments => + _tournaments.Value(() => GetFirstMethodValue("tournaments")); +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/Videogame.cs b/StartGG/Client/Generated/Types/Videogame.cs index c5ae0380..ca81133a 100644 --- a/StartGG/Client/Generated/Types/Videogame.cs +++ b/StartGG/Client/Generated/Types/Videogame.cs @@ -5,36 +5,34 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - public static class VideogameExtensions { [GraphQLMember("images")] - public static List Images(this Videogame videogame, [GraphQLArgument("type", "String")] string type = null) + public static List Images(this Videogame videogame, [GraphQLArgument("type", "String")] string type = null) { return videogame.GetMethodValue>("images", type); } - } /// -/// A videogame +/// A videogame /// -public partial class Videogame : GraphQLTypeBase +public class Videogame : GraphQLTypeBase { + private readonly LazyProperty> _images = new(); + [GraphQLMember("id")] [JsonPropertyName("id")] public ID Id { get; set; } /// - /// All characters for this videogame + /// All characters for this videogame /// [GraphQLMember("characters")] [JsonPropertyName("characters")] @@ -44,9 +42,8 @@ public partial class Videogame : GraphQLTypeBase [JsonPropertyName("displayName")] public string DisplayName { get; set; } - private LazyProperty> _images = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// public List Images => _images.Value(() => GetFirstMethodValue>("images")); @@ -59,10 +56,9 @@ public partial class Videogame : GraphQLTypeBase public string Slug { get; set; } /// - /// All stages for this videogame + /// All stages for this videogame /// [GraphQLMember("stages")] [JsonPropertyName("stages")] public List Stages { get; set; } - -} +} \ No newline at end of file diff --git a/StartGG/Client/Generated/Types/VideogameConnection.cs b/StartGG/Client/Generated/Types/VideogameConnection.cs index 83c81adf..ecb079bd 100644 --- a/StartGG/Client/Generated/Types/VideogameConnection.cs +++ b/StartGG/Client/Generated/Types/VideogameConnection.cs @@ -5,23 +5,19 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StartGG.Client; - -public partial class VideogameConnection : GraphQLTypeBase, Linq2GraphQL.Client.Common.ICursorPaging +public class VideogameConnection : GraphQLTypeBase, ICursorPaging { - [GraphQLMember("pageInfo")] - [JsonPropertyName("pageInfo")] - public Linq2GraphQL.Client.Common.PageInfo PageInfo { get; set; } - [GraphQLMember("nodes")] [JsonPropertyName("nodes")] public List Nodes { get; set; } -} + [GraphQLMember("pageInfo")] + [JsonPropertyName("pageInfo")] + public PageInfo PageInfo { get; set; } +} \ No newline at end of file diff --git a/StartGG/StartGG.csproj b/StartGG/StartGG.csproj index 4d5ca064..183ad3ed 100644 --- a/StartGG/StartGG.csproj +++ b/StartGG/StartGG.csproj @@ -1,14 +1,14 @@  - - Exe - net8.0 - enable - disable - + + Exe + net9.0 + enable + disable + - - - + + + diff --git a/docs/Linq2GraphQL.Docs/App.razor b/docs/Linq2GraphQL.Docs/App.razor index d24fd397..54e55066 100644 --- a/docs/Linq2GraphQL.Docs/App.razor +++ b/docs/Linq2GraphQL.Docs/App.razor @@ -1,10 +1,10 @@  - - + + - @* Not found *@ + @* Not found *@

Sorry, there's nothing at this address.

diff --git a/docs/Linq2GraphQL.Docs/Components/ExceptionModal.razor b/docs/Linq2GraphQL.Docs/Components/ExceptionModal.razor index c1ed447a..8fba2e55 100644 --- a/docs/Linq2GraphQL.Docs/Components/ExceptionModal.razor +++ b/docs/Linq2GraphQL.Docs/Components/ExceptionModal.razor @@ -1,5 +1,4 @@ - - + @Exception?.Message diff --git a/docs/Linq2GraphQL.Docs/Components/GenerateClient.razor b/docs/Linq2GraphQL.Docs/Components/GenerateClient.razor index 5c254d78..baff0026 100644 --- a/docs/Linq2GraphQL.Docs/Components/GenerateClient.razor +++ b/docs/Linq2GraphQL.Docs/Components/GenerateClient.razor @@ -14,54 +14,60 @@ - + - + - + - + - + - + - + - + -
+
- + - + - + -
Run this query and paste the result below.
+
Run this + + query and paste the result below. +
- + - +
diff --git a/docs/Linq2GraphQL.Docs/Components/GenerateClient.razor.cs b/docs/Linq2GraphQL.Docs/Components/GenerateClient.razor.cs index d2fde424..c89efebe 100644 --- a/docs/Linq2GraphQL.Docs/Components/GenerateClient.razor.cs +++ b/docs/Linq2GraphQL.Docs/Components/GenerateClient.razor.cs @@ -1,163 +1,153 @@ +using System.IO.Compression; using Linq2GraphQL.Generator; using Microsoft.AspNetCore.Components; -using System.IO.Compression; using TabBlazor; using TabBlazor.Services; -namespace Linq2GraphQL.Docs.Components +namespace Linq2GraphQL.Docs.Components; + +public partial class GenerateClient { + private readonly List demoOptions = new(); + private bool isLoading; - public partial class GenerateClient - { - [Inject] private TablerService tablerService { get; set; } - [Inject] private ToastService toastService { get; set; } - [Inject] private IModalService modalService { get; set; } + private GenerateOptions options = new(); + [Inject] private TablerService tablerService { get; set; } + [Inject] private ToastService toastService { get; set; } + [Inject] private IModalService modalService { get; set; } - private GenerateOptions options = new(); - private bool isLoading; - private List demoOptions = new(); + protected override void OnInitialized() + { + demoOptions.Add(new() { Namespace = "MyNamespace", ClientName = "MyClient" }); - protected override void OnInitialized() + demoOptions.Add(new() { - demoOptions.Add(new GenerateOptions - { - Namespace = "MyNamespace", - ClientName = "MyClient" - }); + Url = "https://swapi-graphql.netlify.app/graphql", + Namespace = "StarWars.Client", + ClientName = "StarWarsClient" + }); + demoOptions.Add(new() + { + Url = "https://spacex-production.up.railway.app/", Namespace = "SpaceX", ClientName = "SpaceXClient" + }); + demoOptions.Add(new() + { + Url = "https://api.github.com/graphql", + Namespace = "Github", + ClientName = "GithubClient", + Token = "[Your Token]" + }); + demoOptions.Add(new() + { + Url = "https://api.start.gg/gql/alpha", + Namespace = "StartGG.Client", + ClientName = "StartGGClient", + Token = "[Your Token]" + }); - demoOptions.Add(new GenerateOptions - { - Url = "https://swapi-graphql.netlify.app/graphql", - Namespace = "StarWars.Client", - ClientName = "StarWarsClient" - }); - demoOptions.Add(new GenerateOptions - { - Url = "https://spacex-production.up.railway.app/", - Namespace = "SpaceX", - ClientName = "SpaceXClient" - }); - demoOptions.Add(new GenerateOptions - { - Url = "https://api.github.com/graphql", - Namespace = "Github", - ClientName = "GithubClient", - Token = "[Your Token]" - }); - demoOptions.Add(new GenerateOptions - { - Url = "https://api.start.gg/gql/alpha", - Namespace = "StartGG.Client", - ClientName = "StartGGClient", - Token = "[Your Token]" - }); + // - // + options = demoOptions.First(); + } - options = demoOptions.First(); + private async Task CopyIntrospection() + { + string query; + if (options.IncludeDeprecated) + { + query = General.IntrospectionQueryIncludeDeprecated; } - - private async Task CopyIntrospection() + else { - string query; - if (options.IncludeDeprecated) - { - query = Generator.General.IntrospectionQueryIncludeDeprecated; - } - else - { - query = Generator.General.IntrospectionQuery; - } - + query = General.IntrospectionQuery; + } - await tablerService.CopyToClipboard(query); - await toastService.AddToastAsync(new ToastModel - { - Title = "Copy Complete", - Message = "Introspection query has been copied to the clipboard" - }); - } + await tablerService.CopyToClipboard(query); + await toastService.AddToastAsync(new() + { + Title = "Copy Complete", Message = "Introspection query has been copied to the clipboard" + }); + } - private async Task SaveEntriesAsync(List entries) + private async Task SaveEntriesAsync(List entries) + { + using var memoryStream = new MemoryStream(); + using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) { - using var memoryStream = new MemoryStream(); - using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) + foreach (var entry in entries) { - foreach (var entry in entries) - { - var file = archive.CreateEntry(entry.DirectoryName + "/" + entry.FileName); - using var entryStream = file.Open(); - using var streamWriter = new StreamWriter(entryStream); - streamWriter.Write(entry.Content); - } - + var file = archive.CreateEntry(entry.DirectoryName + "/" + entry.FileName); + using var entryStream = file.Open(); + using var streamWriter = new StreamWriter(entryStream); + streamWriter.Write(entry.Content); } - memoryStream.Seek(0, SeekOrigin.Begin); - await tablerService.SaveAsBinary($"{options.ClientName}.zip", "application/zip", memoryStream.ToArray()); - - await toastService.AddToastAsync(new ToastModel - { - Title = "Generate Complete", - Message = $"{options.ClientName}.zip has been been created! Please check you downloads." - }); - } - private async Task GenerateClientJson() + memoryStream.Seek(0, SeekOrigin.Begin); + await tablerService.SaveAsBinary($"{options.ClientName}.zip", "application/zip", memoryStream.ToArray()); + + await toastService.AddToastAsync(new() { - try - { - isLoading = true; - var generator = new Generator.ClientGenerator(options.Namespace, options.ClientName, options.IncludeSubscriptions, EnumGeneratorStrategy.FailIfMissing, options.Nullable, options.IncludeDeprecated); - var entries = generator.Generate(options.Schema); - await SaveEntriesAsync(entries); + Title = "Generate Complete", + Message = $"{options.ClientName}.zip has been been created! Please check you downloads." + }); + } - } - catch (Exception ex) - { - var component = new RenderComponent().Set(e => e.Exception, ex); - var result = await modalService.ShowAsync("Error", component, new ModalOptions { Size = ModalSize.Large }); - } - finally - { - isLoading = false; - } + private async Task GenerateClientJson() + { + try + { + isLoading = true; + var generator = new ClientGenerator(options.Namespace, options.ClientName, options.IncludeSubscriptions, + EnumGeneratorStrategy.FailIfMissing, options.Nullable, options.IncludeDeprecated); + var entries = generator.Generate(options.Schema); + await SaveEntriesAsync(entries); } - - - private async Task GenerateClientAsync() + catch (Exception ex) { - try - { - isLoading = true; - var generator = new ClientGenerator(options.Namespace, options.ClientName, options.IncludeSubscriptions, options.EnumGeneratorStrategy, options.Nullable, options.IncludeDeprecated); - var entries = await generator.GenerateAsync(new Uri(options.Url), options.Token); - await SaveEntriesAsync(entries); - } - catch (Exception ex) - { - var component = new RenderComponent().Set(e => e.Exception, ex); - var result = await modalService.ShowAsync("Error", component, new ModalOptions { Size = ModalSize.Large }); - } - finally - { - isLoading = false; - } + var component = new RenderComponent().Set(e => e.Exception, ex); + var result = await modalService.ShowAsync("Error", component, new() { Size = ModalSize.Large }); + } + finally + { + isLoading = false; } } - public class GenerateOptions + + private async Task GenerateClientAsync() { - public string Namespace { get; set; } - public string ClientName { get; set; } - public bool IncludeSubscriptions { get; set; } - public bool Nullable { get; set; } - public string Url { get; set; } - public string Token { get; set; } - public bool IncludeDeprecated { get; set; } - public EnumGeneratorStrategy EnumGeneratorStrategy { get; set; } - - public string Schema { get; set; } + try + { + isLoading = true; + var generator = new ClientGenerator(options.Namespace, options.ClientName, options.IncludeSubscriptions, + options.EnumGeneratorStrategy, options.Nullable, options.IncludeDeprecated); + var entries = await generator.GenerateAsync(new(options.Url), options.Token); + await SaveEntriesAsync(entries); + } + catch (Exception ex) + { + var component = new RenderComponent().Set(e => e.Exception, ex); + var result = await modalService.ShowAsync("Error", component, new() { Size = ModalSize.Large }); + } + finally + { + isLoading = false; + } } } + +public class GenerateOptions +{ + public string Namespace { get; set; } + public string ClientName { get; set; } + public bool IncludeSubscriptions { get; set; } + public bool Nullable { get; set; } + public string Url { get; set; } + public string Token { get; set; } + public bool IncludeDeprecated { get; set; } + public EnumGeneratorStrategy EnumGeneratorStrategy { get; set; } + + public string Schema { get; set; } +} \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceQuery.razor b/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceQuery.razor index b318694d..a0604d62 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceQuery.razor +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceQuery.razor @@ -2,10 +2,10 @@ - - - - + + + + \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceQuery.razor.cs b/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceQuery.razor.cs index 6ece1394..f757d093 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceQuery.razor.cs +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceQuery.razor.cs @@ -1,17 +1,16 @@ using Linq2GraphQL.Client; using StarWars.Client; -namespace Linq2GraphQL.Docs.Components.Samples.Interfaces +namespace Linq2GraphQL.Docs.Components.Samples.Interfaces; + +public partial class InterfaceQuery { - public partial class InterfaceQuery + private GraphQueryExecute GetQuery() { - private GraphQueryExecute GetQuery() - { - return starWarsClient - .Query - .Node("ZmlsbXM6MQ==") - .Include(e => e.Film()) - .Select(); - } + return starWarsClient + .Query + .Node("ZmlsbXM6MQ==") + .Include(e => e.Film()) + .Select(); } } \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceSamples.razor b/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceSamples.razor index ccf71473..054bb7b8 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceSamples.razor +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Interfaces/InterfaceSamples.razor @@ -1,11 +1,10 @@ @page "/samples/interfaces" -@using Linq2GraphQL.Client; -@using StarWars.Client; +@using StarWars.Client @inject StarWarsClient starWarsClient

Interface Samples

- + diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/BasicQuery.razor b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/BasicQuery.razor index 21292a9c..6fc0824e 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/BasicQuery.razor +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/BasicQuery.razor @@ -2,10 +2,10 @@ - - This is a basic query.. - - + + This is a basic query.. + + \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/BasicQuery.razor.cs b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/BasicQuery.razor.cs index f99b62cb..fd53d30d 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/BasicQuery.razor.cs +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/BasicQuery.razor.cs @@ -1,15 +1,16 @@ using Linq2GraphQL.Client; -namespace Linq2GraphQL.Docs.Components.Samples.Queries +using StarWars.Client; + +namespace Linq2GraphQL.Docs.Components.Samples.Queries; + +public partial class BasicQuery { - public partial class BasicQuery + private GraphQueryExecute> GetQuery() { - private GraphQueryExecute> GetQuery() - { - return starWarsClient - .Query - .AllFilms(first: 3) - .Include(e => e.Films.Select(f => f.Producers)) - .Select(e => e.Films); - } + return starWarsClient + .Query + .AllFilms(first: 3) + .Include(e => e.Films.Select(f => f.Producers)) + .Select(e => e.Films); } } \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/ProjectCustomObject.razor b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/ProjectCustomObject.razor index 20d812cb..49ed76bd 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/ProjectCustomObject.razor +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/ProjectCustomObject.razor @@ -1,7 +1,7 @@ @inherits SampleBase; - + Project to a custom object... diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/ProjectCustomObject.razor.cs b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/ProjectCustomObject.razor.cs index f73fb7fb..a8c053dd 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/ProjectCustomObject.razor.cs +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/ProjectCustomObject.razor.cs @@ -1,29 +1,24 @@ using Linq2GraphQL.Client; -namespace Linq2GraphQL.Docs.Components.Samples.Queries +using StarWars.Client; + +namespace Linq2GraphQL.Docs.Components.Samples.Queries; + +public partial class ProjectCustomObject { - public partial class ProjectCustomObject + private GraphCursorQueryExecute> GetQuery() { - private GraphCursorQueryExecute> GetQuery() - { - return starWarsClient - .Query - .AllFilms(first: 3) - .Select(e => e.Films.Select(e => - new FilmProjection - { - Id = e.Id, - Title = e.Title, - Created = e.Created, - Producers = e.Producers, - })); - } + return starWarsClient + .Query + .AllFilms(first: 3) + .Select(e => e.Films.Select(e => + new FilmProjection { Id = e.Id, Title = e.Title, Created = e.Created, Producers = e.Producers })); } +} - public class FilmProjection - { - public string Id { get; set; } - public string Title { get; set; } - public string Created { get; set; } - public List Producers { get; set; } - } +public class FilmProjection +{ + public string Id { get; set; } + public string Title { get; set; } + public string Created { get; set; } + public List Producers { get; set; } } \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/QuerySamples.razor b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/QuerySamples.razor index c4cbecd5..599ec535 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/QuerySamples.razor +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/QuerySamples.razor @@ -1,13 +1,12 @@ @page "/samples/queries" -@using Linq2GraphQL.Client; -@using StarWars.Client; +@using StarWars.Client @inject StarWarsClient starWarsClient

Query Samples

- - - + + + diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/SelectMany.razor b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/SelectMany.razor index 33acd256..8b790555 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/SelectMany.razor +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/SelectMany.razor @@ -1,7 +1,7 @@ @inherits SampleBase; - + diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/SelectMany.razor.cs b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/SelectMany.razor.cs index 215c770c..5d9bb272 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/Queries/SelectMany.razor.cs +++ b/docs/Linq2GraphQL.Docs/Components/Samples/Queries/SelectMany.razor.cs @@ -1,15 +1,16 @@ using Linq2GraphQL.Client; -namespace Linq2GraphQL.Docs.Components.Samples.Queries +using StarWars.Client; + +namespace Linq2GraphQL.Docs.Components.Samples.Queries; + +public partial class SelectMany { - public partial class SelectMany + private GraphCursorQueryExecute> GetQuery() { - private GraphCursorQueryExecute> GetQuery() - { - return starWarsClient - .Query - .AllFilms() - .Select(e => e.Films.SelectMany(e => e.Producers) - ); - } + return starWarsClient + .Query + .AllFilms() + .Select(e => e.Films.SelectMany(e => e.Producers) + ); } } \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/SampleBase.cs b/docs/Linq2GraphQL.Docs/Components/Samples/SampleBase.cs index b02668f5..9876698d 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/SampleBase.cs +++ b/docs/Linq2GraphQL.Docs/Components/Samples/SampleBase.cs @@ -1,18 +1,14 @@ -using Linq2GraphQL.Client; -using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components; using StarWars.Client; -using TabBlazor.Components.Tables.Components; -namespace Linq2GraphQL.Docs.Components.Samples -{ - public class SampleBase : ComponentBase - { - [Inject] public StarWarsClient starWarsClient { get; set; } +namespace Linq2GraphQL.Docs.Components.Samples; - public string GetTypeFullName() - { - return GetType().FullName; - } +public class SampleBase : ComponentBase +{ + [Inject] public StarWarsClient starWarsClient { get; set; } + public string GetTypeFullName() + { + return GetType().FullName; } -} +} \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/Components/Samples/SamplesViewer.razor b/docs/Linq2GraphQL.Docs/Components/Samples/SamplesViewer.razor index 1cae8d72..dd97d92e 100644 --- a/docs/Linq2GraphQL.Docs/Components/Samples/SamplesViewer.razor +++ b/docs/Linq2GraphQL.Docs/Components/Samples/SamplesViewer.razor @@ -6,7 +6,10 @@ -

@Title

+

@Title +

@Description @@ -21,13 +24,14 @@
- +
- +
@@ -35,7 +39,9 @@
@if (QueryExecute.BaseResult == null) { - + } else { @@ -47,8 +53,8 @@
@if (QueryExecute.BaseResult != null) { - - + }
@@ -59,15 +65,14 @@ {
- +
} - - } diff --git a/docs/Linq2GraphQL.Docs/GraphQLSample.cs b/docs/Linq2GraphQL.Docs/GraphQLSample.cs index 468dabd0..9b192b1e 100644 --- a/docs/Linq2GraphQL.Docs/GraphQLSample.cs +++ b/docs/Linq2GraphQL.Docs/GraphQLSample.cs @@ -1,17 +1,15 @@ using Linq2GraphQL.Client; -namespace Linq2GraphQL.Docs +namespace Linq2GraphQL.Docs; + +public class GraphQLSample { - public class GraphQLSample + public GraphQLSample(GraphQueryExecute executor, string title) { - - public GraphQLSample(GraphQueryExecute executor, string title) - { - Executor = executor; - Title = title; - } - - public GraphQueryExecute Executor { get; } - public string Title { get; } + Executor = executor; + Title = title; } -} + + public GraphQueryExecute Executor { get; } + public string Title { get; } +} \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/Linq2GraphQL.Docs.csproj b/docs/Linq2GraphQL.Docs/Linq2GraphQL.Docs.csproj index 0fb7dd7f..0e7a217b 100644 --- a/docs/Linq2GraphQL.Docs/Linq2GraphQL.Docs.csproj +++ b/docs/Linq2GraphQL.Docs/Linq2GraphQL.Docs.csproj @@ -1,38 +1,38 @@ - - net8.0 - disable - enable - + + net9.0 + disable + enable + - - false - + + false + - - - - - - - - + + + + + + + + - - - - + + + + - - - - - wwwroot\_content\razor_samples\%(DistFiles.RecursiveDir)%(DistFiles.Filename)%(DistFiles.Extension) - PreserveNewest - true - - - + + + + + wwwroot\_content\razor_samples\%(DistFiles.RecursiveDir)%(DistFiles.Filename)%(DistFiles.Extension) + PreserveNewest + true + + + diff --git a/docs/Linq2GraphQL.Docs/Pages/Index.razor b/docs/Linq2GraphQL.Docs/Pages/Index.razor index 37043447..91682974 100644 --- a/docs/Linq2GraphQL.Docs/Pages/Index.razor +++ b/docs/Linq2GraphQL.Docs/Pages/Index.razor @@ -10,17 +10,21 @@
- logo + logo

Linq2GraphQL.Client

A straightforward Linq to GraphQL Client

-

Documentation · Report Bug · Request Feature

+

Documentation · Report Bug · Request Feature

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.

-

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

+

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

 var orders = await sampleClient
     .Query
     .Orders(first: 10)
@@ -32,12 +36,13 @@
 

Generate Client code

There are two options to generate the client code from the GraphQL schema. - Use the online tool to generate or install Linq2GraphQL.Generator as a .Net tool. + Use the online tool to generate or install + Linq2GraphQL.Generator as a .Net tool.

Install/Update Tool:

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

Usage:

+

Usage:

  Linq2GraphQL.Generator <endpoint> [options]
 
 Arguments:
@@ -55,7 +60,8 @@ Options:
 

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

Add the Nuget Package Linq2GraphQL.Client

dotnet add package Linq2GraphQL.Client --prerelease
@@ -73,6 +79,9 @@ Options:
        httpClient => { 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 , thank you Giorgi

+

Linq2GraphQL is inspired by GraphQLinq , thank you Giorgi

diff --git a/docs/Linq2GraphQL.Docs/Shared/MainLayout.razor b/docs/Linq2GraphQL.Docs/Shared/MainLayout.razor index 65cd97c4..07490e05 100644 --- a/docs/Linq2GraphQL.Docs/Shared/MainLayout.razor +++ b/docs/Linq2GraphQL.Docs/Shared/MainLayout.razor @@ -1,12 +1,12 @@ @inherits LayoutComponentBase - - - + + +
- +
diff --git a/docs/Linq2GraphQL.Docs/Shared/MainLayout.razor.css b/docs/Linq2GraphQL.Docs/Shared/MainLayout.razor.css index c8654276..01a5066c 100644 --- a/docs/Linq2GraphQL.Docs/Shared/MainLayout.razor.css +++ b/docs/Linq2GraphQL.Docs/Shared/MainLayout.razor.css @@ -21,20 +21,20 @@ main { align-items: center; } - .top-row ::deep a, .top-row ::deep .btn-link { - white-space: nowrap; - margin-left: 1.5rem; - text-decoration: none; - } +.top-row ::deep a, .top-row ::deep .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + text-decoration: none; +} - .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { - text-decoration: underline; - } +.top-row ::deep a:hover, .top-row ::deep .btn-link:hover { + text-decoration: underline; +} - .top-row ::deep a:first-child { - overflow: hidden; - text-overflow: ellipsis; - } +.top-row ::deep a:first-child { + overflow: hidden; + text-overflow: ellipsis; +} @media (max-width: 640.98px) { .top-row:not(.auth) { diff --git a/docs/Linq2GraphQL.Docs/Shared/MainNavigation.razor b/docs/Linq2GraphQL.Docs/Shared/MainNavigation.razor index f83a4f73..f76d1b1e 100644 --- a/docs/Linq2GraphQL.Docs/Shared/MainNavigation.razor +++ b/docs/Linq2GraphQL.Docs/Shared/MainNavigation.razor @@ -11,24 +11,24 @@ - + - + - + - - + + diff --git a/docs/Linq2GraphQL.Docs/wwwroot/css/app.css b/docs/Linq2GraphQL.Docs/wwwroot/css/app.css index 5e6fd00b..dc1b096b 100644 --- a/docs/Linq2GraphQL.Docs/wwwroot/css/app.css +++ b/docs/Linq2GraphQL.Docs/wwwroot/css/app.css @@ -19,7 +19,7 @@ max-height: 300px; overflow: auto; margin-bottom: 0.5rem !important; - padding:5px + padding: 5px } /*Monaco Editor*/ @@ -40,12 +40,12 @@ z-index: 1000; } - #blazor-error-ui .dismiss { - cursor: pointer; - position: absolute; - right: 0.75rem; - top: 0.5rem; - } +#blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; +} .blazor-error-boundary { background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; @@ -53,9 +53,9 @@ color: white; } - .blazor-error-boundary::after { - content: "An error has occurred." - } +.blazor-error-boundary::after { + content: "An error has occurred." +} .loading-progress { position: relative; @@ -65,19 +65,19 @@ margin: 20vh auto 1rem auto; } - .loading-progress circle { - fill: none; - stroke: #e0e0e0; - stroke-width: 0.6rem; - transform-origin: 50% 50%; - transform: rotate(-90deg); - } +.loading-progress circle { + fill: none; + stroke: #e0e0e0; + stroke-width: 0.6rem; + transform-origin: 50% 50%; + transform: rotate(-90deg); +} - .loading-progress circle:last-child { - stroke: #1b6ec2; - stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; - transition: stroke-dasharray 0.05s ease-in-out; - } +.loading-progress circle:last-child { + stroke: #1b6ec2; + stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; + transition: stroke-dasharray 0.05s ease-in-out; +} .loading-progress-text { position: absolute; @@ -86,6 +86,6 @@ inset: calc(20vh + 3.25rem) 0 auto 0.2rem; } - .loading-progress-text:after { - content: var(--blazor-load-percentage-text, "Loading"); - } +.loading-progress-text:after { + content: var(--blazor-load-percentage-text, "Loading"); +} diff --git a/docs/Linq2GraphQL.Docs/wwwroot/img/logo.svg b/docs/Linq2GraphQL.Docs/wwwroot/img/logo.svg index e85d0ee4..c35135a2 100644 --- a/docs/Linq2GraphQL.Docs/wwwroot/img/logo.svg +++ b/docs/Linq2GraphQL.Docs/wwwroot/img/logo.svg @@ -1 +1,19 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Linq2GraphQL.Docs/wwwroot/index.html b/docs/Linq2GraphQL.Docs/wwwroot/index.html index fa4b31c1..6b02ad40 100644 --- a/docs/Linq2GraphQL.Docs/wwwroot/index.html +++ b/docs/Linq2GraphQL.Docs/wwwroot/index.html @@ -2,45 +2,45 @@ - - + + Linq2GraphQL Documentation - + - - + + - + - + + + + + - - - - -
- - - - -
-
- -
- An unhandled error has occurred. - Reload - 🗙 -
- - - - - - +
+ + + + +
+
+ +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + + + + diff --git a/docs/StarWars.Client/Generated/Client/StarWarsClient.cs b/docs/StarWars.Client/Generated/Client/StarWarsClient.cs index b1d3e0b9..cc965c15 100644 --- a/docs/StarWars.Client/Generated/Client/StarWarsClient.cs +++ b/docs/StarWars.Client/Generated/Client/StarWarsClient.cs @@ -6,7 +6,6 @@ //--------------------------------------------------------------------- using Linq2GraphQL.Client; -using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; @@ -14,12 +13,12 @@ namespace StarWars.Client; public class StarWarsClient { - public StarWarsClient(HttpClient httpClient, [FromKeyedServices("StarWarsClient")]IOptions options, IServiceProvider provider) + public StarWarsClient(HttpClient httpClient, + [FromKeyedServices("StarWarsClient")] IOptions options, IServiceProvider provider) { var client = new GraphClient(httpClient, options, provider); - Query = new RootMethods(client); + Query = new(client); } public RootMethods Query { get; private set; } - } \ No newline at end of file diff --git a/docs/StarWars.Client/Generated/Types/FilmPlanetsConnection.cs b/docs/StarWars.Client/Generated/Types/FilmPlanetsConnection.cs index eb2ac52d..cffe8796 100644 --- a/docs/StarWars.Client/Generated/Types/FilmPlanetsConnection.cs +++ b/docs/StarWars.Client/Generated/Types/FilmPlanetsConnection.cs @@ -5,54 +5,50 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StarWars.Client; - /// -/// A connection to a list of items. +/// A connection to a list of items. /// -public partial class FilmPlanetsConnection : GraphQLTypeBase, Linq2GraphQL.Client.Common.ICursorPaging +public class FilmPlanetsConnection : GraphQLTypeBase, ICursorPaging { /// - /// Information to aid in pagination. - /// - [GraphQLMember("pageInfo")] - [JsonPropertyName("pageInfo")] - public Linq2GraphQL.Client.Common.PageInfo PageInfo { get; set; } - - /// - /// A list of edges. + /// A list of edges. /// [GraphQLMember("edges")] [JsonPropertyName("edges")] public List Edges { get; set; } /// - /// A count of the total number of objects in this connection, ignoring pagination. -/// This allows a client to fetch the first five objects by passing "5" as the -/// argument to "first", then fetch the total count so it could display "5 of 83", -/// for example. + /// A count of the total number of objects in this connection, ignoring pagination. + /// This allows a client to fetch the first five objects by passing "5" as the + /// argument to "first", then fetch the total count so it could display "5 of 83", + /// for example. /// [GraphQLMember("totalCount")] [JsonPropertyName("totalCount")] public int? TotalCount { get; set; } /// - /// A list of all of the objects returned in the connection. This is a convenience -/// field provided for quickly exploring the API; rather than querying for -/// "{ edges { node } }" when no edge data is needed, this field can be be used -/// instead. Note that when clients like Relay need to fetch the "cursor" field on -/// the edge to enable efficient pagination, this shortcut cannot be used, and the -/// full "{ edges { node } }" version should be used instead. + /// A list of all of the objects returned in the connection. This is a convenience + /// field provided for quickly exploring the API; rather than querying for + /// "{ edges { node } }" when no edge data is needed, this field can be be used + /// instead. Note that when clients like Relay need to fetch the "cursor" field on + /// the edge to enable efficient pagination, this shortcut cannot be used, and the + /// full "{ edges { node } }" version should be used instead. /// [GraphQLMember("planets")] [JsonPropertyName("planets")] public List Planets { get; set; } -} + /// + /// Information to aid in pagination. + /// + [GraphQLMember("pageInfo")] + [JsonPropertyName("pageInfo")] + public PageInfo PageInfo { get; set; } +} \ No newline at end of file diff --git a/docs/StarWars.Client/Generated/Types/FilmStarshipsConnection.cs b/docs/StarWars.Client/Generated/Types/FilmStarshipsConnection.cs index 0f8f72e8..b64332f1 100644 --- a/docs/StarWars.Client/Generated/Types/FilmStarshipsConnection.cs +++ b/docs/StarWars.Client/Generated/Types/FilmStarshipsConnection.cs @@ -5,54 +5,50 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StarWars.Client; - /// -/// A connection to a list of items. +/// A connection to a list of items. /// -public partial class FilmStarshipsConnection : GraphQLTypeBase, Linq2GraphQL.Client.Common.ICursorPaging +public class FilmStarshipsConnection : GraphQLTypeBase, ICursorPaging { /// - /// Information to aid in pagination. - /// - [GraphQLMember("pageInfo")] - [JsonPropertyName("pageInfo")] - public Linq2GraphQL.Client.Common.PageInfo PageInfo { get; set; } - - /// - /// A list of edges. + /// A list of edges. /// [GraphQLMember("edges")] [JsonPropertyName("edges")] public List Edges { get; set; } /// - /// A count of the total number of objects in this connection, ignoring pagination. -/// This allows a client to fetch the first five objects by passing "5" as the -/// argument to "first", then fetch the total count so it could display "5 of 83", -/// for example. + /// A count of the total number of objects in this connection, ignoring pagination. + /// This allows a client to fetch the first five objects by passing "5" as the + /// argument to "first", then fetch the total count so it could display "5 of 83", + /// for example. /// [GraphQLMember("totalCount")] [JsonPropertyName("totalCount")] public int? TotalCount { get; set; } /// - /// A list of all of the objects returned in the connection. This is a convenience -/// field provided for quickly exploring the API; rather than querying for -/// "{ edges { node } }" when no edge data is needed, this field can be be used -/// instead. Note that when clients like Relay need to fetch the "cursor" field on -/// the edge to enable efficient pagination, this shortcut cannot be used, and the -/// full "{ edges { node } }" version should be used instead. + /// A list of all of the objects returned in the connection. This is a convenience + /// field provided for quickly exploring the API; rather than querying for + /// "{ edges { node } }" when no edge data is needed, this field can be be used + /// instead. Note that when clients like Relay need to fetch the "cursor" field on + /// the edge to enable efficient pagination, this shortcut cannot be used, and the + /// full "{ edges { node } }" version should be used instead. /// [GraphQLMember("starships")] [JsonPropertyName("starships")] public List Starships { get; set; } -} + /// + /// Information to aid in pagination. + /// + [GraphQLMember("pageInfo")] + [JsonPropertyName("pageInfo")] + public PageInfo PageInfo { get; set; } +} \ No newline at end of file diff --git a/docs/StarWars.Client/Generated/Types/FilmStarshipsEdge.cs b/docs/StarWars.Client/Generated/Types/FilmStarshipsEdge.cs index ce93a212..d1d1a499 100644 --- a/docs/StarWars.Client/Generated/Types/FilmStarshipsEdge.cs +++ b/docs/StarWars.Client/Generated/Types/FilmStarshipsEdge.cs @@ -5,32 +5,28 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StarWars.Client; - /// -/// An edge in a connection. +/// An edge in a connection. /// -public partial class FilmStarshipsEdge : GraphQLTypeBase +public class FilmStarshipsEdge : GraphQLTypeBase { /// - /// The item at the end of the edge + /// The item at the end of the edge /// [GraphQLMember("node")] [JsonPropertyName("node")] public Starship Node { get; set; } /// - /// A cursor for use in pagination + /// A cursor for use in pagination /// [GraphQLMember("cursor")] [JsonPropertyName("cursor")] public string Cursor { get; set; } - -} +} \ No newline at end of file diff --git a/docs/StarWars.Client/Generated/Types/FilmVehiclesConnection.cs b/docs/StarWars.Client/Generated/Types/FilmVehiclesConnection.cs index 4a4bce8d..89fa8fad 100644 --- a/docs/StarWars.Client/Generated/Types/FilmVehiclesConnection.cs +++ b/docs/StarWars.Client/Generated/Types/FilmVehiclesConnection.cs @@ -5,54 +5,50 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StarWars.Client; - /// -/// A connection to a list of items. +/// A connection to a list of items. /// -public partial class FilmVehiclesConnection : GraphQLTypeBase, Linq2GraphQL.Client.Common.ICursorPaging +public class FilmVehiclesConnection : GraphQLTypeBase, ICursorPaging { /// - /// Information to aid in pagination. - /// - [GraphQLMember("pageInfo")] - [JsonPropertyName("pageInfo")] - public Linq2GraphQL.Client.Common.PageInfo PageInfo { get; set; } - - /// - /// A list of edges. + /// A list of edges. /// [GraphQLMember("edges")] [JsonPropertyName("edges")] public List Edges { get; set; } /// - /// A count of the total number of objects in this connection, ignoring pagination. -/// This allows a client to fetch the first five objects by passing "5" as the -/// argument to "first", then fetch the total count so it could display "5 of 83", -/// for example. + /// A count of the total number of objects in this connection, ignoring pagination. + /// This allows a client to fetch the first five objects by passing "5" as the + /// argument to "first", then fetch the total count so it could display "5 of 83", + /// for example. /// [GraphQLMember("totalCount")] [JsonPropertyName("totalCount")] public int? TotalCount { get; set; } /// - /// A list of all of the objects returned in the connection. This is a convenience -/// field provided for quickly exploring the API; rather than querying for -/// "{ edges { node } }" when no edge data is needed, this field can be be used -/// instead. Note that when clients like Relay need to fetch the "cursor" field on -/// the edge to enable efficient pagination, this shortcut cannot be used, and the -/// full "{ edges { node } }" version should be used instead. + /// A list of all of the objects returned in the connection. This is a convenience + /// field provided for quickly exploring the API; rather than querying for + /// "{ edges { node } }" when no edge data is needed, this field can be be used + /// instead. Note that when clients like Relay need to fetch the "cursor" field on + /// the edge to enable efficient pagination, this shortcut cannot be used, and the + /// full "{ edges { node } }" version should be used instead. /// [GraphQLMember("vehicles")] [JsonPropertyName("vehicles")] public List Vehicles { get; set; } -} + /// + /// Information to aid in pagination. + /// + [GraphQLMember("pageInfo")] + [JsonPropertyName("pageInfo")] + public PageInfo PageInfo { get; set; } +} \ No newline at end of file diff --git a/docs/StarWars.Client/Generated/Types/PlanetResidentsConnection.cs b/docs/StarWars.Client/Generated/Types/PlanetResidentsConnection.cs index 99762c7d..b094d2db 100644 --- a/docs/StarWars.Client/Generated/Types/PlanetResidentsConnection.cs +++ b/docs/StarWars.Client/Generated/Types/PlanetResidentsConnection.cs @@ -5,54 +5,50 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StarWars.Client; - /// -/// A connection to a list of items. +/// A connection to a list of items. /// -public partial class PlanetResidentsConnection : GraphQLTypeBase, Linq2GraphQL.Client.Common.ICursorPaging +public class PlanetResidentsConnection : GraphQLTypeBase, ICursorPaging { /// - /// Information to aid in pagination. - /// - [GraphQLMember("pageInfo")] - [JsonPropertyName("pageInfo")] - public Linq2GraphQL.Client.Common.PageInfo PageInfo { get; set; } - - /// - /// A list of edges. + /// A list of edges. /// [GraphQLMember("edges")] [JsonPropertyName("edges")] public List Edges { get; set; } /// - /// A count of the total number of objects in this connection, ignoring pagination. -/// This allows a client to fetch the first five objects by passing "5" as the -/// argument to "first", then fetch the total count so it could display "5 of 83", -/// for example. + /// A count of the total number of objects in this connection, ignoring pagination. + /// This allows a client to fetch the first five objects by passing "5" as the + /// argument to "first", then fetch the total count so it could display "5 of 83", + /// for example. /// [GraphQLMember("totalCount")] [JsonPropertyName("totalCount")] public int? TotalCount { get; set; } /// - /// A list of all of the objects returned in the connection. This is a convenience -/// field provided for quickly exploring the API; rather than querying for -/// "{ edges { node } }" when no edge data is needed, this field can be be used -/// instead. Note that when clients like Relay need to fetch the "cursor" field on -/// the edge to enable efficient pagination, this shortcut cannot be used, and the -/// full "{ edges { node } }" version should be used instead. + /// A list of all of the objects returned in the connection. This is a convenience + /// field provided for quickly exploring the API; rather than querying for + /// "{ edges { node } }" when no edge data is needed, this field can be be used + /// instead. Note that when clients like Relay need to fetch the "cursor" field on + /// the edge to enable efficient pagination, this shortcut cannot be used, and the + /// full "{ edges { node } }" version should be used instead. /// [GraphQLMember("residents")] [JsonPropertyName("residents")] public List Residents { get; set; } -} + /// + /// Information to aid in pagination. + /// + [GraphQLMember("pageInfo")] + [JsonPropertyName("pageInfo")] + public PageInfo PageInfo { get; set; } +} \ No newline at end of file diff --git a/docs/StarWars.Client/Generated/Types/PlanetResidentsEdge.cs b/docs/StarWars.Client/Generated/Types/PlanetResidentsEdge.cs index c27fb16a..da1782b3 100644 --- a/docs/StarWars.Client/Generated/Types/PlanetResidentsEdge.cs +++ b/docs/StarWars.Client/Generated/Types/PlanetResidentsEdge.cs @@ -5,32 +5,28 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StarWars.Client; - /// -/// An edge in a connection. +/// An edge in a connection. /// -public partial class PlanetResidentsEdge : GraphQLTypeBase +public class PlanetResidentsEdge : GraphQLTypeBase { /// - /// The item at the end of the edge + /// The item at the end of the edge /// [GraphQLMember("node")] [JsonPropertyName("node")] public Person Node { get; set; } /// - /// A cursor for use in pagination + /// A cursor for use in pagination /// [GraphQLMember("cursor")] [JsonPropertyName("cursor")] public string Cursor { get; set; } - -} +} \ No newline at end of file diff --git a/docs/StarWars.Client/Generated/Types/Starship.cs b/docs/StarWars.Client/Generated/Types/Starship.cs index c42e82fc..0e2f452c 100644 --- a/docs/StarWars.Client/Generated/Types/Starship.cs +++ b/docs/StarWars.Client/Generated/Types/Starship.cs @@ -5,163 +5,167 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StarWars.Client; - public static class StarshipExtensions { [GraphQLMember("pilotConnection")] - public static StarshipPilotsConnection PilotConnection(this Starship starship, [GraphQLArgument("after", "String")] string after = null, [GraphQLArgument("first", "Int")] int? first = null, [GraphQLArgument("before", "String")] string before = null, [GraphQLArgument("last", "Int")] int? last = null) + public static StarshipPilotsConnection PilotConnection(this Starship starship, + [GraphQLArgument("after", "String")] string after = null, [GraphQLArgument("first", "Int")] int? first = null, + [GraphQLArgument("before", "String")] string before = null, [GraphQLArgument("last", "Int")] int? last = null) { return starship.GetMethodValue("pilotConnection", after, first, before, last); } [GraphQLMember("filmConnection")] - public static StarshipFilmsConnection FilmConnection(this Starship starship, [GraphQLArgument("after", "String")] string after = null, [GraphQLArgument("first", "Int")] int? first = null, [GraphQLArgument("before", "String")] string before = null, [GraphQLArgument("last", "Int")] int? last = null) + public static StarshipFilmsConnection FilmConnection(this Starship starship, + [GraphQLArgument("after", "String")] string after = null, [GraphQLArgument("first", "Int")] int? first = null, + [GraphQLArgument("before", "String")] string before = null, [GraphQLArgument("last", "Int")] int? last = null) { return starship.GetMethodValue("filmConnection", after, first, before, last); } - } /// -/// A single transport craft that has hyperdrive capability. +/// A single transport craft that has hyperdrive capability. /// -public partial class Starship : GraphQLTypeBase, Node +public class Starship : GraphQLTypeBase, Node { + private readonly LazyProperty _filmConnection = new(); + + private readonly LazyProperty _pilotConnection = new(); + /// - /// The name of this starship. The common name, such as "Death Star". + /// The name of this starship. The common name, such as "Death Star". /// [GraphQLMember("name")] [JsonPropertyName("name")] public string Name { get; set; } /// - /// The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 -/// Orbital Battle Station". + /// The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 + /// Orbital Battle Station". /// [GraphQLMember("model")] [JsonPropertyName("model")] public string Model { get; set; } /// - /// The class of this starship, such as "Starfighter" or "Deep Space Mobile -/// Battlestation" + /// The class of this starship, such as "Starfighter" or "Deep Space Mobile + /// Battlestation" /// [GraphQLMember("starshipClass")] [JsonPropertyName("starshipClass")] public string StarshipClass { get; set; } /// - /// The manufacturers of this starship. + /// The manufacturers of this starship. /// [GraphQLMember("manufacturers")] [JsonPropertyName("manufacturers")] public List Manufacturers { get; set; } /// - /// The cost of this starship new, in galactic credits. + /// The cost of this starship new, in galactic credits. /// [GraphQLMember("costInCredits")] [JsonPropertyName("costInCredits")] public double? CostInCredits { get; set; } /// - /// The length of this starship in meters. + /// The length of this starship in meters. /// [GraphQLMember("length")] [JsonPropertyName("length")] public double? Length { get; set; } /// - /// The number of personnel needed to run or pilot this starship. + /// The number of personnel needed to run or pilot this starship. /// [GraphQLMember("crew")] [JsonPropertyName("crew")] public string Crew { get; set; } /// - /// The number of non-essential people this starship can transport. + /// The number of non-essential people this starship can transport. /// [GraphQLMember("passengers")] [JsonPropertyName("passengers")] public string Passengers { get; set; } /// - /// The maximum speed of this starship in atmosphere. null if this starship is -/// incapable of atmosphering flight. + /// The maximum speed of this starship in atmosphere. null if this starship is + /// incapable of atmosphering flight. /// [GraphQLMember("maxAtmospheringSpeed")] [JsonPropertyName("maxAtmospheringSpeed")] public int? MaxAtmospheringSpeed { get; set; } /// - /// The class of this starships hyperdrive. + /// The class of this starships hyperdrive. /// [GraphQLMember("hyperdriveRating")] [JsonPropertyName("hyperdriveRating")] public double? HyperdriveRating { get; set; } /// - /// The Maximum number of Megalights this starship can travel in a standard hour. -/// A "Megalight" is a standard unit of distance and has never been defined before -/// within the Star Wars universe. This figure is only really useful for measuring -/// the difference in speed of starships. We can assume it is similar to AU, the -/// distance between our Sun (Sol) and Earth. + /// The Maximum number of Megalights this starship can travel in a standard hour. + /// A "Megalight" is a standard unit of distance and has never been defined before + /// within the Star Wars universe. This figure is only really useful for measuring + /// the difference in speed of starships. We can assume it is similar to AU, the + /// distance between our Sun (Sol) and Earth. /// [GraphQLMember("MGLT")] [JsonPropertyName("MGLT")] public int? MGLT { get; set; } /// - /// The maximum number of kilograms that this starship can transport. + /// The maximum number of kilograms that this starship can transport. /// [GraphQLMember("cargoCapacity")] [JsonPropertyName("cargoCapacity")] public double? CargoCapacity { get; set; } /// - /// The maximum length of time that this starship can provide consumables for its -/// entire crew without having to resupply. + /// The maximum length of time that this starship can provide consumables for its + /// entire crew without having to resupply. /// [GraphQLMember("consumables")] [JsonPropertyName("consumables")] public string Consumables { get; set; } - private LazyProperty _pilotConnection = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// - public StarshipPilotsConnection PilotConnection => _pilotConnection.Value(() => GetFirstMethodValue("pilotConnection")); + public StarshipPilotsConnection PilotConnection => + _pilotConnection.Value(() => GetFirstMethodValue("pilotConnection")); - private LazyProperty _filmConnection = new(); /// - /// Do not use in Query, only to retrive result + /// Do not use in Query, only to retrive result /// - public StarshipFilmsConnection FilmConnection => _filmConnection.Value(() => GetFirstMethodValue("filmConnection")); + public StarshipFilmsConnection FilmConnection => + _filmConnection.Value(() => GetFirstMethodValue("filmConnection")); /// - /// The ISO 8601 date format of the time that this resource was created. + /// The ISO 8601 date format of the time that this resource was created. /// [GraphQLMember("created")] [JsonPropertyName("created")] public string Created { get; set; } /// - /// The ISO 8601 date format of the time that this resource was edited. + /// The ISO 8601 date format of the time that this resource was edited. /// [GraphQLMember("edited")] [JsonPropertyName("edited")] public string Edited { get; set; } /// - /// The ID of an object + /// The ID of an object /// [GraphQLMember("id")] [JsonPropertyName("id")] @@ -170,4 +174,4 @@ public partial class Starship : GraphQLTypeBase, Node [GraphQLMember("__typename")] [JsonPropertyName("__typename")] public string __TypeName { get; set; } -} +} \ No newline at end of file diff --git a/docs/StarWars.Client/Generated/Types/VehicleFilmsEdge.cs b/docs/StarWars.Client/Generated/Types/VehicleFilmsEdge.cs index e9527bf0..907b1f19 100644 --- a/docs/StarWars.Client/Generated/Types/VehicleFilmsEdge.cs +++ b/docs/StarWars.Client/Generated/Types/VehicleFilmsEdge.cs @@ -5,32 +5,28 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; using Linq2GraphQL.Client.Common; namespace StarWars.Client; - /// -/// An edge in a connection. +/// An edge in a connection. /// -public partial class VehicleFilmsEdge : GraphQLTypeBase +public class VehicleFilmsEdge : GraphQLTypeBase { /// - /// The item at the end of the edge + /// The item at the end of the edge /// [GraphQLMember("node")] [JsonPropertyName("node")] public Film Node { get; set; } /// - /// A cursor for use in pagination + /// A cursor for use in pagination /// [GraphQLMember("cursor")] [JsonPropertyName("cursor")] public string Cursor { get; set; } - -} +} \ No newline at end of file diff --git a/docs/StarWars.Client/ReadMe.md b/docs/StarWars.Client/ReadMe.md index b2cee588..4cbf5a74 100644 --- a/docs/StarWars.Client/ReadMe.md +++ b/docs/StarWars.Client/ReadMe.md @@ -1,6 +1,8 @@ ### Upgrade Tool + dotnet tool update Linq2GraphQL.Generator -g --prerelease ### Update Schema + Linq2GraphQL https://swapi-graphql.netlify.app/graphql -c="StarWarsClient" -n="StarWars.Client" -o="Generated" -es="AddUnknownOption" diff --git a/docs/StarWars.Client/StarWars.Client.csproj b/docs/StarWars.Client/StarWars.Client.csproj index 65043f78..1a444581 100644 --- a/docs/StarWars.Client/StarWars.Client.csproj +++ b/docs/StarWars.Client/StarWars.Client.csproj @@ -1,14 +1,14 @@  - - net8.0 - enable - disable - + + net9.0 + enable + disable + - - - - + + + + diff --git a/nuget.config b/nuget.config index 55dcc87d..f75991bf 100644 --- a/nuget.config +++ b/nuget.config @@ -1,10 +1,10 @@  - - - - - - - + + + + + + + \ No newline at end of file diff --git a/src/Linq2GraphQL.Client.Subscriptions/Linq2GraphQL.Client.Subscriptions.csproj b/src/Linq2GraphQL.Client.Subscriptions/Linq2GraphQL.Client.Subscriptions.csproj index 4b5244eb..31c169ef 100644 --- a/src/Linq2GraphQL.Client.Subscriptions/Linq2GraphQL.Client.Subscriptions.csproj +++ b/src/Linq2GraphQL.Client.Subscriptions/Linq2GraphQL.Client.Subscriptions.csproj @@ -1,26 +1,26 @@ - net8.0 + net9.0 enable - - Joakim Dangården,Magnus Ahlberg - Linq2GraphQL - git - https://github.com/linq2graphql/linq2graphql.client - https://linq2graphql.com/ - Linq2GraphQL.Client.Subscriptions - Linq2GraphQL Subscription support - Copyright 2023 (c) Joakim Dangården. All rights reserved. - Linq GraphQL Client Subscriptions + + Joakim Dangården,Magnus Ahlberg + Linq2GraphQL + git + https://github.com/linq2graphql/linq2graphql.client + https://linq2graphql.com/ + Linq2GraphQL.Client.Subscriptions + Linq2GraphQL Subscription support + Copyright 2023 (c) Joakim Dangården. All rights reserved. + Linq GraphQL Client Subscriptions - + - + diff --git a/src/Linq2GraphQL.Client/Attributes/GraphQLMemberAttribute.cs b/src/Linq2GraphQL.Client/Attributes/GraphQLMemberAttribute.cs index 28b5e375..36bb92a0 100644 --- a/src/Linq2GraphQL.Client/Attributes/GraphQLMemberAttribute.cs +++ b/src/Linq2GraphQL.Client/Attributes/GraphQLMemberAttribute.cs @@ -1,6 +1,4 @@ -using System.Text.Json.Serialization; - -namespace Linq2GraphQL.Client; +namespace Linq2GraphQL.Client; [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] public class GraphQLMemberAttribute : Attribute @@ -11,4 +9,4 @@ public GraphQLMemberAttribute(string graphQLName) } public string GraphQLName { get; private set; } -} +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Client/Common/CustomScalar.cs b/src/Linq2GraphQL.Client/Common/CustomScalar.cs index 988068eb..3cbd1a8a 100644 --- a/src/Linq2GraphQL.Client/Common/CustomScalar.cs +++ b/src/Linq2GraphQL.Client/Common/CustomScalar.cs @@ -1,20 +1,18 @@ -namespace Linq2GraphQL.Client -{ - public class CustomScalar - { - internal object InternalValue { get; set; } +namespace Linq2GraphQL.Client; - public override string ToString() - { - return InternalValue?.ToString(); - } +public class CustomScalar +{ + internal object InternalValue { get; set; } - public virtual object Value - { - get { return InternalValue; } + public virtual object Value + { + get => InternalValue; - set { InternalValue = value; } + set => InternalValue = value; + } - } + public override string ToString() + { + return InternalValue?.ToString(); } -} +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Client/Converters/CustomScalarConverter.cs b/src/Linq2GraphQL.Client/Converters/CustomScalarConverter.cs index 04cff7ed..f45cc96e 100644 --- a/src/Linq2GraphQL.Client/Converters/CustomScalarConverter.cs +++ b/src/Linq2GraphQL.Client/Converters/CustomScalarConverter.cs @@ -1,46 +1,41 @@ -using System.Text.Json.Serialization; -using System.Text.Json; -using Linq2GraphQL.Client; +using System.Text.Json; +using System.Text.Json.Serialization; +namespace Linq2GraphQL.Client; -namespace Linq2GraphQL.Client +public class CustomScalarConverter : JsonConverter + where TScalar : CustomScalar, new() { - - public class CustomScalarConverter : JsonConverter - where TScalar : CustomScalar, new() + public override TScalar Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - public override TScalar Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + object value = null; + switch (reader.TokenType) { - object value = null; - switch (reader.TokenType) - { - case JsonTokenType.Null: - case JsonTokenType.None: - return null; - case JsonTokenType.String: - value = reader.GetString(); - break; - case JsonTokenType.Number: - value = reader.GetDecimal(); - break; - case JsonTokenType.True: - value = true; - break; - case JsonTokenType.False: - value = false; - break; - default: - value = JsonDocument.ParseValue(ref reader); - break; - } - - return new TScalar { Value = value }; + case JsonTokenType.Null: + case JsonTokenType.None: + return null; + case JsonTokenType.String: + value = reader.GetString(); + break; + case JsonTokenType.Number: + value = reader.GetDecimal(); + break; + case JsonTokenType.True: + value = true; + break; + case JsonTokenType.False: + value = false; + break; + default: + value = JsonDocument.ParseValue(ref reader); + break; } - public override void Write(Utf8JsonWriter writer, TScalar value, JsonSerializerOptions options) - { - writer.WriteStringValue(value.InternalValue?.ToString()); - } + return new() { Value = value }; + } + public override void Write(Utf8JsonWriter writer, TScalar value, JsonSerializerOptions options) + { + writer.WriteStringValue(value.InternalValue?.ToString()); } -} +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Client/Converters/InterfaceConverter.cs b/src/Linq2GraphQL.Client/Converters/InterfaceConverter.cs index dfd8a3ae..7027a5c3 100644 --- a/src/Linq2GraphQL.Client/Converters/InterfaceConverter.cs +++ b/src/Linq2GraphQL.Client/Converters/InterfaceConverter.cs @@ -1,72 +1,61 @@ -using System.Text.Json.Serialization; -using System.Text.Json; +using System.Text.Json; using System.Text.Json.Nodes; +using System.Text.Json.Serialization; -namespace Linq2GraphQL.Client.Converters +namespace Linq2GraphQL.Client.Converters; + +public class InterfaceConverter : JsonConverter + where TImplementation : class, TInterface { - public class InterfaceConverter : JsonConverter where TImplementation : class, TInterface + public override TInterface Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - public override TInterface Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - => JsonSerializer.Deserialize(ref reader, options); + return JsonSerializer.Deserialize(ref reader, options); + } - public override void Write(Utf8JsonWriter writer, TInterface value, JsonSerializerOptions options) - { - } + public override void Write(Utf8JsonWriter writer, TInterface value, JsonSerializerOptions options) + { } +} - public abstract class InterfaceJsonConverter : JsonConverter +public abstract class InterfaceJsonConverter : JsonConverter +{ + public override T Read(ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options) { - public override T Read(ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options) + var json = JsonSerializer.Deserialize(ref reader); + if (json is null) { - var json = JsonSerializer.Deserialize(ref reader); - if (json is null) - { - return default; - } - - if (!json.ContainsKey("__typename")) - { - return default; - } + return default; + } - var type = json["__typename"]!.ToString(); - var value = Deserialize(type, json); - return value; + if (!json.ContainsKey("__typename")) + { + return default; } - public abstract T Deserialize(string typeName, JsonObject json); + var type = json["__typename"]!.ToString(); + var value = Deserialize(type, json); + return value; + } + + public abstract T Deserialize(string typeName, JsonObject json); - public override void Write( - Utf8JsonWriter writer, - T value, - JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + T value, + JsonSerializerOptions options) + { + switch (value) { - switch (value) + case null: + JsonSerializer.Serialize(writer, default!, options); + break; + default: { - case null: - JsonSerializer.Serialize(writer, default!, options); - break; - default: - { - JsonSerializer.Serialize(writer, value, value.GetType(), options); - break; - } + JsonSerializer.Serialize(writer, value, value.GetType(), options); + break; } } } - - -} - - - - - - - - - - - +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Client/Exceptions/GraphQueryExecutionException.cs b/src/Linq2GraphQL.Client/Exceptions/GraphQueryExecutionException.cs index 7e92c541..a3f85b0e 100644 --- a/src/Linq2GraphQL.Client/Exceptions/GraphQueryExecutionException.cs +++ b/src/Linq2GraphQL.Client/Exceptions/GraphQueryExecutionException.cs @@ -4,13 +4,15 @@ namespace Linq2GraphQL.Client; public class GraphQueryExecutionException : Exception { - public GraphQueryExecutionException(string query, Dictionary variables) : base("Unexpected error response received from server.") + public GraphQueryExecutionException(string query, Dictionary variables) : base( + "Unexpected error response received from server.") { GraphQLQuery = query; GraphQLVariables = variables; } - public GraphQueryExecutionException(IEnumerable errors, string query, Dictionary variables) + public GraphQueryExecutionException(IEnumerable errors, string query, + Dictionary variables) : base($"{errors.FirstOrDefault()?.Message} - Check {nameof(Errors)} property for details") { Errors = errors; @@ -30,7 +32,7 @@ public class GraphQueryError [JsonPropertyName("locations")] public ErrorLocation[] Locations { get; set; } - [JsonPropertyName("path")] public List Path { get; set; } + [JsonPropertyName("path")] public List Path { get; set; } } public class ErrorLocation diff --git a/src/Linq2GraphQL.Client/Exceptions/GraphQueryRequestException.cs b/src/Linq2GraphQL.Client/Exceptions/GraphQueryRequestException.cs index a0d6540c..0c5ea20b 100644 --- a/src/Linq2GraphQL.Client/Exceptions/GraphQueryRequestException.cs +++ b/src/Linq2GraphQL.Client/Exceptions/GraphQueryRequestException.cs @@ -2,7 +2,8 @@ public class GraphQueryRequestException : Exception { - public GraphQueryRequestException(string message, string query, Dictionary variables) : base(message) + public GraphQueryRequestException(string message, string query, Dictionary variables) : + base(message) { GraphQLQuery = query; GraphQLVariables = variables; diff --git a/src/Linq2GraphQL.Client/Extensions.cs b/src/Linq2GraphQL.Client/Extensions.cs index e22b8f50..b9e1586c 100644 --- a/src/Linq2GraphQL.Client/Extensions.cs +++ b/src/Linq2GraphQL.Client/Extensions.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System; namespace Linq2GraphQL.Client; @@ -12,7 +11,8 @@ internal static bool IsValueTypeOrString(this Type type) return false; } - return type.IsValueType || type == typeof(string) || type.IsSubclassOf(typeof(CustomScalar)); ; + return type.IsValueType || type == typeof(string) || type.IsSubclassOf(typeof(CustomScalar)); + ; } internal static bool IsListOfPrimitiveTypeOrString(this Type type) @@ -57,9 +57,9 @@ internal static Type GetUnderlyingType(this MemberInfo member) MemberTypes.Method => ((MethodInfo)member).ReturnType, MemberTypes.Property => ((PropertyInfo)member).PropertyType, _ => throw new ArgumentException - ( - "Input MemberInfo must be if type TypeInfo, EventInfo, FieldInfo, MethodInfo, or PropertyInfo" - ), + ( + "Input MemberInfo must be if type TypeInfo, EventInfo, FieldInfo, MethodInfo, or PropertyInfo" + ) }; } } \ No newline at end of file diff --git a/src/Linq2GraphQL.Client/GraphBase.cs b/src/Linq2GraphQL.Client/GraphBase.cs index 03c7e948..b81c8b8a 100644 --- a/src/Linq2GraphQL.Client/GraphBase.cs +++ b/src/Linq2GraphQL.Client/GraphBase.cs @@ -1,44 +1,40 @@ using System.Linq.Expressions; -namespace Linq2GraphQL.Client +namespace Linq2GraphQL.Client; + +public abstract class GraphBase { - public abstract class GraphBase + protected readonly GraphClient client; + protected readonly OperationType operationType; + + public GraphBase(GraphClient client, string name, OperationType operationType, List arguments) { - protected readonly GraphClient client; - protected readonly OperationType operationType; - - public GraphBase(GraphClient client, string name, OperationType operationType, List arguments) - { - this.client = client; - this.operationType = operationType; - QueryNode = new QueryNode(typeof(T), name, arguments, false, true); - - } - - public QueryNode QueryNode { get; } - - - /// - /// Include top node - /// - /// - public TGraph Include() - { - QueryNode.IncludePrimitive = true; - return (TGraph)(object)this; - } - - public TGraph Include(Expression> path) - { - Utilities.ParseExpression(path, QueryNode); - return (TGraph)(object)this; - } - - public void ParseExpression(Expression body) - { - Utilities.ParseExpression(body, QueryNode); - } + this.client = client; + this.operationType = operationType; + QueryNode = new(typeof(T), name, arguments, false, true); + } + public QueryNode QueryNode { get; } + + /// + /// Include top node + /// + /// + public TGraph Include() + { + QueryNode.IncludePrimitive = true; + return (TGraph)(object)this; + } + + public TGraph Include(Expression> path) + { + Utilities.ParseExpression(path, QueryNode); + return (TGraph)(object)this; + } + + public void ParseExpression(Expression body) + { + Utilities.ParseExpression(body, QueryNode); } -} +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Client/GraphClient.cs b/src/Linq2GraphQL.Client/GraphClient.cs index d3e0e294..e5f2925d 100644 --- a/src/Linq2GraphQL.Client/GraphClient.cs +++ b/src/Linq2GraphQL.Client/GraphClient.cs @@ -14,7 +14,8 @@ public class GraphClient private readonly IOptions options; private readonly bool includeDeprecated; - public GraphClient(HttpClient httpClient, IOptions options, IServiceProvider provider, bool includeDeprecated = false) + public GraphClient(HttpClient httpClient, IOptions options, IServiceProvider provider, + bool includeDeprecated = false) { this.options = options; this.includeDeprecated = includeDeprecated; @@ -25,11 +26,7 @@ public GraphClient(HttpClient httpClient, IOptions options, HttpClient = httpClient; - SerializerOptions = new() - { - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - Converters = { }, - }; + SerializerOptions = new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, Converters = { }, }; SubscriptionUrl = GetSubscriptionUrl(); } @@ -38,9 +35,10 @@ public GraphClient(HttpClient httpClient, IOptions options, public SubscriptionProtocol SubscriptionProtocol => options.Value.SubscriptionProtocol; public HttpClient HttpClient { get; } public JsonSerializerOptions SerializerOptions { get; } - + public Func> WSConnectionInitPayload => options.Value.WSConnectionInitPayload; + private string GetSubscriptionUrl() { var baseUrl = HttpClient?.BaseAddress.ToString(); @@ -85,7 +83,7 @@ public async Task GetSchemaForSafeModeAsync() query = Helpers.SchemaQuery; } - var graphRequest = new GraphQLRequest { Query = query }; + var graphRequest = new GraphQLRequest { Query = query }; return await executor.ExecuteRequestAsync("__schema", graphRequest); }); } diff --git a/src/Linq2GraphQL.Client/GraphCursorQuery.cs b/src/Linq2GraphQL.Client/GraphCursorQuery.cs index 28992139..a8843c0c 100644 --- a/src/Linq2GraphQL.Client/GraphCursorQuery.cs +++ b/src/Linq2GraphQL.Client/GraphCursorQuery.cs @@ -1,23 +1,24 @@ -using Linq2GraphQL.Client.Common; -using System.Linq.Expressions; +using System.Linq.Expressions; +using Linq2GraphQL.Client.Common; namespace Linq2GraphQL.Client; public class GraphCursorQuery : GraphBase> where T : ICursorPaging { - public GraphCursorQuery(GraphClient client, string name, OperationType operationType, List arguments) : base(client, name, operationType, arguments) + public GraphCursorQuery(GraphClient client, string name, OperationType operationType, List arguments) + : base(client, name, operationType, arguments) { } public GraphCursorQueryExecute Select() { QueryNode.IncludePrimitiveIfNoChildPrimitive(); - return new GraphCursorQueryExecute(client, operationType, QueryNode, null); + return new(client, operationType, QueryNode, null); } public GraphCursorQueryExecute Select(Expression> selector) { ParseExpression(selector); - return new GraphCursorQueryExecute(client, operationType, QueryNode, selector); + return new(client, operationType, QueryNode, selector); } -} +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Client/HttpClientBuilderExtensions.cs b/src/Linq2GraphQL.Client/HttpClientBuilderExtensions.cs index d9a4a439..60dc4392 100644 --- a/src/Linq2GraphQL.Client/HttpClientBuilderExtensions.cs +++ b/src/Linq2GraphQL.Client/HttpClientBuilderExtensions.cs @@ -30,4 +30,28 @@ public static IHttpClientBuilder WithHttpClient( return builder; } + + public static IHttpClientBuilder WithHttpClient( + this IGraphClientBuilder clientBuilder, + string httpClientName, + Action configureClient, + Action configureClientBuilder = null) where T : class + { + var builder = clientBuilder.Services + .AddHttpClient( + httpClientName, + client => + { + client.DefaultRequestHeaders.UserAgent.Add( + new ProductInfoHeaderValue( + new ProductHeaderValue( + userAgentName, + userAgentVersion))); + configureClient(client); + }); + + configureClientBuilder?.Invoke(builder); + + return builder; + } } \ No newline at end of file diff --git a/src/Linq2GraphQL.Client/Linq2GraphQL.Client.csproj b/src/Linq2GraphQL.Client/Linq2GraphQL.Client.csproj index e5f1a536..9bc82f2a 100644 --- a/src/Linq2GraphQL.Client/Linq2GraphQL.Client.csproj +++ b/src/Linq2GraphQL.Client/Linq2GraphQL.Client.csproj @@ -1,22 +1,22 @@ - net8.0 + net9.0 enable Joakim Dangården,Magnus Ahlberg Linq2GraphQL git https://github.com/linq2graphql/linq2graphql.client https://linq2graphql.com/ - Linq2GraphQL.Client + Linq2GraphQL.Client Linq to graphql client Copyright 2023 (c) Joakim Dangården. All rights reserved. Linq GraphQL Client - - + + diff --git a/src/Linq2GraphQL.Client/QueryExecutor.cs b/src/Linq2GraphQL.Client/QueryExecutor.cs index 6a41210e..28d46a0b 100644 --- a/src/Linq2GraphQL.Client/QueryExecutor.cs +++ b/src/Linq2GraphQL.Client/QueryExecutor.cs @@ -5,10 +5,10 @@ namespace Linq2GraphQL.Client; public class QueryExecutor { - private const string errorPropertyName = "errors"; - private const string dataPropertyName = "data"; - private const string extensionsPropertyName = "extensions"; - + private const string ErrorPropertyName = "errors"; + private const string DataPropertyName = "data"; + private const string ExtensionsPropertyName = "extensions"; + private readonly GraphClient client; internal QueryExecutor(GraphClient client) @@ -16,9 +16,11 @@ internal QueryExecutor(GraphClient client) this.client = client; } - internal async Task ExecuteRequestAsync(string name, GraphQLRequest graphRequest, CancellationToken cancellationToken = default) + internal async Task ExecuteRequestAsync(string name, GraphQLRequest graphRequest, + CancellationToken cancellationToken = default) { - using var response = await client.HttpClient.PostAsJsonAsync("", graphRequest, client.SerializerOptions, cancellationToken: cancellationToken); + using var response = await client.HttpClient.PostAsJsonAsync("", graphRequest, client.SerializerOptions, + cancellationToken: cancellationToken); if (!response.IsSuccessStatusCode) { @@ -34,8 +36,7 @@ internal async Task ExecuteRequestAsync(string name, GraphQLRequest graphRequ public T ProcessResponse(string con, string name, GraphQLRequest request) { var document = JsonDocument.Parse(con); - var hasError = document.RootElement.TryGetProperty(errorPropertyName, out var errorElement); - var hasExtensions = document.RootElement.TryGetProperty(extensionsPropertyName, out var extensionsElement); + var hasError = document.RootElement.TryGetProperty(ErrorPropertyName, out var errorElement); if (hasError) { @@ -43,7 +44,7 @@ public T ProcessResponse(string con, string name, GraphQLRequest request) throw new GraphQueryExecutionException(errors, request.Query, request.Variables); } - document.RootElement.TryGetProperty(dataPropertyName, out var dataElement); + document.RootElement.TryGetProperty(DataPropertyName, out var dataElement); dataElement.TryGetProperty(name, out var resultElement); if (resultElement.ValueKind == JsonValueKind.Null) @@ -52,6 +53,5 @@ public T ProcessResponse(string con, string name, GraphQLRequest request) } return resultElement.Deserialize(client.SerializerOptions); - } -} +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Client/QueryNode.cs b/src/Linq2GraphQL.Client/QueryNode.cs index 4f5b69e2..adfcdaef 100644 --- a/src/Linq2GraphQL.Client/QueryNode.cs +++ b/src/Linq2GraphQL.Client/QueryNode.cs @@ -1,7 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; -using System.Text.Json.Serialization; -using Linq2GraphQL.Client; using Linq2GraphQL.Client.Schema; namespace Linq2GraphQL.Client; @@ -12,7 +9,8 @@ public class QueryNode private readonly Type underlyingMemberType; private string argumentHashCodeId; - public QueryNode(MemberInfo member, string name = null, List arguments = null, bool interfaceProperty = false, bool topLevel = false) + public QueryNode(MemberInfo member, string name = null, List arguments = null, + bool interfaceProperty = false, bool topLevel = false) { Name = name ?? member.GetCustomAttribute()?.GraphQLName ?? member.Name.ToCamelCase(); Member = member; @@ -21,7 +19,8 @@ public QueryNode(MemberInfo member, string name = null, List argu mustHaveChildren = MustHaveChildren(underlyingMemberType); InterfaceProperty = interfaceProperty; - if (!topLevel) { + if (!topLevel) + { SetArgumentHashCodeId(); } } @@ -29,7 +28,7 @@ public QueryNode(MemberInfo member, string name = null, List argu public bool InterfaceProperty { get; internal set; } public string Name { get; internal set; } public string Alias { get; internal set; } - + public MemberInfo Member { get; internal set; } public List ChildNodes { get; internal set; } = new(); public List Arguments { get; internal set; } = new(); @@ -37,6 +36,9 @@ public QueryNode(MemberInfo member, string name = null, List argu public QueryNode Parent { get; private set; } + public int Level => Parent?.Level + 1 ?? 1; + public int Leaf { get; internal set; } = 1; + internal void IncludePrimitiveIfNoChildPrimitive() { @@ -48,7 +50,7 @@ internal void IncludePrimitiveIfNoChildPrimitive() private void SetArgumentHashCodeId() { - argumentHashCodeId = Utilities.GetArgumentsId(Arguments?.Select(e=> e.Value)); + argumentHashCodeId = Utilities.GetArgumentsId(Arguments?.Select(e => e.Value)); if (argumentHashCodeId != null) { Alias = Name + argumentHashCodeId; @@ -65,15 +67,13 @@ private static bool MustHaveChildren(Type type) public void AddChildNode(MemberInfo member, string name = null) { - AddChildNode(new QueryNode(member, name)); + AddChildNode(new(member, name)); } - public int Level => Parent?.Level + 1 ?? 1; - public int Leaf { get; internal set; } = 1; - public QueryNode AddChildNode(QueryNode childNode) { - var currentNode = ChildNodes.FirstOrDefault(e => e.Name == childNode.Name && e.argumentHashCodeId == childNode.argumentHashCodeId); + var currentNode = ChildNodes.FirstOrDefault(e => + e.Name == childNode.Name && e.argumentHashCodeId == childNode.argumentHashCodeId); if (currentNode == null) { childNode.Parent = this; @@ -81,7 +81,8 @@ public QueryNode AddChildNode(QueryNode childNode) ChildNodes.Add(childNode); return childNode; } - else if (childNode.IncludePrimitive) + + if (childNode.IncludePrimitive) { currentNode.IncludePrimitive = true; } @@ -92,7 +93,6 @@ public QueryNode AddChildNode(QueryNode childNode) } return currentNode; - } public void SetArgumentValue(string graphName, object value) @@ -119,7 +119,6 @@ public void AddPrimitiveChildren(bool recursive, GraphQLSchema schema) var typeOrListType = underlyingMemberType.GetTypeOrListType(); foreach (var propertyInfo in typeOrListType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { - if (!propertyInfo.PropertyType.IsValueTypeOrString()) { continue; @@ -164,7 +163,6 @@ internal void SetAllUniqueVariableNames() { child.SetAllUniqueVariableNames(); } - } public List GetActiveArguments() @@ -179,12 +177,14 @@ public List GetAllActiveArguments() { allArguments.AddRange(childNode.GetAllActiveArguments()); } + return allArguments; } private string GetArgumentString() { - var args = GetActiveArguments(); ; + var args = GetActiveArguments(); + ; if (!args.Any()) { return ""; @@ -195,6 +195,7 @@ private string GetArgumentString() { argString += arg.GraphName + ":$" + arg.VariableName + " "; } + argString.TrimEnd(); argString += ")"; @@ -202,8 +203,6 @@ private string GetArgumentString() } - - internal string GetQueryString(string indent = "") { string query; @@ -212,7 +211,6 @@ internal string GetQueryString(string indent = "") if (InterfaceProperty) { query = "... on " + Name + GetArgumentString() + Environment.NewLine; - } else if (!string.IsNullOrWhiteSpace(Alias)) { diff --git a/src/Linq2GraphQL.Client/Visitors/ParameterVisitor.cs b/src/Linq2GraphQL.Client/Visitors/ParameterVisitor.cs index d3d94981..9b968863 100644 --- a/src/Linq2GraphQL.Client/Visitors/ParameterVisitor.cs +++ b/src/Linq2GraphQL.Client/Visitors/ParameterVisitor.cs @@ -1,170 +1,164 @@ -using Linq2GraphQL.Client; -using System.Linq.Expressions; +using System.Linq.Expressions; using System.Reflection; -using System.Reflection.Metadata; using System.Runtime.CompilerServices; -using System.Xml.Linq; -namespace Linq2GraphQL.Client.Visitors +namespace Linq2GraphQL.Client.Visitors; + +internal class ParameterVisitor(MemberNode memberNode) : ExpressionVisitor { - internal class ParameterVisitor(MemberNode memberNode) : ExpressionVisitor + public MemberNode ParseExpression(Expression expression) { + Visit(expression); + return memberNode; + } - public MemberNode ParseExpression(Expression expression) - { - Visit(expression); - return memberNode; - } + protected override Expression VisitMember(MemberExpression node) + { + var attribute = node.Member.GetCustomAttribute(); - protected override Expression VisitMember(MemberExpression node) + if (attribute != null) { - var attribute = node.Member.GetCustomAttribute(); + var parameter = GetParameterExpression(node); + AddMemberNodes(parameter, node); + } - if (attribute != null) - { - var parameter = GetParameterExpression(node); - AddMemberNodes(parameter, node); - } + return node; + } - return node; - } + public MemberNode AddMemberNodes(ParameterExpression targetParameter, Expression expression) + { + var targetNode = memberNode.GetMemberNodeFromParameterExpression(targetParameter); + var newNode = targetNode.AddMembers(expression); + return newNode; + } - public MemberNode AddMemberNodes(ParameterExpression targetParameter, Expression expression) - { - var targetNode = memberNode.GetMemberNodeFromParameterExpression(targetParameter); - var newNode = targetNode.AddMembers(expression); - return newNode; - } + protected override Expression VisitMethodCall(MethodCallExpression expression) + { + var attribute = expression.Method.GetCustomAttribute(); - protected override Expression VisitMethodCall(MethodCallExpression expression) + if (attribute != null) { - var attribute = expression.Method.GetCustomAttribute(); - - if (attribute != null) + var parExp = GetParameterExpression(expression); + var i = 0; + var argumentValues = new List(); + foreach (var parameter in expression.Method.GetParameters()) { - var parExp = GetParameterExpression(expression); - var i = 0; - var argumentValues = new List(); - foreach (var parameter in expression.Method.GetParameters()) + var graphQLArgumentAttribute = parameter.GetCustomAttribute(); + if (graphQLArgumentAttribute != null) { - var graphQLArgumentAttribute = parameter.GetCustomAttribute(); - if (graphQLArgumentAttribute != null) - { - var arg = expression.Arguments[i]; - var v = GetArgumentValue(arg); - argumentValues.Add(new ArgumentValue(graphQLArgumentAttribute.GraphQLName, graphQLArgumentAttribute.GraphQLType, GetArgumentValue(arg))); - } - i++; + var arg = expression.Arguments[i]; + var v = GetArgumentValue(arg); + argumentValues.Add(new(graphQLArgumentAttribute.GraphQLName, graphQLArgumentAttribute.GraphQLType, + GetArgumentValue(arg))); } - var targetNode = memberNode.GetMemberNodeFromParameterExpression(parExp); - targetNode.AddChild(new MemberNode(expression.Method, argumentValues)); + i++; + } + var targetNode = memberNode.GetMemberNodeFromParameterExpression(parExp); + targetNode.AddChild(new(expression.Method, argumentValues)); - return expression; - } - if (IsLinqOperator(expression.Method)) - { - var memberExp = expression.Arguments[0] as MemberExpression; - var attr = memberExp?.Member.GetCustomAttribute(); + return expression; + } - if (attr != null) - { - var parameter = GetParameterExpression(expression.Arguments[1]); - var child = memberNode.AddMembers(memberExp); - child.SetParameterExpression(parameter); + if (IsLinqOperator(expression.Method)) + { + var memberExp = expression.Arguments[0] as MemberExpression; + var attr = memberExp?.Member.GetCustomAttribute(); - var visitor = new ParameterVisitor(child); - visitor.ParseExpression(expression.Arguments[1]); - return expression; - } + if (attr != null) + { + var parameter = GetParameterExpression(expression.Arguments[1]); + var child = memberNode.AddMembers(memberExp); + child.SetParameterExpression(parameter); + var visitor = new ParameterVisitor(child); + visitor.ParseExpression(expression.Arguments[1]); + return expression; } - return base.VisitMethodCall(expression); } + return base.VisitMethodCall(expression); + } - protected override Expression VisitLambda(Expression node) - { - var newExp = node.Body as NewExpression; - return base.VisitLambda(node); - } - - //protected override Expression VisitNew(NewExpression node) - //{ + protected override Expression VisitLambda(Expression node) + { + var newExp = node.Body as NewExpression; + return base.VisitLambda(node); + } - // if (memberNode.ParameterName != null && node.Arguments.Any(e=> e.NodeType == ExpressionType.Parameter)) - // { + //protected override Expression VisitNew(NewExpression node) + //{ + // if (memberNode.ParameterName != null && node.Arguments.Any(e=> e.NodeType == ExpressionType.Parameter)) + // { - // } + // } - // return base.VisitNew(node); - //} + // return base.VisitNew(node); + //} - private static object GetArgumentValue(Expression element) + private static object GetArgumentValue(Expression element) + { + if (element is ConstantExpression) { - if (element is ConstantExpression) - { - return (element as ConstantExpression).Value; - } - - var l = Expression.Lambda(Expression.Convert(element, element.Type)); - return l.Compile().DynamicInvoke(); + return (element as ConstantExpression).Value; } + var l = Expression.Lambda(Expression.Convert(element, element.Type)); + return l.Compile().DynamicInvoke(); + } - private ParameterExpression GetParameterExpression(Expression expression) + + private ParameterExpression GetParameterExpression(Expression expression) + { + if (expression == null) { - if (expression == null) - { - return null; - } + return null; + } - if (expression.NodeType == ExpressionType.Parameter) - { - return expression as ParameterExpression; - } - else if (expression.NodeType == ExpressionType.MemberAccess) - { - var member = (MemberExpression)expression; - return GetParameterExpression(member.Expression); - } - else if (expression.NodeType == ExpressionType.Lambda) - { - var member = (LambdaExpression)expression; - return GetParameterExpression(member.Parameters[0]); - } - else if (expression.NodeType == ExpressionType.Call) - { - var member = (MethodCallExpression)expression; + if (expression.NodeType == ExpressionType.Parameter) + { + return expression as ParameterExpression; + } - if (member.Object != null) - { - return GetParameterExpression(member.Object); - } + if (expression.NodeType == ExpressionType.MemberAccess) + { + var member = (MemberExpression)expression; + return GetParameterExpression(member.Expression); + } - return GetParameterExpression(member.Arguments[0]); + if (expression.NodeType == ExpressionType.Lambda) + { + var member = (LambdaExpression)expression; + return GetParameterExpression(member.Parameters[0]); + } - } + if (expression.NodeType == ExpressionType.Call) + { + var member = (MethodCallExpression)expression; + if (member.Object != null) + { + return GetParameterExpression(member.Object); + } - return null; + return GetParameterExpression(member.Arguments[0]); } - private static bool IsLinqOperator(MethodInfo method) - { - if (method.DeclaringType != typeof(Queryable) && method.DeclaringType != typeof(Enumerable)) - return false; - return Attribute.GetCustomAttribute(method, typeof(ExtensionAttribute)) != null; - } + return null; } - -} + private static bool IsLinqOperator(MethodInfo method) + { + if (method.DeclaringType != typeof(Queryable) && method.DeclaringType != typeof(Enumerable)) + return false; + return Attribute.GetCustomAttribute(method, typeof(ExtensionAttribute)) != null; + } +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Generator/ClientGenerator.cs b/src/Linq2GraphQL.Generator/ClientGenerator.cs index 9fe195ec..55ec6eb5 100644 --- a/src/Linq2GraphQL.Generator/ClientGenerator.cs +++ b/src/Linq2GraphQL.Generator/ClientGenerator.cs @@ -10,8 +10,13 @@ namespace Linq2GraphQL.Generator { - public class ClientGenerator(string namespaceName, string clientName, bool includeSubscriptions, - EnumGeneratorStrategy enumGeneratorStrategy, bool nullable, bool includeDeprecated) + public class ClientGenerator( + string namespaceName, + string clientName, + bool includeSubscriptions, + EnumGeneratorStrategy enumGeneratorStrategy, + bool nullable, + bool includeDeprecated) { private readonly List entries = new(); @@ -52,7 +57,7 @@ public async Task> GenerateAsync(Uri uri, string authToken = nul query = General.IntrospectionQuery; } - using var response = await httpClient.PostAsJsonAsync(uri, new { query = query }); + using var response = await httpClient.PostAsJsonAsync(uri, new { query = query }); if (!response.IsSuccessStatusCode) { throw new Exception( @@ -105,8 +110,10 @@ public List Generate(string schemaJson) Console.WriteLine("Generate Interfaces"); var classInterfacesList = schema.GetClassTypes()?.Where(e => e.HasInterfaces) - ?.SelectMany(i => i.Interfaces?.ToDictionary(e => i.Name, e => e.Name))?.ToList() ?? new List>(); - + ?.SelectMany(i => i.Interfaces?.ToDictionary(e => i.Name, e => e.Name)) + ?.ToList() ?? + new List>(); + var interfaces = schema.GetInterfaces(); if (interfaces != null) { @@ -149,7 +156,6 @@ public List Generate(string schemaJson) } - Console.WriteLine("Generate Enums..."); foreach (var enumType in schema.GetEnums()) { @@ -172,18 +178,19 @@ public List Generate(string schemaJson) { var scalarText = new ScalarTemplate(scalar, namespaceName).TransformText(); AddFile("Scalars", scalar.FileName, scalarText); - } Console.WriteLine("Generate Client Interface..."); - var clientInterfaceText = new IClientTemplate(namespaceName, clientName, queryType, mutationType, subscriptionType, includeDeprecated) + var clientInterfaceText = new IClientTemplate(namespaceName, clientName, queryType, mutationType, + subscriptionType, includeDeprecated) .TransformText(); var interfaceFileName = "I" + clientName + ".cs"; AddFile("Interfaces", interfaceFileName, clientInterfaceText); Console.WriteLine("Generate Client..."); - var templateText = new ClientTemplate(namespaceName, clientName, queryType, mutationType, subscriptionType, includeDeprecated) + var templateText = new ClientTemplate(namespaceName, clientName, queryType, mutationType, subscriptionType, + includeDeprecated, nullable: nullable) .TransformText(); var fileName = clientName + ".cs"; AddFile(clientDirName, fileName, templateText); diff --git a/src/Linq2GraphQL.Generator/FileEntry.cs b/src/Linq2GraphQL.Generator/FileEntry.cs index a0dd5656..a413911f 100644 --- a/src/Linq2GraphQL.Generator/FileEntry.cs +++ b/src/Linq2GraphQL.Generator/FileEntry.cs @@ -1,15 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace Linq2GraphQL.Generator; -namespace Linq2GraphQL.Generator +public class FileEntry { - public class FileEntry - { - public string FileName { get; set; } - public string DirectoryName { get; set; } - public string Content { get; set; } - } -} + public string FileName { get; set; } + public string DirectoryName { get; set; } + public string Content { get; set; } +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Generator/GraphQLSchema/Helpers.cs b/src/Linq2GraphQL.Generator/GraphQLSchema/Helpers.cs index bd8a1c31..dbeedfc1 100644 --- a/src/Linq2GraphQL.Generator/GraphQLSchema/Helpers.cs +++ b/src/Linq2GraphQL.Generator/GraphQLSchema/Helpers.cs @@ -110,7 +110,6 @@ internal static string SafeVariableName(string name) { "Int", new ValueTuple("int", typeof(int)) }, { "Float", new ValueTuple("double", typeof(double)) }, { "String", new ValueTuple("string", typeof(string)) }, - // { "ID", new ValueTuple("string", typeof(string)) }, { "Date", new ValueTuple("DateTime", typeof(DateTime)) }, { "Boolean", new ValueTuple("bool", typeof(bool)) }, { "Long", new ValueTuple("long", typeof(long)) }, @@ -121,6 +120,9 @@ internal static string SafeVariableName(string name) { "Decimal", new ValueTuple("decimal", typeof(decimal)) }, { "TimeSpan", new ValueTuple("TimeSpan", typeof(TimeSpan)) }, { "Byte", new ValueTuple("byte", typeof(byte)) }, + + { "LocalDate", new ValueTuple("DateTime", typeof(DateTime)) }, + { "LocalTime", new ValueTuple("TimeSpan", typeof(TimeSpan)) }, }; diff --git a/src/Linq2GraphQL.Generator/GraphQLSchema/RootSchema.cs b/src/Linq2GraphQL.Generator/GraphQLSchema/RootSchema.cs index bdf893f5..a6675c27 100644 --- a/src/Linq2GraphQL.Generator/GraphQLSchema/RootSchema.cs +++ b/src/Linq2GraphQL.Generator/GraphQLSchema/RootSchema.cs @@ -20,7 +20,6 @@ public class GraphqlSchemaType public class GraphqlType : BaseType { - public List EnumValues { get; set; } public List Fields { get; set; } public List InputFields { get; set; } @@ -46,6 +45,7 @@ public string GetInterfacesString(string baseClass = null) { interfaces += ", "; } + interfaces += string.Join(", ", Interfaces.Select(e => e.Name)); } @@ -60,7 +60,6 @@ public string GetInterfacesString(string baseClass = null) } - if (!string.IsNullOrWhiteSpace(interfaces)) { interfaces = ": " + interfaces; @@ -71,13 +70,21 @@ public string GetInterfacesString(string baseClass = null) public bool IsPageInfo() { - if (CSharpName != "PageInfo") { return false; } - if (InputFields != null && InputFields.Any()) { return false; } + if (CSharpName != "PageInfo") + { + return false; + } + + if (InputFields != null && InputFields.Any()) + { + return false; + } + //TODO Fix this foreach (var field in Fields) { - } + return true; } @@ -85,8 +92,6 @@ public bool ContainPageInfo() { return Fields?.Any(e => e.GraphqlType.IsPageInfo()) == true; } - - } [JsonConverter(typeof(JsonStringEnumMemberConverter))] @@ -123,16 +128,12 @@ public string GetCSharpName() } } - - - public class BaseField { - public string Name { get; set; } public string SafeName => Helpers.SafeVariableName(Name); - + public string Description { get; set; } @@ -153,6 +154,7 @@ public class BaseField public BaseType Type { get; set; } private CoreType coreType; + public CoreType CoreType { get @@ -161,13 +163,8 @@ public CoreType CoreType return coreType; } } - - - } - - public class Field : BaseField { public List Args { get; set; } @@ -175,9 +172,21 @@ public class Field : BaseField public bool SupportCursorPaging() { - if (!GraphqlType.ContainPageInfo()) { return false; } - if (Args?.FirstOrDefault(e => e.Name == "after" && e.CoreType.CSharpTypeName == "string") == null) { return false; } - if (Args?.FirstOrDefault(e => e.Name == "before" && e.CoreType.CSharpTypeName == "string") == null) { return false; } + if (!GraphqlType.ContainPageInfo()) + { + return false; + } + + if (Args?.FirstOrDefault(e => e.Name == "after" && e.CoreType.CSharpTypeName == "string") == null) + { + return false; + } + + if (Args?.FirstOrDefault(e => e.Name == "before" && e.CoreType.CSharpTypeName == "string") == null) + { + return false; + } + return true; } @@ -224,14 +233,11 @@ public string GetArgString(bool addTypeAttribute) } } - public class Arg : BaseField { public string DefaultValue { get; set; } } - - public class BaseType { public string Name { get; set; } @@ -249,7 +255,6 @@ public class BaseType public BaseType OfType { get; set; } - public List GetAllTypes() { var result = new List { this }; @@ -292,7 +297,6 @@ public CoreType GetCoreType() result.BaseType = type; currentNoneNull = false; break; - } } @@ -314,13 +318,9 @@ public CoreType GetCoreType() result.SetGraphQLTypeDefinition(); return result; - } - - } - public class CoreTypeList { public bool NoneNull { get; set; } @@ -339,6 +339,7 @@ public class CoreType public bool IsEnum => BaseType.Kind == TypeKind.Enum; public string CSharpTypeDefinition { get; set; } + public string CSharpTypeDefinitionNeverNull { get @@ -347,30 +348,36 @@ public string CSharpTypeDefinitionNeverNull { return CSharpTypeDefinition.RemoveFromEnd("?"); } + return CSharpTypeDefinition; } } + public string GraphQLTypeDefinition { get; set; } public void SetGraphQLTypeDefinition() { var result = BaseType.Name; - if (NoneNull) { result += "!"; } + if (NoneNull) + { + result += "!"; + } foreach (var list in Lists) { result = $"[{result}]"; - if (list.NoneNull) { result += "!"; } + if (list.NoneNull) + { + result += "!"; + } } GraphQLTypeDefinition = result; - } private bool UseSharpNoneNull() { - if (GeneratorSettings.Current.Nullable || NoneNull) { return NoneNull; @@ -392,16 +399,20 @@ public void SetCSharpTypeDefinition() { var result = CSharpTypeName; - if (!UseSharpNoneNull()) { result += "?"; } + if (!UseSharpNoneNull()) + { + result += "?"; + } foreach (var list in Lists) { result = $"List<{result}>"; - if (!list.NoneNull && GeneratorSettings.Current.Nullable) { result += "?"; } + if (!list.NoneNull && GeneratorSettings.Current.Nullable) + { + result += "?"; + } } CSharpTypeDefinition = result; - } - } \ No newline at end of file diff --git a/src/Linq2GraphQL.Generator/GraphQLSchema/Schema.cs b/src/Linq2GraphQL.Generator/GraphQLSchema/Schema.cs index 94a8fdf6..f4b1635b 100644 --- a/src/Linq2GraphQL.Generator/GraphQLSchema/Schema.cs +++ b/src/Linq2GraphQL.Generator/GraphQLSchema/Schema.cs @@ -6,11 +6,8 @@ public class Schema { private static readonly List BuiltInTypes = new() { - // "ID", - "Int", - "Float", - "String", - "Boolean" + // "ID", + "Int", "Float", "String", "Boolean" }; public List Types { get; set; } @@ -30,8 +27,8 @@ public class Schema public List GetAllTypesExceptSystemTypes() { - if (Types == null) return new List(); - + if (Types == null) return new(); + return Types.Where(e => e.Name != SchemaQueryType?.Name && !e.Name.StartsWith("__") && !BuiltInTypes.Contains(e.Name) && @@ -43,9 +40,9 @@ public List GetAllTypesExceptSystemTypes() public void PopulateFieldTypes() { if (Types == null) return; - + foreach (var typeGroup in Types.Where(e => e.AllFields != null && e.AllFields.Any()) - .SelectMany(e => e.AllFields).GroupBy(e => e.Type.GetBaseBaseType().Name)) + .SelectMany(e => e.AllFields).GroupBy(e => e.Type.GetBaseBaseType().Name)) { var graphQlType = GetGraphqlType(typeGroup.Key); @@ -72,7 +69,8 @@ public List GetEnums() public List GetCustomScalars() { var mappers = Helpers.TypeMapping; - return GetAllTypesExceptSystemTypes().Where(e => e.Kind == TypeKind.Scalar && !mappers.ContainsKey(e.Name)).ToList(); + return GetAllTypesExceptSystemTypes().Where(e => e.Kind == TypeKind.Scalar && !mappers.ContainsKey(e.Name)) + .ToList(); } public List GetInterfaces() @@ -80,6 +78,8 @@ public List GetInterfaces() return GetAllTypesExceptSystemTypes().Where(e => e.Kind == TypeKind.Interface).ToList(); } - public GraphqlType GetGraphqlType(string name) => Types?.FirstOrDefault(e => e.Name == name); - + public GraphqlType GetGraphqlType(string name) + { + return Types?.FirstOrDefault(e => e.Name == name); + } } \ No newline at end of file diff --git a/src/Linq2GraphQL.Generator/Linq2GraphQL.Generator.csproj b/src/Linq2GraphQL.Generator/Linq2GraphQL.Generator.csproj index 10fbf8b9..7d1ea89d 100644 --- a/src/Linq2GraphQL.Generator/Linq2GraphQL.Generator.csproj +++ b/src/Linq2GraphQL.Generator/Linq2GraphQL.Generator.csproj @@ -2,27 +2,27 @@ Exe - net8.0 + net9.0 enable true Linq2GraphQL - Joakim Dangården, Magnus Ahlberg - Linq2GraphQL - git - https://github.com/linq2graphql/linq2graphql.client - https://linq2graphql.com/ - Linq2GraphQL.Generator - Generates Linq2GraphQL Client - Copyright 2023 (c) Joakim Dangården. All rights reserved. - Linq GraphQL Client Generator + Joakim Dangården, Magnus Ahlberg + Linq2GraphQL + git + https://github.com/linq2graphql/linq2graphql.client + https://linq2graphql.com/ + Linq2GraphQL.Generator + Generates Linq2GraphQL Client + Copyright 2023 (c) Joakim Dangården. All rights reserved. + Linq GraphQL Client Generator - - - + + + @@ -47,8 +47,8 @@ EnumTemplate.cs - InterfaceTemplate.cs - TextTemplatingFilePreprocessor + InterfaceTemplate.cs + TextTemplatingFilePreprocessor TextTemplatingFilePreprocessor @@ -63,13 +63,13 @@ ClientExtensionsTemplate.cs - TextTemplatingFilePreprocessor - ScalarTemplate.cs + TextTemplatingFilePreprocessor + ScalarTemplate.cs - + @@ -84,14 +84,14 @@ ClassTemplate.tt - True - True - ClientExtensionsTemplate.tt + True + True + ClientExtensionsTemplate.tt - True - True - ClientTemplate.tt + True + True + ClientTemplate.tt True @@ -104,9 +104,9 @@ EnumTemplate.tt - True - True - InterfaceTemplate.tt + True + True + InterfaceTemplate.tt True @@ -119,14 +119,14 @@ InputFactoryClassTemplate.tt - True - True - ScalarTemplate.tt + True + True + ScalarTemplate.tt - + diff --git a/src/Linq2GraphQL.Generator/Program.cs b/src/Linq2GraphQL.Generator/Program.cs index 5e6dcbdb..b9bafcda 100644 --- a/src/Linq2GraphQL.Generator/Program.cs +++ b/src/Linq2GraphQL.Generator/Program.cs @@ -54,19 +54,19 @@ await GenerateClientAsync(uriValue, outputFolderValue, namespaceValue, clientNam } ); - await rootCommand.InvokeAsync(args); - - + await rootCommand.InvokeAsync(args); } private static async Task GenerateClientAsync(Uri uri, string outputFolder, string namespaceName, string name, bool includeSubscriptions, string authToken, string enumStrategy, bool nullable, bool includeDeprecated) { - var enumStrat = enumStrategy != null && enumStrategy.Equals("AddUnknownOption", StringComparison.InvariantCultureIgnoreCase) + var enumStrat = enumStrategy != null && + enumStrategy.Equals("AddUnknownOption", StringComparison.InvariantCultureIgnoreCase) ? EnumGeneratorStrategy.AddUnknownOption : EnumGeneratorStrategy.FailIfMissing; - - var generator = new ClientGenerator(namespaceName, name, includeSubscriptions, enumStrat, nullable, includeDeprecated); + + var generator = new ClientGenerator(namespaceName, name, includeSubscriptions, enumStrat, nullable, + includeDeprecated); var entries = await generator.GenerateAsync(uri, authToken); var outputPath = Path.GetFullPath(outputFolder, Environment.CurrentDirectory); @@ -81,7 +81,6 @@ private static async Task GenerateClientAsync(Uri uri, string outputFolder, stri var filePath = Path.Combine(directory, entry.FileName); await File.WriteAllTextAsync(filePath, entry.Content); } - } } } \ No newline at end of file diff --git a/src/Linq2GraphQL.Generator/Properties/launchSettings.json b/src/Linq2GraphQL.Generator/Properties/launchSettings.json index f1dfb782..9b50de83 100644 --- a/src/Linq2GraphQL.Generator/Properties/launchSettings.json +++ b/src/Linq2GraphQL.Generator/Properties/launchSettings.json @@ -2,7 +2,8 @@ "profiles": { "Linq2GraphQL.Generator": { "commandName": "Project", - "commandLineArgs": "https://localhost:7184/graphql/ -c=\"SampleClient\" -n=\"Linq2GraphQL.TestClient\" -o=\"C:\\Code\\Github\\Linq2GraphQL.Client\\test\\Linq2GraphQL.TestClient\\Generated\" -s=true -d=true" +// "commandLineArgs": "https://localhost:7184/graphql/ -c=\"SampleClient\" -n=\"Linq2GraphQL.TestClient\" -o=\"C:\\Code\\Linq2GraphQL.Client\\test\\Linq2GraphQL.TestClient\\Generated\" -s=true -d=true" + "commandLineArgs": "https://localhost:50741/graphql/ -c=\"SampleNullableClient\" -n=\"Linq2GraphQL.TestClientNullable\" -o=\"C:\\Code\\Linq2GraphQL.Client\\test\\Linq2GraphQL.TestClientNullable\\Generated\" -s=true -d=true -nu=true" } } } \ No newline at end of file diff --git a/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.cs b/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.cs index afd68c4a..eeafeb24 100644 --- a/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.cs +++ b/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.cs @@ -1,7 +1,7 @@ // ------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version: 17.0.0.0 +// Runtime Version: 16.0.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -15,8 +15,8 @@ namespace Linq2GraphQL.Generator.Templates.Client /// Class to produce the template output /// - #line 1 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] + #line 1 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")] public partial class ClientTemplate : ClientTemplateBase { #line hidden @@ -25,291 +25,274 @@ public partial class ClientTemplate : ClientTemplateBase /// public virtual string TransformText() { - this.Write("using Linq2GraphQL.Client;\r\nusing Microsoft.Extensions.DependencyInjection;\r\nusin" + - "g Microsoft.Extensions.Options;\r\n\r\nnamespace "); + this.Write("using Linq2GraphQL.Client;\r\nusing Microsoft.Extensions.DependencyInjection;\r\nusing Microsoft.Extensions.Options;\r\n\r\nnamespace "); - #line 7 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 7 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(namespaceName)); #line default #line hidden this.Write(";\r\n\r\n/// \r\n/// GraphQL client for "); - #line 10 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 10 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(name)); #line default #line hidden - this.Write(" operations\r\n/// \r\n/// \r\n/// Provides strongly-typed access to" + - " GraphQL queries, mutations, and subscriptions.\r\n/// Supports dependency injecti" + - "on for better testability and flexibility.\r\n/// \r\npublic class "); + this.Write(" operations\r\n/// \r\n/// \r\n/// Provides strongly-typed access to GraphQL queries, mutations, and subscriptions.\r\n/// Supports dependency injection for better testability and flexibility.\r\n/// \r\npublic class "); - #line 16 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 16 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(name)); #line default #line hidden this.Write(" : I"); - #line 16 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 16 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(name)); #line default #line hidden - this.Write(@" -{ - /// - /// Constructor with dependency injection support - /// - /// HTTP client for GraphQL requests - /// GraphQL client configuration options - /// Service provider for dependency resolution -"); + this.Write("\r\n{ \r\n /// \r\n /// Constructor with dependency injection support\r\n /// \r\n /// HTTP client for GraphQL requests\r\n /// GraphQL client configuration options\r\n /// Service provider for dependency resolution\r\n"); - #line 24 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 24 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeQuery) { #line default #line hidden - this.Write(" /// Optional query methods implementation (uses de" + - "fault if null)\r\n"); + this.Write(" /// Optional query methods implementation (uses default if null)\r\n"); - #line 26 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 26 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden - #line 27 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 27 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeMutation) { #line default #line hidden - this.Write(" /// Optional mutation methods implementation (u" + - "ses default if null)\r\n"); + this.Write(" /// Optional mutation methods implementation (uses default if null)\r\n"); - #line 29 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 29 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden - #line 30 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 30 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeSubscriptions) { #line default #line hidden - this.Write(" /// Optional subscription methods implement" + - "ation (uses default if null)\r\n"); + this.Write(" /// Optional subscription methods implementation (uses default if null)\r\n"); - #line 32 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 32 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden this.Write(" public "); - #line 33 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 33 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(name)); #line default #line hidden this.Write("(\r\n HttpClient httpClient, \r\n [FromKeyedServices(\""); - #line 35 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 35 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(name)); #line default #line hidden this.Write("\")] IOptions options, \r\n IServiceProvider provider"); - #line 36 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 36 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeQuery) { #line default #line hidden this.Write(",\r\n I"); - #line 37 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(GetMehodName(queryType))); + #line 37 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(GetParameterName(queryType))); #line default #line hidden this.Write(" queryMethods = null"); - #line 37 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 37 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden - #line 37 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 37 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeMutation) { #line default #line hidden this.Write(",\r\n I"); - #line 38 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(GetMehodName(mutationType))); + #line 38 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(GetParameterName(mutationType))); #line default #line hidden this.Write(" mutationMethods = null"); - #line 38 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 38 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden - #line 38 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 38 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeSubscriptions) { #line default #line hidden this.Write(",\r\n I"); - #line 39 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(GetMehodName(subscriptionType))); + #line 39 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(GetParameterName(subscriptionType))); #line default #line hidden this.Write(" subscriptionMethods = null"); - #line 39 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 39 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden this.Write(")\r\n {\r\n var client = new GraphClient(httpClient, options, provider, "); - #line 41 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 41 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(includeDeprecated.ToString().ToLower())); #line default #line hidden this.Write(");\r\n"); - #line 42 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 42 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeQuery) { #line default #line hidden this.Write(" Query = queryMethods ?? new "); - #line 43 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(GetMehodName(queryType))); + #line 43 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(GetTypeName(queryType))); #line default #line hidden this.Write("(client);\r\n"); - #line 44 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 44 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden - #line 45 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 45 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeMutation) { #line default #line hidden this.Write(" Mutation = mutationMethods ?? new "); - #line 46 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(GetMehodName(mutationType))); + #line 46 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(GetTypeName(mutationType))); #line default #line hidden this.Write("(client);\r\n"); - #line 47 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 47 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden - #line 48 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 48 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeSubscriptions) { #line default #line hidden this.Write(" Subscription = subscriptionMethods ?? new "); - #line 49 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(GetMehodName(subscriptionType))); + #line 49 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(GetTypeName(subscriptionType))); #line default #line hidden this.Write("(client);\r\n"); - #line 50 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 50 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden this.Write(" }\r\n\r\n"); - #line 53 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 53 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeQuery) { #line default #line hidden - this.Write(" /// \r\n /// Gets the query methods for this GraphQL client\r\n //" + - "/ \r\n public I"); + this.Write(" /// \r\n /// Gets the query methods for this GraphQL client\r\n /// \r\n public I"); - #line 57 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(GetMehodName(queryType))); + #line 57 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(GetTypeName(queryType))); #line default #line hidden this.Write(" Query { get; private set; }\r\n"); - #line 58 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 58 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden - #line 59 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 59 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeMutation) { #line default #line hidden - this.Write(" /// \r\n /// Gets the mutation methods for this GraphQL client\r\n " + - " /// \r\n public I"); + this.Write(" /// \r\n /// Gets the mutation methods for this GraphQL client\r\n /// \r\n public I"); - #line 63 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(GetMehodName(mutationType))); + #line 63 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(GetTypeName(mutationType))); #line default #line hidden this.Write(" Mutation { get; private set; }\r\n"); - #line 64 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 64 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default #line hidden - #line 65 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 65 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" if (includeSubscriptions) { #line default #line hidden - this.Write(" /// \r\n /// Gets the subscription methods for this GraphQL client\r" + - "\n /// \r\n public I"); + this.Write(" /// \r\n /// Gets the subscription methods for this GraphQL client\r\n /// \r\n public I"); - #line 69 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" - this.Write(this.ToStringHelper.ToStringWithCulture(GetMehodName(subscriptionType))); + #line 69 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + this.Write(this.ToStringHelper.ToStringWithCulture(GetTypeName(subscriptionType))); #line default #line hidden this.Write(" Subscription { get; private set; }\r\n"); - #line 70 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" + #line 70 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Client\ClientTemplate.tt" } #line default @@ -325,7 +308,7 @@ public virtual string TransformText() /// /// Base class for this transformation /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")] public class ClientTemplateBase { #region Fields @@ -340,7 +323,7 @@ public class ClientTemplateBase /// /// The string builder that generation-time code is using to assemble generated output /// - public System.Text.StringBuilder GenerationEnvironment + protected System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.tt b/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.tt index f80c86cd..c0fe6e76 100644 --- a/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.tt +++ b/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.tt @@ -34,19 +34,19 @@ public class <#= name #> : I<#= name #> HttpClient httpClient, [FromKeyedServices("<#= name #>")] IOptions options, IServiceProvider provider<# if (includeQuery) { #>, - I<#= GetMehodName(queryType) #> queryMethods = null<# } #><# if (includeMutation) { #>, - I<#= GetMehodName(mutationType) #> mutationMethods = null<# } #><# if (includeSubscriptions) { #>, - I<#= GetMehodName(subscriptionType) #> subscriptionMethods = null<# } #>) + I<#= GetParameterName(queryType) #> queryMethods = null<# } #><# if (includeMutation) { #>, + I<#= GetParameterName(mutationType) #> mutationMethods = null<# } #><# if (includeSubscriptions) { #>, + I<#= GetParameterName(subscriptionType) #> subscriptionMethods = null<# } #>) { var client = new GraphClient(httpClient, options, provider, <#= includeDeprecated.ToString().ToLower() #>); <# if (includeQuery) { #> - Query = queryMethods ?? new <#= GetMehodName(queryType) #>(client); + Query = queryMethods ?? new <#= GetTypeName(queryType) #>(client); <# } #> <# if (includeMutation) { #> - Mutation = mutationMethods ?? new <#= GetMehodName(mutationType) #>(client); + Mutation = mutationMethods ?? new <#= GetTypeName(mutationType) #>(client); <# } #> <# if (includeSubscriptions) { #> - Subscription = subscriptionMethods ?? new <#= GetMehodName(subscriptionType) #>(client); + Subscription = subscriptionMethods ?? new <#= GetTypeName(subscriptionType) #>(client); <# } #> } @@ -54,18 +54,18 @@ public class <#= name #> : I<#= name #> /// /// Gets the query methods for this GraphQL client /// - public I<#= GetMehodName(queryType) #> Query { get; private set; } + public I<#= GetTypeName(queryType) #> Query { get; private set; } <# } #> <# if (includeMutation) { #> /// /// Gets the mutation methods for this GraphQL client /// - public I<#= GetMehodName(mutationType) #> Mutation { get; private set; } + public I<#= GetTypeName(mutationType) #> Mutation { get; private set; } <# } #> <# if (includeSubscriptions) { #> /// /// Gets the subscription methods for this GraphQL client /// - public I<#= GetMehodName(subscriptionType) #> Subscription { get; private set; } + public I<#= GetTypeName(subscriptionType) #> Subscription { get; private set; } <# } #> } \ No newline at end of file diff --git a/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.tt.cs b/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.tt.cs index 380aa435..b8633ced 100644 --- a/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.tt.cs +++ b/src/Linq2GraphQL.Generator/Templates/Client/ClientTemplate.tt.cs @@ -1,30 +1,31 @@ namespace Linq2GraphQL.Generator.Templates.Client; -public partial class ClientTemplate +public partial class ClientTemplate( + string namespaceName, + string name, + GraphqlType queryType, + GraphqlType mutationType, + GraphqlType subscriptionType, + bool includeDeprecated, + bool nullable) { - private readonly string namespaceName; - private readonly string name; - private readonly GraphqlType queryType; - private readonly GraphqlType mutationType; - private readonly GraphqlType subscriptionType; - private readonly bool includeDeprecated; - - public ClientTemplate(string namespaceName, string name, GraphqlType queryType, GraphqlType mutationType, GraphqlType subscriptionType, bool includeDeprecated) - { - this.namespaceName = namespaceName; - this.name = name; - this.queryType = queryType; - this.mutationType = mutationType; - this.subscriptionType = subscriptionType; - this.includeDeprecated = includeDeprecated; - } - private bool includeQuery => queryType != null; private bool includeMutation => mutationType != null; private bool includeSubscriptions => subscriptionType != null; - private string GetMehodName(GraphqlType graphqlType) + private string GetParameterName(GraphqlType graphqlType) + { + var parameterName = GetTypeName(graphqlType); + if (nullable) + { + parameterName += "?"; + } + + return parameterName; + } + + private string GetTypeName(GraphqlType graphqlType) { return graphqlType.CSharpName + "Methods"; } -} +} \ No newline at end of file diff --git a/src/Linq2GraphQL.Generator/Templates/Interface/InterfaceTemplate.cs b/src/Linq2GraphQL.Generator/Templates/Interface/InterfaceTemplate.cs index cf630aba..caf135b1 100644 --- a/src/Linq2GraphQL.Generator/Templates/Interface/InterfaceTemplate.cs +++ b/src/Linq2GraphQL.Generator/Templates/Interface/InterfaceTemplate.cs @@ -1,7 +1,7 @@ // ------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version: 17.0.0.0 +// Runtime Version: 16.0.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -15,8 +15,8 @@ namespace Linq2GraphQL.Generator.Templates.Interface /// Class to produce the template output /// - #line 1 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] + #line 1 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")] public partial class InterfaceTemplate : InterfaceTemplateBase { #line hidden @@ -25,312 +25,316 @@ public partial class InterfaceTemplate : InterfaceTemplateBase /// public virtual string TransformText() { - this.Write("using System;\r\nusing System.Text.Json;\r\nusing System.Text.Json.Nodes;\r\nusing Syst" + - "em.Text.Json.Serialization;\r\nusing Linq2GraphQL.Client;\r\nusing Linq2GraphQL.Clie" + - "nt.Converters;\r\n\r\nnamespace "); + this.Write("using System;\r\nusing System.Text.Json;\r\nusing System.Text.Json.Nodes;\r\nusing System.Text.Json.Serialization;\r\nusing Linq2GraphQL.Client;\r\nusing Linq2GraphQL.Client.Converters;\r\n\r\nnamespace "); - #line 10 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 10 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(namespaceName)); #line default #line hidden this.Write(";\r\n\r\n/// \r\n/// Extension methods for "); - #line 13 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 13 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write(" interface type casting\r\n/// \r\npublic static class "); - #line 15 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 15 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write("Extensions\r\n{\r\n"); - #line 17 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" - foreach (var field in implementedBy) { + #line 17 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + + foreach (var field in implementedBy) + { + #line default #line hidden this.Write(" /// \r\n /// Casts "); - #line 19 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 22 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write(" to "); - #line 19 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 22 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field)); #line default #line hidden - this.Write(" if the runtime type matches\r\n /// \r\n /// The" + - " interface value to cast\r\n /// "); + this.Write(" if the runtime type matches\r\n /// \r\n /// The interface value to cast\r\n /// "); - #line 22 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 25 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field)); #line default #line hidden - this.Write(" instance or null if type doesn\'t match\r\n [GraphInterface]\r\n publ" + - "ic static "); + this.Write(" instance or null if type doesn't match\r\n [GraphInterface]\r\n public static "); - #line 24 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 27 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field)); #line default #line hidden this.Write(" "); - #line 24 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 27 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field)); #line default #line hidden this.Write("(this "); - #line 24 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 27 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write(" value)\r\n {\r\n if (value.__TypeName == \""); - #line 26 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 29 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field)); #line default #line hidden this.Write("\")\r\n {\r\n return ("); - #line 28 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 31 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field)); #line default #line hidden this.Write(")value;\r\n }\r\n return null;\r\n }\r\n\r\n"); - #line 33 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" - } + #line 36 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + + } + #line default #line hidden this.Write("}\r\n\r\n/// \r\n/// JSON converter for "); - #line 37 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 42 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write(" interface deserialization\r\n/// \r\ninternal class "); - #line 39 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 44 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(GetInterfaceConverterName())); #line default #line hidden this.Write(" : InterfaceJsonConverter<"); - #line 39 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 44 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden - this.Write(@"> -{ - /// - /// Deserializes JSON to the appropriate concrete type based on __typename - /// - /// The GraphQL type name from __typename field - /// The JSON object to deserialize - /// Deserialized instance of the appropriate concrete type - public override "); + this.Write(">\r\n{\r\n /// \r\n /// Deserializes JSON to the appropriate concrete type based on __typename\r\n /// \r\n /// The GraphQL type name from __typename field\r\n /// The JSON object to deserialize\r\n /// Deserialized instance of the appropriate concrete type\r\n public override "); - #line 47 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 52 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write(" Deserialize(string typeName, JsonObject json) => typeName switch\r\n {\r\n"); - #line 49 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" - foreach (var field in implementedBy) { + #line 54 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + + foreach (var field in implementedBy) + { + #line default #line hidden this.Write(" \""); - #line 50 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 58 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field)); #line default #line hidden this.Write("\" => json.Deserialize<"); - #line 50 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 58 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field)); #line default #line hidden this.Write(">(),\r\n"); - #line 51 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" - } + #line 59 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + + } + #line default #line hidden this.Write(" _ => json.Deserialize<"); - #line 52 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 62 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(GetInterfaceConcreteName())); #line default #line hidden this.Write(">()\r\n };\r\n}\r\n\r\n/// \r\n/// GraphQL interface "); - #line 57 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 67 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write(" with all common fields\r\n/// \r\n[JsonConverter(typeof("); - #line 59 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 69 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(GetInterfaceConverterName())); #line default #line hidden this.Write("))]\r\npublic interface "); - #line 60 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 70 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write(" "); - #line 60 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 70 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.GetInterfacesString())); #line default #line hidden this.Write("\r\n{\r\n"); - #line 62 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" - foreach (var field in classType.AllFields) { - var coreType = field.CoreType; + #line 72 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + + foreach (var field in classType.AllFields) + { + var coreType = field.CoreType; + #line default #line hidden this.Write(" /// \r\n /// "); - #line 65 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 78 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field.Name)); #line default #line hidden this.Write(" field from GraphQL schema\r\n /// \r\n [GraphQLMember(\""); - #line 67 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 80 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field.Name)); #line default #line hidden this.Write("\")]\r\n "); - #line 68 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 81 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(coreType.CSharpTypeDefinition)); #line default #line hidden this.Write(" "); - #line 68 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 81 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field.CSharpName)); #line default #line hidden this.Write(" { get; set; }\r\n\r\n"); - #line 70 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" - } + #line 83 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + + } + #line default #line hidden - this.Write(" /// \r\n /// GraphQL __typename field for runtime type resolution\r\n" + - " /// \r\n [GraphQLMember(\"__typename\")]\r\n string __TypeName { g" + - "et; set; }\r\n}\r\n\r\n/// \r\n/// Concrete implementation of "); + this.Write(" /// \r\n /// GraphQL __typename field for runtime type resolution\r\n /// \r\n [GraphQLMember(\"__typename\")]\r\n string __TypeName { get; set; }\r\n}\r\n\r\n/// \r\n/// Concrete implementation of "); - #line 79 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 94 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write(" interface for fallback deserialization\r\n/// \r\ninternal class "); - #line 81 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 96 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(GetInterfaceConcreteName())); #line default #line hidden this.Write(" : "); - #line 81 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 96 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(classType.Name)); #line default #line hidden this.Write("\r\n{\r\n"); - #line 83 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" - foreach (var field in classType.AllFields) { - var coreType = field.CoreType; + #line 98 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + + foreach (var field in classType.AllFields) + { + var coreType = field.CoreType; + #line default #line hidden this.Write(" /// \r\n /// "); - #line 86 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 104 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field.Name)); #line default #line hidden this.Write(" field from GraphQL schema\r\n /// \r\n [GraphQLMember(\""); - #line 88 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 106 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field.Name)); #line default #line hidden this.Write("\")]\r\n public "); - #line 89 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 107 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(coreType.CSharpTypeDefinition)); #line default #line hidden this.Write(" "); - #line 89 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + #line 107 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(field.CSharpName)); #line default #line hidden this.Write(" { get; set; }\r\n\r\n"); - #line 91 "C:\Data\Linq2GraphQL.Client-1\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" - } + #line 109 "C:\Code\Linq2GraphQL.Client\src\Linq2GraphQL.Generator\Templates\Interface\InterfaceTemplate.tt" + + } + #line default #line hidden - this.Write(" /// \r\n /// GraphQL __typename field for runtime type resolution\r\n" + - " /// \r\n [GraphQLMember(\"__typename\")]\r\n public string __TypeN" + - "ame { get; set; }\r\n}"); + this.Write(" /// \r\n /// GraphQL __typename field for runtime type resolution\r\n /// \r\n [GraphQLMember(\"__typename\")]\r\n public string __TypeName { get; set; }\r\n}"); return this.GenerationEnvironment.ToString(); } } @@ -341,7 +345,7 @@ public virtual string TransformText() /// /// Base class for this transformation /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")] public class InterfaceTemplateBase { #region Fields @@ -356,7 +360,7 @@ public class InterfaceTemplateBase /// /// The string builder that generation-time code is using to assemble generated output /// - public System.Text.StringBuilder GenerationEnvironment + protected System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/Linq2GraphQL.Generator/Templates/Interface/InterfaceTemplate.tt b/src/Linq2GraphQL.Generator/Templates/Interface/InterfaceTemplate.tt index a0d49c34..fc23a18d 100644 --- a/src/Linq2GraphQL.Generator/Templates/Interface/InterfaceTemplate.tt +++ b/src/Linq2GraphQL.Generator/Templates/Interface/InterfaceTemplate.tt @@ -14,7 +14,10 @@ namespace <#= namespaceName #>; /// public static class <#= classType.Name #>Extensions { -<# foreach (var field in implementedBy) { #> +<# + foreach (var field in implementedBy) + { +#> /// /// Casts <#= classType.Name #> to <#= field #> if the runtime type matches /// @@ -30,7 +33,9 @@ public static class <#= classType.Name #>Extensions return null; } -<# } #> +<# + } +#> } /// @@ -46,9 +51,14 @@ internal class <#= GetInterfaceConverterName() #> : InterfaceJsonConverter<<#= c /// Deserialized instance of the appropriate concrete type public override <#= classType.Name #> Deserialize(string typeName, JsonObject json) => typeName switch { -<# foreach (var field in implementedBy) { #> +<# + foreach (var field in implementedBy) + { +#> "<#= field #>" => json.Deserialize<<#= field #>>(), -<# } #> +<# + } +#> _ => json.Deserialize<<#= GetInterfaceConcreteName() #>>() }; } @@ -59,15 +69,20 @@ internal class <#= GetInterfaceConverterName() #> : InterfaceJsonConverter<<#= c [JsonConverter(typeof(<#= GetInterfaceConverterName() #>))] public interface <#= classType.Name #> <#= classType.GetInterfacesString() #> { -<# foreach (var field in classType.AllFields) { - var coreType = field.CoreType; #> +<# + foreach (var field in classType.AllFields) + { + var coreType = field.CoreType; +#> /// /// <#= field.Name #> field from GraphQL schema /// [GraphQLMember("<#= field.Name #>")] <#= coreType.CSharpTypeDefinition #> <#= field.CSharpName #> { get; set; } -<# } #> +<# + } +#> /// /// GraphQL __typename field for runtime type resolution /// @@ -80,15 +95,20 @@ public interface <#= classType.Name #> <#= classType.GetInterfacesString() #> /// internal class <#= GetInterfaceConcreteName() #> : <#= classType.Name #> { -<# foreach (var field in classType.AllFields) { - var coreType = field.CoreType; #> +<# + foreach (var field in classType.AllFields) + { + var coreType = field.CoreType; +#> /// /// <#= field.Name #> field from GraphQL schema /// [GraphQLMember("<#= field.Name #>")] public <#= coreType.CSharpTypeDefinition #> <#= field.CSharpName #> { get; set; } -<# } #> +<# + } +#> /// /// GraphQL __typename field for runtime type resolution /// diff --git a/test/Linq2GraphQL.Console/Linq2GraphQL.Console.csproj b/test/Linq2GraphQL.Console/Linq2GraphQL.Console.csproj index 3a38b49e..06be6746 100644 --- a/test/Linq2GraphQL.Console/Linq2GraphQL.Console.csproj +++ b/test/Linq2GraphQL.Console/Linq2GraphQL.Console.csproj @@ -2,23 +2,23 @@ Exe - net8.0 + net9.0 enable - - - - - - - - + + + + + + + + - - + + diff --git a/test/Linq2GraphQL.Console/Program.cs b/test/Linq2GraphQL.Console/Program.cs index 85fe8887..44a6410a 100644 --- a/test/Linq2GraphQL.Console/Program.cs +++ b/test/Linq2GraphQL.Console/Program.cs @@ -21,19 +21,21 @@ x.SubscriptionProtocol = SubscriptionProtocol.ServerSentEvents; }) .WithHttpClient( - httpClient => { httpClient.BaseAddress = new Uri("https://localhost:7184/graphql"); }, + httpClient => { httpClient.BaseAddress = new("https://localhost:7184/graphql"); }, builder => { //Add stuff here }); serviceProvider.AddStarWarsClient(x => -{ - x.UseSafeMode = true; - x.SubscriptionProtocol = SubscriptionProtocol.ServerSentEvents; -}) - .WithHttpClient( - httpClient => { httpClient.BaseAddress = new Uri("https://swapi-graphql.netlify.app/.netlify/functions/index"); }); + { + x.UseSafeMode = true; + x.SubscriptionProtocol = SubscriptionProtocol.ServerSentEvents; + }) + .WithHttpClient(httpClient => + { + httpClient.BaseAddress = new("https://swapi-graphql.netlify.app/.netlify/functions/index"); + }); var services = serviceProvider.BuildServiceProvider(); diff --git a/test/Linq2GraphQL.TestClient/Generated/Client/QueryMethods.cs b/test/Linq2GraphQL.TestClient/Generated/Client/QueryMethods.cs index 173786bf..aef2cb5a 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Client/QueryMethods.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Client/QueryMethods.cs @@ -106,17 +106,19 @@ public GraphCursorQuery Animals(int? first = null, string aft return new GraphCursorQuery(client, "animals", OperationType.Query, arguments); } - public GraphQuery OrdersOffsetPaging(int? skip = null, int? take = null, OrderFilterInput where = null, List order = null) + public GraphCursorQuery OrdersOffsetPaging(int? first = null, string after = null, int? last = null, string before = null, OrderFilterInput where = null, List order = null) { var arguments = new List { - new("skip","Int", skip), - new("take","Int", take), + new("first","Int", first), + new("after","String", after), + new("last","Int", last), + new("before","String", before), new("where","OrderFilterInput", where), new("order","[OrderSortInput!]", order), }; - return new GraphQuery(client, "ordersOffsetPaging", OperationType.Query, arguments); + return new GraphCursorQuery(client, "ordersOffsetPaging", OperationType.Query, arguments); } } diff --git a/test/Linq2GraphQL.TestClient/Generated/Client/SampleClient.cs b/test/Linq2GraphQL.TestClient/Generated/Client/SampleClient.cs index 9f814853..97336e68 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Client/SampleClient.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Client/SampleClient.cs @@ -6,24 +6,53 @@ //--------------------------------------------------------------------- using Linq2GraphQL.Client; -using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace Linq2GraphQL.TestClient; +/// +/// GraphQL client for SampleClient operations +/// +/// +/// Provides strongly-typed access to GraphQL queries, mutations, and subscriptions. +/// Supports dependency injection for better testability and flexibility. +/// public class SampleClient : ISampleClient { - public SampleClient(HttpClient httpClient, [FromKeyedServices("SampleClient")]IOptions options, IServiceProvider provider) + /// + /// Constructor with dependency injection support + /// + /// HTTP client for GraphQL requests + /// GraphQL client configuration options + /// Service provider for dependency resolution + /// Optional query methods implementation (uses default if null) + /// Optional mutation methods implementation (uses default if null) + /// Optional subscription methods implementation (uses default if null) + public SampleClient( + HttpClient httpClient, + [FromKeyedServices("SampleClient")] IOptions options, + IServiceProvider provider, + IQueryMethods queryMethods = null, + IMutationMethods mutationMethods = null, + ISubscriptionMethods subscriptionMethods = null) { var client = new GraphClient(httpClient, options, provider, true); - Query = new QueryMethods(client); - Mutation = new MutationMethods(client); - Subscription = new SubscriptionMethods(client); + Query = queryMethods ?? new QueryMethods(client); + Mutation = mutationMethods ?? new MutationMethods(client); + Subscription = subscriptionMethods ?? new SubscriptionMethods(client); } + /// + /// Gets the query methods for this GraphQL client + /// public IQueryMethods Query { get; private set; } + /// + /// Gets the mutation methods for this GraphQL client + /// public IMutationMethods Mutation { get; private set; } + /// + /// Gets the subscription methods for this GraphQL client + /// public ISubscriptionMethods Subscription { get; private set; } - } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Client/SampleClientExtensions.cs b/test/Linq2GraphQL.TestClient/Generated/Client/SampleClientExtensions.cs index 78d6abef..81049d4a 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Client/SampleClientExtensions.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Client/SampleClientExtensions.cs @@ -33,7 +33,7 @@ private static IGraphClientBuilder GraphClientBuilder(IServiceColl GraphClientOptions graphClientOptions) { var opts = Options.Create(graphClientOptions); - services.AddKeyedSingleton(ClientName, opts); + services.AddKeyedSingleton(ClientName, opts); services.AddMemoryCache(); return new ClientBuilder(ClientName, services); } diff --git a/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressFilterInput.cs b/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressFilterInput.cs index eeaffc70..641e2c55 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressFilterInput.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressFilterInput.cs @@ -55,4 +55,12 @@ public StringOperationFilterInput PostalCode set => SetValue("postalCode", value); } + [GraphQLMember("createdDate")] + [JsonPropertyName("createdDate")] + public LocalDateOperationFilterInput CreatedDate + { + get => GetValue("createdDate"); + set => SetValue("createdDate", value); + } + } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressInput.cs b/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressInput.cs index 3ec82d82..877db8cb 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressInput.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressInput.cs @@ -39,4 +39,12 @@ public string PostalCode set => SetValue("postalCode", value); } + [GraphQLMember("createdDate")] + [JsonPropertyName("createdDate")] + public DateTime CreatedDate + { + get => GetValue("createdDate"); + set => SetValue("createdDate", value); + } + } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressSortInput.cs b/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressSortInput.cs index e105695d..d8370d42 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressSortInput.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Inputs/AddressSortInput.cs @@ -39,4 +39,12 @@ public SortEnumType? PostalCode set => SetValue("postalCode", value); } + [GraphQLMember("createdDate")] + [JsonPropertyName("createdDate")] + public SortEnumType? CreatedDate + { + get => GetValue("createdDate"); + set => SetValue("createdDate", value); + } + } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Inputs/InputFactory.cs b/test/Linq2GraphQL.TestClient/Generated/Inputs/InputFactory.cs index c3f58e05..b5db63fa 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Inputs/InputFactory.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Inputs/InputFactory.cs @@ -90,6 +90,14 @@ public static ListFilterInputTypeOfOrderLineFilterInput ListFilterInputTypeOfOrd { return new ListFilterInputTypeOfOrderLineFilterInput(); } + public static LocalDateOperationFilterInput LocalDateOperationFilter() + { + return new LocalDateOperationFilterInput(); + } + public static LocalTimeOperationFilterInput LocalTimeOperationFilter() + { + return new LocalTimeOperationFilterInput(); + } public static OrderFilterInput OrderFilter() { return new OrderFilterInput(); @@ -114,10 +122,6 @@ public static StringOperationFilterInput StringOperationFilter() { return new StringOperationFilterInput(); } - public static TimeSpanOperationFilterInput TimeSpanOperationFilter() - { - return new TimeSpanOperationFilterInput(); - } public static UuidOperationFilterInput UuidOperationFilter() { return new UuidOperationFilterInput(); @@ -173,6 +177,15 @@ public static AddressFilterInput PostalCode(this AddressFilterInput input, Actio return input; } + public static AddressFilterInput CreatedDate(this AddressFilterInput input, Action mod) + { + var filter = new LocalDateOperationFilterInput(); + mod ??= _ => { }; + mod(filter); + input.CreatedDate = filter; + return input; + } + } public static class AddressInputExtensions @@ -198,6 +211,13 @@ public static AddressInput PostalCode(this AddressInput input, string val) return input; } + + public static AddressInput CreatedDate(this AddressInput input, DateTime val) + { + input.CreatedDate = val; + return input; + } + } public static class AddressSortInputExtensions @@ -223,6 +243,13 @@ public static AddressSortInput PostalCode(this AddressSortInput input, SortEnumT return input; } + + public static AddressSortInput CreatedDate(this AddressSortInput input, SortEnumType? val) + { + input.CreatedDate = val; + return input; + } + } public static class ByteOperationFilterInputExtensions @@ -1087,6 +1114,182 @@ public static ListFilterInputTypeOfOrderLineFilterInput Any(this ListFilterInput } +public static class LocalDateOperationFilterInputExtensions +{ + + public static LocalDateOperationFilterInput Eq(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Eq = val; + return input; + } + + + public static LocalDateOperationFilterInput Neq(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Neq = val; + return input; + } + + + public static LocalDateOperationFilterInput In(this LocalDateOperationFilterInput input, List val) + { + input.In = val; + return input; + } + + + public static LocalDateOperationFilterInput Nin(this LocalDateOperationFilterInput input, List val) + { + input.Nin = val; + return input; + } + + + public static LocalDateOperationFilterInput Gt(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Gt = val; + return input; + } + + + public static LocalDateOperationFilterInput Ngt(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Ngt = val; + return input; + } + + + public static LocalDateOperationFilterInput Gte(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Gte = val; + return input; + } + + + public static LocalDateOperationFilterInput Ngte(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Ngte = val; + return input; + } + + + public static LocalDateOperationFilterInput Lt(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Lt = val; + return input; + } + + + public static LocalDateOperationFilterInput Nlt(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Nlt = val; + return input; + } + + + public static LocalDateOperationFilterInput Lte(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Lte = val; + return input; + } + + + public static LocalDateOperationFilterInput Nlte(this LocalDateOperationFilterInput input, DateTime? val) + { + input.Nlte = val; + return input; + } + +} + +public static class LocalTimeOperationFilterInputExtensions +{ + + public static LocalTimeOperationFilterInput Eq(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Eq = val; + return input; + } + + + public static LocalTimeOperationFilterInput Neq(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Neq = val; + return input; + } + + + public static LocalTimeOperationFilterInput In(this LocalTimeOperationFilterInput input, List val) + { + input.In = val; + return input; + } + + + public static LocalTimeOperationFilterInput Nin(this LocalTimeOperationFilterInput input, List val) + { + input.Nin = val; + return input; + } + + + public static LocalTimeOperationFilterInput Gt(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Gt = val; + return input; + } + + + public static LocalTimeOperationFilterInput Ngt(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Ngt = val; + return input; + } + + + public static LocalTimeOperationFilterInput Gte(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Gte = val; + return input; + } + + + public static LocalTimeOperationFilterInput Ngte(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Ngte = val; + return input; + } + + + public static LocalTimeOperationFilterInput Lt(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Lt = val; + return input; + } + + + public static LocalTimeOperationFilterInput Nlt(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Nlt = val; + return input; + } + + + public static LocalTimeOperationFilterInput Lte(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Lte = val; + return input; + } + + + public static LocalTimeOperationFilterInput Nlte(this LocalTimeOperationFilterInput input, TimeSpan? val) + { + input.Nlte = val; + return input; + } + +} + public static class OrderFilterInputExtensions { public static OrderFilterInput And(this OrderFilterInput input, Action> mod) @@ -1152,9 +1355,9 @@ public static OrderFilterInput Lines(this OrderFilterInput input, Action mod) + public static OrderFilterInput EntryTime(this OrderFilterInput input, Action mod) { - var filter = new TimeSpanOperationFilterInput(); + var filter = new LocalTimeOperationFilterInput(); mod ??= _ => { }; mod(filter); input.EntryTime = filter; @@ -1483,94 +1686,6 @@ public static StringOperationFilterInput NendsWith(this StringOperationFilterInp } -public static class TimeSpanOperationFilterInputExtensions -{ - - public static TimeSpanOperationFilterInput Eq(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Eq = val; - return input; - } - - - public static TimeSpanOperationFilterInput Neq(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Neq = val; - return input; - } - - - public static TimeSpanOperationFilterInput In(this TimeSpanOperationFilterInput input, List val) - { - input.In = val; - return input; - } - - - public static TimeSpanOperationFilterInput Nin(this TimeSpanOperationFilterInput input, List val) - { - input.Nin = val; - return input; - } - - - public static TimeSpanOperationFilterInput Gt(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Gt = val; - return input; - } - - - public static TimeSpanOperationFilterInput Ngt(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Ngt = val; - return input; - } - - - public static TimeSpanOperationFilterInput Gte(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Gte = val; - return input; - } - - - public static TimeSpanOperationFilterInput Ngte(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Ngte = val; - return input; - } - - - public static TimeSpanOperationFilterInput Lt(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Lt = val; - return input; - } - - - public static TimeSpanOperationFilterInput Nlt(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Nlt = val; - return input; - } - - - public static TimeSpanOperationFilterInput Lte(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Lte = val; - return input; - } - - - public static TimeSpanOperationFilterInput Nlte(this TimeSpanOperationFilterInput input, TimeSpan? val) - { - input.Nlte = val; - return input; - } - -} - public static class UuidOperationFilterInputExtensions { diff --git a/test/Linq2GraphQL.TestClient/Generated/Inputs/LocalDateOperationFilterInput.cs b/test/Linq2GraphQL.TestClient/Generated/Inputs/LocalDateOperationFilterInput.cs new file mode 100644 index 00000000..5600d712 --- /dev/null +++ b/test/Linq2GraphQL.TestClient/Generated/Inputs/LocalDateOperationFilterInput.cs @@ -0,0 +1,114 @@ +//--------------------------------------------------------------------- +// This code was automatically generated by Linq2GraphQL +// Please don't edit this file +// Github:https://github.com/linq2graphql/linq2graphql.client +// Url: https://linq2graphql.com +//--------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; +using Linq2GraphQL.Client; + +namespace Linq2GraphQL.TestClient; + +[JsonConverter(typeof(GraphInputConverter))] +public partial class LocalDateOperationFilterInput : GraphInputBase +{ + [GraphQLMember("eq")] + [JsonPropertyName("eq")] + public DateTime? Eq + { + get => GetValue("eq"); + set => SetValue("eq", value); + } + + [GraphQLMember("neq")] + [JsonPropertyName("neq")] + public DateTime? Neq + { + get => GetValue("neq"); + set => SetValue("neq", value); + } + + [GraphQLMember("in")] + [JsonPropertyName("in")] + public List In + { + get => GetValue>("in"); + set => SetValue("in", value); + } + + [GraphQLMember("nin")] + [JsonPropertyName("nin")] + public List Nin + { + get => GetValue>("nin"); + set => SetValue("nin", value); + } + + [GraphQLMember("gt")] + [JsonPropertyName("gt")] + public DateTime? Gt + { + get => GetValue("gt"); + set => SetValue("gt", value); + } + + [GraphQLMember("ngt")] + [JsonPropertyName("ngt")] + public DateTime? Ngt + { + get => GetValue("ngt"); + set => SetValue("ngt", value); + } + + [GraphQLMember("gte")] + [JsonPropertyName("gte")] + public DateTime? Gte + { + get => GetValue("gte"); + set => SetValue("gte", value); + } + + [GraphQLMember("ngte")] + [JsonPropertyName("ngte")] + public DateTime? Ngte + { + get => GetValue("ngte"); + set => SetValue("ngte", value); + } + + [GraphQLMember("lt")] + [JsonPropertyName("lt")] + public DateTime? Lt + { + get => GetValue("lt"); + set => SetValue("lt", value); + } + + [GraphQLMember("nlt")] + [JsonPropertyName("nlt")] + public DateTime? Nlt + { + get => GetValue("nlt"); + set => SetValue("nlt", value); + } + + [GraphQLMember("lte")] + [JsonPropertyName("lte")] + public DateTime? Lte + { + get => GetValue("lte"); + set => SetValue("lte", value); + } + + [GraphQLMember("nlte")] + [JsonPropertyName("nlte")] + public DateTime? Nlte + { + get => GetValue("nlte"); + set => SetValue("nlte", value); + } + +} \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Inputs/LocalTimeOperationFilterInput.cs b/test/Linq2GraphQL.TestClient/Generated/Inputs/LocalTimeOperationFilterInput.cs new file mode 100644 index 00000000..209b6b52 --- /dev/null +++ b/test/Linq2GraphQL.TestClient/Generated/Inputs/LocalTimeOperationFilterInput.cs @@ -0,0 +1,114 @@ +//--------------------------------------------------------------------- +// This code was automatically generated by Linq2GraphQL +// Please don't edit this file +// Github:https://github.com/linq2graphql/linq2graphql.client +// Url: https://linq2graphql.com +//--------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; +using Linq2GraphQL.Client; + +namespace Linq2GraphQL.TestClient; + +[JsonConverter(typeof(GraphInputConverter))] +public partial class LocalTimeOperationFilterInput : GraphInputBase +{ + [GraphQLMember("eq")] + [JsonPropertyName("eq")] + public TimeSpan? Eq + { + get => GetValue("eq"); + set => SetValue("eq", value); + } + + [GraphQLMember("neq")] + [JsonPropertyName("neq")] + public TimeSpan? Neq + { + get => GetValue("neq"); + set => SetValue("neq", value); + } + + [GraphQLMember("in")] + [JsonPropertyName("in")] + public List In + { + get => GetValue>("in"); + set => SetValue("in", value); + } + + [GraphQLMember("nin")] + [JsonPropertyName("nin")] + public List Nin + { + get => GetValue>("nin"); + set => SetValue("nin", value); + } + + [GraphQLMember("gt")] + [JsonPropertyName("gt")] + public TimeSpan? Gt + { + get => GetValue("gt"); + set => SetValue("gt", value); + } + + [GraphQLMember("ngt")] + [JsonPropertyName("ngt")] + public TimeSpan? Ngt + { + get => GetValue("ngt"); + set => SetValue("ngt", value); + } + + [GraphQLMember("gte")] + [JsonPropertyName("gte")] + public TimeSpan? Gte + { + get => GetValue("gte"); + set => SetValue("gte", value); + } + + [GraphQLMember("ngte")] + [JsonPropertyName("ngte")] + public TimeSpan? Ngte + { + get => GetValue("ngte"); + set => SetValue("ngte", value); + } + + [GraphQLMember("lt")] + [JsonPropertyName("lt")] + public TimeSpan? Lt + { + get => GetValue("lt"); + set => SetValue("lt", value); + } + + [GraphQLMember("nlt")] + [JsonPropertyName("nlt")] + public TimeSpan? Nlt + { + get => GetValue("nlt"); + set => SetValue("nlt", value); + } + + [GraphQLMember("lte")] + [JsonPropertyName("lte")] + public TimeSpan? Lte + { + get => GetValue("lte"); + set => SetValue("lte", value); + } + + [GraphQLMember("nlte")] + [JsonPropertyName("nlte")] + public TimeSpan? Nlte + { + get => GetValue("nlte"); + set => SetValue("nlte", value); + } + +} \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Inputs/OrderFilterInput.cs b/test/Linq2GraphQL.TestClient/Generated/Inputs/OrderFilterInput.cs index 4bb175cf..aebec590 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Inputs/OrderFilterInput.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Inputs/OrderFilterInput.cs @@ -73,9 +73,9 @@ public ListFilterInputTypeOfOrderLineFilterInput Lines [GraphQLMember("entryTime")] [JsonPropertyName("entryTime")] - public TimeSpanOperationFilterInput EntryTime + public LocalTimeOperationFilterInput EntryTime { - get => GetValue("entryTime"); + get => GetValue("entryTime"); set => SetValue("entryTime", value); } diff --git a/test/Linq2GraphQL.TestClient/Generated/Inputs/TimeSpanOperationFilterInput.cs b/test/Linq2GraphQL.TestClient/Generated/Inputs/TimeSpanOperationFilterInput.cs index eb4e84b9..4f50c676 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Inputs/TimeSpanOperationFilterInput.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Inputs/TimeSpanOperationFilterInput.cs @@ -5,110 +5,107 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Text.Json.Serialization; using Linq2GraphQL.Client; namespace Linq2GraphQL.TestClient; [JsonConverter(typeof(GraphInputConverter))] -public partial class TimeSpanOperationFilterInput : GraphInputBase +public class TimeSpanOperationFilterInput : GraphInputBase { - [GraphQLMember("eq")] - [JsonPropertyName("eq")] - public TimeSpan? Eq - { - get => GetValue("eq"); - set => SetValue("eq", value); - } + [GraphQLMember("eq")] + [JsonPropertyName("eq")] + public TimeSpan? Eq + { + get => GetValue("eq"); + set => SetValue("eq", value); + } - [GraphQLMember("neq")] - [JsonPropertyName("neq")] - public TimeSpan? Neq - { - get => GetValue("neq"); - set => SetValue("neq", value); - } + [GraphQLMember("neq")] + [JsonPropertyName("neq")] + public TimeSpan? Neq + { + get => GetValue("neq"); + set => SetValue("neq", value); + } - [GraphQLMember("in")] - [JsonPropertyName("in")] - public List In - { - get => GetValue>("in"); - set => SetValue("in", value); - } + [GraphQLMember("in")] + [JsonPropertyName("in")] + public List In + { + get => GetValue>("in"); + set => SetValue("in", value); + } - [GraphQLMember("nin")] - [JsonPropertyName("nin")] - public List Nin - { - get => GetValue>("nin"); - set => SetValue("nin", value); - } + [GraphQLMember("nin")] + [JsonPropertyName("nin")] + public List Nin + { + get => GetValue>("nin"); + set => SetValue("nin", value); + } - [GraphQLMember("gt")] - [JsonPropertyName("gt")] - public TimeSpan? Gt - { - get => GetValue("gt"); - set => SetValue("gt", value); - } + [GraphQLMember("gt")] + [JsonPropertyName("gt")] + public TimeSpan? Gt + { + get => GetValue("gt"); + set => SetValue("gt", value); + } - [GraphQLMember("ngt")] - [JsonPropertyName("ngt")] - public TimeSpan? Ngt - { - get => GetValue("ngt"); - set => SetValue("ngt", value); - } + [GraphQLMember("ngt")] + [JsonPropertyName("ngt")] + public TimeSpan? Ngt + { + get => GetValue("ngt"); + set => SetValue("ngt", value); + } - [GraphQLMember("gte")] - [JsonPropertyName("gte")] - public TimeSpan? Gte - { - get => GetValue("gte"); - set => SetValue("gte", value); - } + [GraphQLMember("gte")] + [JsonPropertyName("gte")] + public TimeSpan? Gte + { + get => GetValue("gte"); + set => SetValue("gte", value); + } - [GraphQLMember("ngte")] - [JsonPropertyName("ngte")] - public TimeSpan? Ngte - { - get => GetValue("ngte"); - set => SetValue("ngte", value); - } + [GraphQLMember("ngte")] + [JsonPropertyName("ngte")] + public TimeSpan? Ngte + { + get => GetValue("ngte"); + set => SetValue("ngte", value); + } - [GraphQLMember("lt")] - [JsonPropertyName("lt")] - public TimeSpan? Lt - { - get => GetValue("lt"); - set => SetValue("lt", value); - } + [GraphQLMember("lt")] + [JsonPropertyName("lt")] + public TimeSpan? Lt + { + get => GetValue("lt"); + set => SetValue("lt", value); + } - [GraphQLMember("nlt")] - [JsonPropertyName("nlt")] - public TimeSpan? Nlt - { - get => GetValue("nlt"); - set => SetValue("nlt", value); - } + [GraphQLMember("nlt")] + [JsonPropertyName("nlt")] + public TimeSpan? Nlt + { + get => GetValue("nlt"); + set => SetValue("nlt", value); + } - [GraphQLMember("lte")] - [JsonPropertyName("lte")] - public TimeSpan? Lte - { - get => GetValue("lte"); - set => SetValue("lte", value); - } - - [GraphQLMember("nlte")] - [JsonPropertyName("nlte")] - public TimeSpan? Nlte - { - get => GetValue("nlte"); - set => SetValue("nlte", value); - } + [GraphQLMember("lte")] + [JsonPropertyName("lte")] + public TimeSpan? Lte + { + get => GetValue("lte"); + set => SetValue("lte", value); + } + [GraphQLMember("nlte")] + [JsonPropertyName("nlte")] + public TimeSpan? Nlte + { + get => GetValue("nlte"); + set => SetValue("nlte", value); + } } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Interfaces/IAnimal.cs b/test/Linq2GraphQL.TestClient/Generated/Interfaces/IAnimal.cs index 61094fa8..aa90977c 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Interfaces/IAnimal.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Interfaces/IAnimal.cs @@ -14,10 +14,16 @@ namespace Linq2GraphQL.TestClient; -public static class IAnimalExtentions +/// +/// Extension methods for IAnimal interface type casting +/// +public static class IAnimalExtensions { - - + /// + /// Casts IAnimal to Pig if the runtime type matches + /// + /// The interface value to cast + /// Pig instance or null if type doesn't match [GraphInterface] public static Pig Pig(this IAnimal value) { @@ -28,6 +34,11 @@ public static Pig Pig(this IAnimal value) return null; } + /// + /// Casts IAnimal to Spider if the runtime type matches + /// + /// The interface value to cast + /// Spider instance or null if type doesn't match [GraphInterface] public static Spider Spider(this IAnimal value) { @@ -37,42 +48,73 @@ public static Spider Spider(this IAnimal value) } return null; } -} +} +/// +/// JSON converter for IAnimal interface deserialization +/// internal class IAnimalConverter : InterfaceJsonConverter { + /// + /// Deserializes JSON to the appropriate concrete type based on __typename + /// + /// The GraphQL type name from __typename field + /// The JSON object to deserialize + /// Deserialized instance of the appropriate concrete type public override IAnimal Deserialize(string typeName, JsonObject json) => typeName switch { - "Pig" => json.Deserialize(), - "Spider" => json.Deserialize(), - _ => json.Deserialize< IAnimal__Concrete>() + "Pig" => json.Deserialize(), + "Spider" => json.Deserialize(), + _ => json.Deserialize() }; } - - - +/// +/// GraphQL interface IAnimal with all common fields +/// [JsonConverter(typeof(IAnimalConverter))] public interface IAnimal { - [GraphQLMember("name")] - public string Name { get; set; } - [GraphQLMember("numberOfLegs")] - public int NumberOfLegs { get; set; } + /// + /// name field from GraphQL schema + /// + [GraphQLMember("name")] + string Name { get; set; } + + /// + /// numberOfLegs field from GraphQL schema + /// + [GraphQLMember("numberOfLegs")] + int NumberOfLegs { get; set; } + + /// + /// GraphQL __typename field for runtime type resolution + /// [GraphQLMember("__typename")] - public string __TypeName { get; set; } - + string __TypeName { get; set; } } +/// +/// Concrete implementation of IAnimal interface for fallback deserialization +/// internal class IAnimal__Concrete : IAnimal { - [GraphQLMember("name")] - public string Name { get; set; } - [GraphQLMember("numberOfLegs")] - public int NumberOfLegs { get; set; } - + /// + /// name field from GraphQL schema + /// + [GraphQLMember("name")] + public string Name { get; set; } + + /// + /// numberOfLegs field from GraphQL schema + /// + [GraphQLMember("numberOfLegs")] + public int NumberOfLegs { get; set; } + + /// + /// GraphQL __typename field for runtime type resolution + /// [GraphQLMember("__typename")] public string __TypeName { get; set; } - } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Interfaces/IMutationMethods.cs b/test/Linq2GraphQL.TestClient/Generated/Interfaces/IMutationMethods.cs index d7399031..b255d2d6 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Interfaces/IMutationMethods.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Interfaces/IMutationMethods.cs @@ -11,8 +11,23 @@ namespace Linq2GraphQL.TestClient; +/// +/// Interface for MutationMethods GraphQL operations +/// public interface IMutationMethods { - GraphQuery SetName(string name); - GraphQuery AddCustomer(CustomerInput customer); + /// + /// Executes setName GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery + GraphQuery SetName(string name = null); + + /// + /// Executes addCustomer GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery + GraphQuery AddCustomer(CustomerInput customer = null); + } diff --git a/test/Linq2GraphQL.TestClient/Generated/Interfaces/IQueryMethods.cs b/test/Linq2GraphQL.TestClient/Generated/Interfaces/IQueryMethods.cs index 0c8359af..49d46dee 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Interfaces/IQueryMethods.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Interfaces/IQueryMethods.cs @@ -5,19 +5,71 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- +using System; using System.Collections.Generic; using Linq2GraphQL.Client; namespace Linq2GraphQL.TestClient; +/// +/// Interface for QueryMethods GraphQL operations +/// public interface IQueryMethods { + /// + /// Executes hello GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery GraphQuery Hello(string name = null); + + /// + /// Executes customerReturnNull GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery GraphQuery CustomerReturnNull(); + + /// + /// Executes customers GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery> GraphQuery> Customers(); + + /// + /// Executes ordersNoBackwardPagination GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery GraphQuery OrdersNoBackwardPagination(int? first = null, string after = null, OrderFilterInput where = null, List order = null); + + /// + /// Executes ordersNoTotalCount GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphCursorQuery GraphCursorQuery OrdersNoTotalCount(int? first = null, string after = null, int? last = null, string before = null, OrderFilterInput where = null, List order = null); + + /// + /// Executes orders GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphCursorQuery GraphCursorQuery Orders(int? first = null, string after = null, int? last = null, string before = null, OrderFilterInput where = null, List order = null); + + /// + /// Executes animals GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphCursorQuery GraphCursorQuery Animals(int? first = null, string after = null, int? last = null, string before = null, IAnimalFilterInput where = null, List order = null); - GraphQuery OrdersOffsetPaging(int? skip = null, int? take = null, OrderFilterInput where = null, List order = null); + + /// + /// Executes ordersOffsetPaging GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphCursorQuery + GraphCursorQuery OrdersOffsetPaging(int? first = null, string after = null, int? last = null, string before = null, OrderFilterInput where = null, List order = null); + } diff --git a/test/Linq2GraphQL.TestClient/Generated/Interfaces/ISubscriptionMethods.cs b/test/Linq2GraphQL.TestClient/Generated/Interfaces/ISubscriptionMethods.cs index d2e45a3e..3f0ff9ff 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Interfaces/ISubscriptionMethods.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Interfaces/ISubscriptionMethods.cs @@ -5,12 +5,30 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using Linq2GraphQL.Client; using Linq2GraphQL.Client.Subscriptions; namespace Linq2GraphQL.TestClient; +/// +/// Interface for SubscriptionMethods GraphQL operations +/// public interface ISubscriptionMethods { + /// + /// Executes customerAdded GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphSubscription GraphSubscription CustomerAdded(); + + /// + /// Executes customerNameAdded GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphSubscription GraphSubscription CustomerNameAdded(string name = null); + } diff --git a/test/Linq2GraphQL.TestClient/Generated/Scalars/LocalDate.cs b/test/Linq2GraphQL.TestClient/Generated/Scalars/LocalDate.cs new file mode 100644 index 00000000..ab8249e0 --- /dev/null +++ b/test/Linq2GraphQL.TestClient/Generated/Scalars/LocalDate.cs @@ -0,0 +1,18 @@ +//--------------------------------------------------------------------- +// This code was automatically generated by Linq2GraphQL +// Please don't edit this file +// Github:https://github.com/linq2graphql/linq2graphql.client +// Url: https://linq2graphql.com +//--------------------------------------------------------------------- + + +using Linq2GraphQL.Client; +using System.Text.Json.Serialization; + +namespace Linq2GraphQL.TestClient; + + /// + /// The `LocalDate` scalar type represents a ISO date string, represented as UTF-8 character sequences YYYY-MM-DD. The scalar follows the specification defined in RFC3339 + /// + [JsonConverter(typeof(CustomScalarConverter))] + public partial class LocalDate : CustomScalar {} \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Scalars/LocalTime.cs b/test/Linq2GraphQL.TestClient/Generated/Scalars/LocalTime.cs new file mode 100644 index 00000000..f7067645 --- /dev/null +++ b/test/Linq2GraphQL.TestClient/Generated/Scalars/LocalTime.cs @@ -0,0 +1,18 @@ +//--------------------------------------------------------------------- +// This code was automatically generated by Linq2GraphQL +// Please don't edit this file +// Github:https://github.com/linq2graphql/linq2graphql.client +// Url: https://linq2graphql.com +//--------------------------------------------------------------------- + + +using Linq2GraphQL.Client; +using System.Text.Json.Serialization; + +namespace Linq2GraphQL.TestClient; + + /// + /// The LocalTime scalar type is a local time string (i.e., with no associated timezone) in 24-hr HH:mm:ss. + /// + [JsonConverter(typeof(CustomScalarConverter))] + public partial class LocalTime : CustomScalar {} \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClient/Generated/Types/Address.cs b/test/Linq2GraphQL.TestClient/Generated/Types/Address.cs index e922664e..91e8792a 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Types/Address.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Types/Address.cs @@ -28,4 +28,8 @@ public partial class Address : GraphQLTypeBase [JsonPropertyName("postalCode")] public string PostalCode { get; set; } + [GraphQLMember("createdDate")] + [JsonPropertyName("createdDate")] + public DateTime CreatedDate { get; set; } + } diff --git a/test/Linq2GraphQL.TestClient/Generated/Types/OrdersOffsetPagingConnection.cs b/test/Linq2GraphQL.TestClient/Generated/Types/OrdersOffsetPagingConnection.cs new file mode 100644 index 00000000..04b5cabb --- /dev/null +++ b/test/Linq2GraphQL.TestClient/Generated/Types/OrdersOffsetPagingConnection.cs @@ -0,0 +1,43 @@ +//--------------------------------------------------------------------- +// This code was automatically generated by Linq2GraphQL +// Please don't edit this file +// Github:https://github.com/linq2graphql/linq2graphql.client +// Url: https://linq2graphql.com +//--------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; +using Linq2GraphQL.Client; +using Linq2GraphQL.Client.Common; + +namespace Linq2GraphQL.TestClient; + + +/// +/// A connection to a list of items. +/// +public partial class OrdersOffsetPagingConnection : GraphQLTypeBase, Linq2GraphQL.Client.Common.ICursorPaging +{ + /// + /// Information to aid in pagination. + /// + [GraphQLMember("pageInfo")] + [JsonPropertyName("pageInfo")] + public Linq2GraphQL.Client.Common.PageInfo PageInfo { get; set; } + + /// + /// A list of edges. + /// + [GraphQLMember("edges")] + [JsonPropertyName("edges")] + public List Edges { get; set; } + + /// + /// A flattened list of the nodes. + /// + [GraphQLMember("nodes")] + [JsonPropertyName("nodes")] + public List Nodes { get; set; } + +} diff --git a/test/Linq2GraphQL.TestClient/Generated/Types/OrdersOffsetPagingEdge.cs b/test/Linq2GraphQL.TestClient/Generated/Types/OrdersOffsetPagingEdge.cs new file mode 100644 index 00000000..debeecfc --- /dev/null +++ b/test/Linq2GraphQL.TestClient/Generated/Types/OrdersOffsetPagingEdge.cs @@ -0,0 +1,36 @@ +//--------------------------------------------------------------------- +// This code was automatically generated by Linq2GraphQL +// Please don't edit this file +// Github:https://github.com/linq2graphql/linq2graphql.client +// Url: https://linq2graphql.com +//--------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; +using Linq2GraphQL.Client; +using Linq2GraphQL.Client.Common; + +namespace Linq2GraphQL.TestClient; + + +/// +/// An edge in a connection. +/// +public partial class OrdersOffsetPagingEdge : GraphQLTypeBase +{ + /// + /// A cursor for use in pagination. + /// + [GraphQLMember("cursor")] + [JsonPropertyName("cursor")] + public string Cursor { get; set; } + + /// + /// The item at the end of the edge. + /// + [GraphQLMember("node")] + [JsonPropertyName("node")] + public Order Node { get; set; } + +} diff --git a/test/Linq2GraphQL.TestClient/Generated/Types/Pig.cs b/test/Linq2GraphQL.TestClient/Generated/Types/Pig.cs index 050a4fc4..f3e2acf7 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Types/Pig.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Types/Pig.cs @@ -16,6 +16,10 @@ namespace Linq2GraphQL.TestClient; public partial class Pig : GraphQLTypeBase, IAnimal { + [GraphQLMember("spices")] + [JsonPropertyName("spices")] + public string Spices { get; set; } + [GraphQLMember("name")] [JsonPropertyName("name")] public string Name { get; set; } @@ -28,10 +32,6 @@ public partial class Pig : GraphQLTypeBase, IAnimal [JsonPropertyName("speed")] public int Speed { get; set; } - [GraphQLMember("spices")] - [JsonPropertyName("spices")] - public string Spices { get; set; } - [GraphQLMember("__typename")] [JsonPropertyName("__typename")] public string __TypeName { get; set; } diff --git a/test/Linq2GraphQL.TestClient/Generated/Types/Spider.cs b/test/Linq2GraphQL.TestClient/Generated/Types/Spider.cs index edcd952d..20d273d0 100644 --- a/test/Linq2GraphQL.TestClient/Generated/Types/Spider.cs +++ b/test/Linq2GraphQL.TestClient/Generated/Types/Spider.cs @@ -16,6 +16,10 @@ namespace Linq2GraphQL.TestClient; public partial class Spider : GraphQLTypeBase, IAnimal { + [GraphQLMember("poisonous")] + [JsonPropertyName("poisonous")] + public bool Poisonous { get; set; } + [GraphQLMember("name")] [JsonPropertyName("name")] public string Name { get; set; } @@ -28,10 +32,6 @@ public partial class Spider : GraphQLTypeBase, IAnimal [JsonPropertyName("speed")] public int Speed { get; set; } - [GraphQLMember("poisonous")] - [JsonPropertyName("poisonous")] - public bool Poisonous { get; set; } - [GraphQLMember("__typename")] [JsonPropertyName("__typename")] public string __TypeName { get; set; } diff --git a/test/Linq2GraphQL.TestClient/Linq2GraphQL.TestClient.csproj b/test/Linq2GraphQL.TestClient/Linq2GraphQL.TestClient.csproj index b6f2b88f..85b0a86c 100644 --- a/test/Linq2GraphQL.TestClient/Linq2GraphQL.TestClient.csproj +++ b/test/Linq2GraphQL.TestClient/Linq2GraphQL.TestClient.csproj @@ -1,14 +1,14 @@  - net8.0 + net9.0 enable - disable + disable - - + + diff --git a/test/Linq2GraphQL.TestClient/ReadMe.txt b/test/Linq2GraphQL.TestClient/ReadMe.txt index 07e77ccb..332fddad 100644 --- a/test/Linq2GraphQL.TestClient/ReadMe.txt +++ b/test/Linq2GraphQL.TestClient/ReadMe.txt @@ -7,4 +7,4 @@ dotnet tool update Linq2GraphQL.Generator -g --prerelease Linq2GraphQL https://localhost:7184/graphql/ -c="SampleClient" -n="Linq2GraphQL.TestClient" -o="Generated" -s=true *Generate local -https://localhost:7184/graphql/ -c="SampleClient" -n="Linq2GraphQL.TestClient" -o="C:\Code\Github\Linq2GraphQL.Client\test\Linq2GraphQL.TestClient\Generated" -s=true -d=true +https://localhost:7184/graphql/ -c="SampleClient" -n="Linq2GraphQL.TestClient" -o="C:\Code\Linq2GraphQL.Client\test\Linq2GraphQL.TestClient\Generated" -s=true -d=true diff --git a/test/Linq2GraphQL.TestClientNullable/Generated/Client/SampleNullableClient.cs b/test/Linq2GraphQL.TestClientNullable/Generated/Client/SampleNullableClient.cs index 3c24b38f..f2599a57 100644 --- a/test/Linq2GraphQL.TestClientNullable/Generated/Client/SampleNullableClient.cs +++ b/test/Linq2GraphQL.TestClientNullable/Generated/Client/SampleNullableClient.cs @@ -6,22 +6,46 @@ //--------------------------------------------------------------------- using Linq2GraphQL.Client; -using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace Linq2GraphQL.TestClientNullable; +/// +/// GraphQL client for SampleNullableClient operations +/// +/// +/// Provides strongly-typed access to GraphQL queries, mutations, and subscriptions. +/// Supports dependency injection for better testability and flexibility. +/// public class SampleNullableClient : ISampleNullableClient -{ - public SampleNullableClient(HttpClient httpClient, [FromKeyedServices("SampleNullableClient")]IOptions options, IServiceProvider provider) +{ + /// + /// Constructor with dependency injection support + /// + /// HTTP client for GraphQL requests + /// GraphQL client configuration options + /// Service provider for dependency resolution + /// Optional query methods implementation (uses default if null) + /// Optional mutation methods implementation (uses default if null) + public SampleNullableClient( + HttpClient httpClient, + [FromKeyedServices("SampleNullableClient")] IOptions options, + IServiceProvider provider, + IQueryMethods? queryMethods = null, + IMutationMethods? mutationMethods = null) { - var client = new GraphClient(httpClient, options, provider); - Query = new QueryMethods(client); - Mutation = new MutationMethods(client); + var client = new GraphClient(httpClient, options, provider, true); + Query = queryMethods ?? new QueryMethods(client); + Mutation = mutationMethods ?? new MutationMethods(client); } + /// + /// Gets the query methods for this GraphQL client + /// public IQueryMethods Query { get; private set; } + /// + /// Gets the mutation methods for this GraphQL client + /// public IMutationMethods Mutation { get; private set; } - } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClientNullable/Generated/Client/SampleNullableClientExtensions.cs b/test/Linq2GraphQL.TestClientNullable/Generated/Client/SampleNullableClientExtensions.cs index 064eca1c..12a94ceb 100644 --- a/test/Linq2GraphQL.TestClientNullable/Generated/Client/SampleNullableClientExtensions.cs +++ b/test/Linq2GraphQL.TestClientNullable/Generated/Client/SampleNullableClientExtensions.cs @@ -33,7 +33,7 @@ private static IGraphClientBuilder GraphClientBuilder(ISer GraphClientOptions graphClientOptions) { var opts = Options.Create(graphClientOptions); - services.AddKeyedSingleton(ClientName, opts); + services.AddKeyedSingleton(ClientName, opts); services.AddMemoryCache(); return new ClientBuilder(ClientName, services); } diff --git a/test/Linq2GraphQL.TestClientNullable/Generated/Inputs/AddressInput.cs b/test/Linq2GraphQL.TestClientNullable/Generated/Inputs/AddressInput.cs index 041c0220..e0d3b06c 100644 --- a/test/Linq2GraphQL.TestClientNullable/Generated/Inputs/AddressInput.cs +++ b/test/Linq2GraphQL.TestClientNullable/Generated/Inputs/AddressInput.cs @@ -39,4 +39,12 @@ public required string PostalCode set => SetValue("postalCode", value); } + [GraphQLMember("createdDate")] + [JsonPropertyName("createdDate")] + public required DateTime CreatedDate + { + get => GetValue("createdDate"); + set => SetValue("createdDate", value); + } + } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClientNullable/Generated/Inputs/CustomerInput.cs b/test/Linq2GraphQL.TestClientNullable/Generated/Inputs/CustomerInput.cs index f8545f2c..657c0712 100644 --- a/test/Linq2GraphQL.TestClientNullable/Generated/Inputs/CustomerInput.cs +++ b/test/Linq2GraphQL.TestClientNullable/Generated/Inputs/CustomerInput.cs @@ -55,4 +55,12 @@ public AddressInput? Address set => SetValue("address", value); } + [GraphQLMember("created")] + [JsonPropertyName("created")] + public DateTimeOffset? Created + { + get => GetValue("created"); + set => SetValue("created", value); + } + } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestClientNullable/Generated/Interfaces/IMutationMethods.cs b/test/Linq2GraphQL.TestClientNullable/Generated/Interfaces/IMutationMethods.cs index bb4eefab..3d7fc280 100644 --- a/test/Linq2GraphQL.TestClientNullable/Generated/Interfaces/IMutationMethods.cs +++ b/test/Linq2GraphQL.TestClientNullable/Generated/Interfaces/IMutationMethods.cs @@ -5,11 +5,29 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- +using System; +using System.Collections.Generic; using Linq2GraphQL.Client; namespace Linq2GraphQL.TestClientNullable; +/// +/// Interface for MutationMethods GraphQL operations +/// public interface IMutationMethods { + /// + /// Executes updateCustomer GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery + GraphQuery UpdateCustomer(CustomerInput customer); + + /// + /// Executes updatePerson GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery GraphQuery UpdatePerson(PersonInput person); + } diff --git a/test/Linq2GraphQL.TestClientNullable/Generated/Interfaces/IQueryMethods.cs b/test/Linq2GraphQL.TestClientNullable/Generated/Interfaces/IQueryMethods.cs index 67836038..06732c2d 100644 --- a/test/Linq2GraphQL.TestClientNullable/Generated/Interfaces/IQueryMethods.cs +++ b/test/Linq2GraphQL.TestClientNullable/Generated/Interfaces/IQueryMethods.cs @@ -5,20 +5,75 @@ // Url: https://linq2graphql.com //--------------------------------------------------------------------- +using System; using System.Collections.Generic; using Linq2GraphQL.Client; namespace Linq2GraphQL.TestClientNullable; +/// +/// Interface for QueryMethods GraphQL operations +/// public interface IQueryMethods { + /// + /// Executes item GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery GraphQuery Item(); + + /// + /// Executes itemDraft GraphQL operation + /// + /// + /// This operation is deprecated: This is an really old method! please d not use it!! + /// [Obsolete("This is an really old method! please d not use it!!")] + /// The operation parameters + /// GraphQL query result of type GraphQuery GraphQuery ItemDraft(); + + /// + /// Executes customerList GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery> GraphQuery> CustomerList(); + + /// + /// Executes customerNullable GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery GraphQuery CustomerNullable(); + + /// + /// Executes customerListAllNullable GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery?> GraphQuery?> CustomerListAllNullable(); + + /// + /// Executes customerListNullable GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery?> GraphQuery?> CustomerListNullable(); + + /// + /// Executes customerListInList GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery>> GraphQuery>> CustomerListInList(); + + /// + /// Executes person GraphQL operation + /// + /// The operation parameters + /// GraphQL query result of type GraphQuery GraphQuery Person(); + } diff --git a/test/Linq2GraphQL.TestClientNullable/Generated/Types/Address.cs b/test/Linq2GraphQL.TestClientNullable/Generated/Types/Address.cs index 37ba23d7..e2b8d286 100644 --- a/test/Linq2GraphQL.TestClientNullable/Generated/Types/Address.cs +++ b/test/Linq2GraphQL.TestClientNullable/Generated/Types/Address.cs @@ -29,4 +29,8 @@ public partial class Address : GraphQLTypeBase [JsonPropertyName("postalCode")] public string PostalCode { get; set; } + [GraphQLMember("createdDate")] + [JsonPropertyName("createdDate")] + public DateTime CreatedDate { get; set; } + } diff --git a/test/Linq2GraphQL.TestClientNullable/Generated/Types/Customer.cs b/test/Linq2GraphQL.TestClientNullable/Generated/Types/Customer.cs index 9b52e63f..c711cf8c 100644 --- a/test/Linq2GraphQL.TestClientNullable/Generated/Types/Customer.cs +++ b/test/Linq2GraphQL.TestClientNullable/Generated/Types/Customer.cs @@ -37,4 +37,8 @@ public partial class Customer : GraphQLTypeBase [JsonPropertyName("address")] public Address? Address { get; set; } + [GraphQLMember("created")] + [JsonPropertyName("created")] + public DateTimeOffset? Created { get; set; } + } diff --git a/test/Linq2GraphQL.TestClientNullable/Linq2GraphQL.TestClientNullable.csproj b/test/Linq2GraphQL.TestClientNullable/Linq2GraphQL.TestClientNullable.csproj index 561931a7..b88f0f49 100644 --- a/test/Linq2GraphQL.TestClientNullable/Linq2GraphQL.TestClientNullable.csproj +++ b/test/Linq2GraphQL.TestClientNullable/Linq2GraphQL.TestClientNullable.csproj @@ -1,14 +1,14 @@  - - net8.0 - enable - enable - + + net9.0 + enable + enable + + + + + + - - - - - diff --git a/test/Linq2GraphQL.TestServer.Shared/Data/SampleData.cs b/test/Linq2GraphQL.TestServer.Shared/Data/SampleData.cs index b968d62d..e51f1bb3 100644 --- a/test/Linq2GraphQL.TestServer.Shared/Data/SampleData.cs +++ b/test/Linq2GraphQL.TestServer.Shared/Data/SampleData.cs @@ -1,5 +1,5 @@ -using Linq2GraphQL.TestServer.Models; -using System.Text; +using System.Text; +using Linq2GraphQL.TestServer.Models; namespace Linq2GraphQL.TestServer.Data; @@ -8,8 +8,8 @@ public static class SampleData public static List GetAnimals() { var result = new List(); - result.Add(new Pig { Name = "Kalle", NumberOfLegs = 4, Speed = 5, Spices ="Normal" }); - result.Add(new Spider { Name = "Imse", NumberOfLegs = 8, Speed= 11, Poisonous = true}); + result.Add(new Pig { Name = "Kalle", NumberOfLegs = 4, Speed = 5, Spices = "Normal" }); + result.Add(new Spider { Name = "Imse", NumberOfLegs = 8, Speed = 11, Poisonous = true }); return result; } @@ -17,7 +17,7 @@ public static List GetAnimals() public static Item GetItem(string ItemId) { var itemName = $"Item: {ItemId}"; - return new Item { ItemId = ItemId, ItemName = itemName, Data = Encoding.ASCII.GetBytes(itemName) }; + return new() { ItemId = ItemId, ItemName = itemName, Data = Encoding.ASCII.GetBytes(itemName) }; } public static List GetCustomers() @@ -28,8 +28,7 @@ public static List GetCustomers() { CustomerId = Guid.Parse("258f2814-c938-484a-884f-8748b10ca9f9"), CustomerName = "Universal Ltd", - Status = CustomerStatus.Active, - + Status = CustomerStatus.Active }; cust1.Orders.Add(GenerateOrder1(cust1)); @@ -41,7 +40,7 @@ public static List GetCustomers() CustomerId = Guid.Parse("3b1761fb-6551-404e-80b0-a6c12f298a06"), CustomerName = "Jocke Pocke", Status = CustomerStatus.Disabled, - Address = new Address(){ Name = "JockeAddr", PostalCode = "11111", Street = "Street 123"} + Address = new() { Name = "JockeAddr", PostalCode = "11111", Street = "Street 123" } }; cust2.Orders.Add(GenerateOrder3(cust2)); @@ -56,28 +55,16 @@ private static Order GenerateOrder1(Customer customer) { var order = new Order(customer) { - OrderId = Guid.Parse("fcdf94de-403e-48ea-b5cb-383bb67694d0"), - OrderDate = new DateTimeOffset(2021, 4, 11, 2, 12, 10, 122, new TimeSpan(1, 0, 0)), - Address = new Address { Name = "Garden Inc", PostalCode = "1234", Street = "New Street 11" } + OrderId = Guid.Parse("fcdf94de-403e-48ea-b5cb-383bb67694d0"), + OrderDate = new(2021, 4, 11, 2, 12, 10, 122, new(1, 0, 0)), + Address = new() { Name = "Garden Inc", PostalCode = "1234", Street = "New Street 11" } }; - var line1 = new OrderLine(order) - { - LineNumber = 1, - Price = 56.4M, - Quantity = 10, - Item = GetItem("12345") - }; + var line1 = new OrderLine(order) { LineNumber = 1, Price = 56.4M, Quantity = 10, Item = GetItem("12345") }; order.Lines.Add(line1); - var line2 = new OrderLine(order) - { - LineNumber = 2, - Price = 11.4M, - Quantity = 123.4, - Item = GetItem("ABCDE") - }; + var line2 = new OrderLine(order) { LineNumber = 2, Price = 11.4M, Quantity = 123.4, Item = GetItem("ABCDE") }; order.Lines.Add(line2); return order; @@ -88,37 +75,19 @@ private static Order GenerateOrder2(Customer customer) var order = new Order(customer) { OrderId = Guid.Parse("80bb321a-3d00-4bd1-be55-47faf07977ac"), - OrderDate = new DateTimeOffset(2022, 06, 21, 6, 33, 1, 221, new TimeSpan(3, 0, 0)), - Address = new Address { Name = "Justify AB", PostalCode = "54354", Street = "Holy Street" } + OrderDate = new(2022, 06, 21, 6, 33, 1, 221, new(3, 0, 0)), + Address = new() { Name = "Justify AB", PostalCode = "54354", Street = "Holy Street" } }; - var line1 = new OrderLine(order) - { - LineNumber = 1, - Price = 56.4M, - Quantity = 10, - Item = GetItem("12345") - }; + var line1 = new OrderLine(order) { LineNumber = 1, Price = 56.4M, Quantity = 10, Item = GetItem("12345") }; order.Lines.Add(line1); - var line2 = new OrderLine(order) - { - LineNumber = 2, - Price = 11.4M, - Quantity = 123.4, - Item = GetItem("ABCDE") - }; + var line2 = new OrderLine(order) { LineNumber = 2, Price = 11.4M, Quantity = 123.4, Item = GetItem("ABCDE") }; order.Lines.Add(line2); - var line3 = new OrderLine(order) - { - LineNumber = 3, - Price = 2345.50M, - Quantity = 400, - Item = GetItem("AA1234") - }; + var line3 = new OrderLine(order) { LineNumber = 3, Price = 2345.50M, Quantity = 400, Item = GetItem("AA1234") }; order.Lines.Add(line3); return order; @@ -129,31 +98,18 @@ private static Order GenerateOrder3(Customer customer) var order = new Order(customer) { OrderId = Guid.Parse("ba8262aa-0b50-40f6-80f0-b4ae474bbf9a"), - OrderDate = new DateTimeOffset(2023, 06, 21, 6, 33, 1, 221, new TimeSpan(3, 0, 0)), - Address = new Address { Name = "Net Box 123", PostalCode = "123", Street = "Bang Street 99" } + OrderDate = new(2023, 06, 21, 6, 33, 1, 221, new(3, 0, 0)), + Address = new() { Name = "Net Box 123", PostalCode = "123", Street = "Bang Street 99" } }; - var line1 = new OrderLine(order) - { - LineNumber = 1, - Price = 5, - Quantity = 10, - Item = GetItem("ABC22") - }; + var line1 = new OrderLine(order) { LineNumber = 1, Price = 5, Quantity = 10, Item = GetItem("ABC22") }; order.Lines.Add(line1); - var line2 = new OrderLine(order) - { - LineNumber = 2, - Price = 111.4M, - Quantity = 11, - Item = GetItem("Vent") - }; + var line2 = new OrderLine(order) { LineNumber = 2, Price = 111.4M, Quantity = 11, Item = GetItem("Vent") }; order.Lines.Add(line2); - return order; } @@ -162,32 +118,18 @@ private static Order GenerateOrder4(Customer customer) var order = new Order(customer) { OrderId = Guid.Parse("4a0ecfc8-eec8-49bb-812e-6866157954c0"), - OrderDate = new DateTimeOffset(2021, 06, 21, 6, 33, 1, 221, new TimeSpan(3, 0, 0)), - Address = new Address { Name = "Delivery Street", PostalCode = "14332", Street = "Checker Street" } + OrderDate = new(2021, 06, 21, 6, 33, 1, 221, new(3, 0, 0)), + Address = new() { Name = "Delivery Street", PostalCode = "14332", Street = "Checker Street" } }; - var line1 = new OrderLine(order) - { - LineNumber = 1, - Price = 99.3M, - Quantity = 100, - Item = GetItem("Main Unit") - }; + var line1 = new OrderLine(order) { LineNumber = 1, Price = 99.3M, Quantity = 100, Item = GetItem("Main Unit") }; order.Lines.Add(line1); - var line2 = new OrderLine(order) - { - LineNumber = 2, - Price = 111.4M, - Quantity = 11, - Item = GetItem("Vent") - }; + var line2 = new OrderLine(order) { LineNumber = 2, Price = 111.4M, Quantity = 11, Item = GetItem("Vent") }; order.Lines.Add(line2); - return order; } - } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestServer.Shared/Linq2GraphQL.TestServer.Shared.csproj b/test/Linq2GraphQL.TestServer.Shared/Linq2GraphQL.TestServer.Shared.csproj index 3f750461..06e4737b 100644 --- a/test/Linq2GraphQL.TestServer.Shared/Linq2GraphQL.TestServer.Shared.csproj +++ b/test/Linq2GraphQL.TestServer.Shared/Linq2GraphQL.TestServer.Shared.csproj @@ -1,15 +1,15 @@ - - net8.0 - enable - enable - + + net9.0 + enable + enable + - - - - - + + + + + diff --git a/test/Linq2GraphQL.TestServer.Shared/Models/Address.cs b/test/Linq2GraphQL.TestServer.Shared/Models/Address.cs index 4704a6dd..b8871f40 100644 --- a/test/Linq2GraphQL.TestServer.Shared/Models/Address.cs +++ b/test/Linq2GraphQL.TestServer.Shared/Models/Address.cs @@ -5,4 +5,5 @@ public class Address public string Name { get; set; } = ""; public string Street { get; set; } = ""; public string PostalCode { get; set; } = ""; + public DateOnly CreatedDate { get; set; } } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestServer.Shared/Models/Customer.cs b/test/Linq2GraphQL.TestServer.Shared/Models/Customer.cs index 58c48296..06a297e6 100644 --- a/test/Linq2GraphQL.TestServer.Shared/Models/Customer.cs +++ b/test/Linq2GraphQL.TestServer.Shared/Models/Customer.cs @@ -3,11 +3,11 @@ public class Customer { public Guid CustomerId { get; set; } - public required string CustomerName { get; set; } + public required string CustomerName { get; set; } public CustomerStatus Status { get; set; } public List Orders { get; set; } = new(); public Address? Address { get; set; } - + public DateTimeOffset? Created { get; set; } } public enum AddressType diff --git a/test/Linq2GraphQL.TestServer.Shared/Models/CustomerStatus.cs b/test/Linq2GraphQL.TestServer.Shared/Models/CustomerStatus.cs index 9f39b53d..288d611e 100644 --- a/test/Linq2GraphQL.TestServer.Shared/Models/CustomerStatus.cs +++ b/test/Linq2GraphQL.TestServer.Shared/Models/CustomerStatus.cs @@ -4,6 +4,7 @@ public enum CustomerStatus { Active = 0, Disabled = 1, + [Obsolete("No longer in use, please use enum value Active instead")] InTransit = 99 } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestServer.Shared/Models/ICreature.cs b/test/Linq2GraphQL.TestServer.Shared/Models/ICreature.cs index 3e30f7fb..7a5d4b86 100644 --- a/test/Linq2GraphQL.TestServer.Shared/Models/ICreature.cs +++ b/test/Linq2GraphQL.TestServer.Shared/Models/ICreature.cs @@ -1,37 +1,30 @@ -namespace Linq2GraphQL.TestServer.Models -{ - [InterfaceType("ICanRun")] - public interface ICanRun - { - public int Speed { get; set; } - - } - - [InterfaceType("IAnimal")] - public interface IAnimal - { - string Name { get; set; } - int NumberOfLegs { get; set; } - } - - +namespace Linq2GraphQL.TestServer.Models; - public class Pig : IAnimal, ICanRun - { - public string Name { get; set; } = ""; - public int NumberOfLegs { get; set; } - public int Speed { get; set; } - - public string Spices { get; set; } = ""; - } - - public class Spider: IAnimal, ICanRun - { - public string Name { get; set; } = ""; - public int NumberOfLegs { get; set; } - public int Speed { get; set; } +[InterfaceType("ICanRun")] +public interface ICanRun +{ + public int Speed { get; set; } +} - public bool Poisonous { get; set; } - } +[InterfaceType("IAnimal")] +public interface IAnimal +{ + string Name { get; set; } + int NumberOfLegs { get; set; } +} +public class Pig : IAnimal, ICanRun +{ + public string Spices { get; set; } = ""; + public string Name { get; set; } = ""; + public int NumberOfLegs { get; set; } + public int Speed { get; set; } } + +public class Spider : IAnimal, ICanRun +{ + public bool Poisonous { get; set; } + public string Name { get; set; } = ""; + public int NumberOfLegs { get; set; } + public int Speed { get; set; } +} \ No newline at end of file diff --git a/test/Linq2GraphQL.TestServer.Shared/Models/Item.cs b/test/Linq2GraphQL.TestServer.Shared/Models/Item.cs index 05abc755..04521293 100644 --- a/test/Linq2GraphQL.TestServer.Shared/Models/Item.cs +++ b/test/Linq2GraphQL.TestServer.Shared/Models/Item.cs @@ -6,5 +6,4 @@ public class Item public string ItemName { get; set; } = ""; public byte[]? Data { get; set; } - } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestServer.Shared/Models/Order.cs b/test/Linq2GraphQL.TestServer.Shared/Models/Order.cs index 0e63ccab..11bd860f 100644 --- a/test/Linq2GraphQL.TestServer.Shared/Models/Order.cs +++ b/test/Linq2GraphQL.TestServer.Shared/Models/Order.cs @@ -32,7 +32,6 @@ public string GetOrderHello(string name, int first = 0) public Address GetOrderAddress(AddressType addressType) { - return new Address { Name = addressType.ToString(), PostalCode = "1234", Street = "Servcie Road 12345" }; + return new() { Name = addressType.ToString(), PostalCode = "1234", Street = "Servcie Road 12345" }; } - } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestServer/Linq2GraphQL.TestServer.csproj b/test/Linq2GraphQL.TestServer/Linq2GraphQL.TestServer.csproj index cfa6f1bd..260e73e3 100644 --- a/test/Linq2GraphQL.TestServer/Linq2GraphQL.TestServer.csproj +++ b/test/Linq2GraphQL.TestServer/Linq2GraphQL.TestServer.csproj @@ -2,19 +2,20 @@ Exe - net8.0 + net9.0 enable - disable + disable - - - + + + + - + diff --git a/test/Linq2GraphQL.TestServer/Mutation.cs b/test/Linq2GraphQL.TestServer/Mutation.cs index b7c0e0b7..be295470 100644 --- a/test/Linq2GraphQL.TestServer/Mutation.cs +++ b/test/Linq2GraphQL.TestServer/Mutation.cs @@ -3,6 +3,7 @@ namespace Linq2GraphQL.TestServer; +[MutationType] public class Mutation { public string SetName(string name) diff --git a/test/Linq2GraphQL.TestServer/Program.cs b/test/Linq2GraphQL.TestServer/Program.cs index c5d723e6..5b530e23 100644 --- a/test/Linq2GraphQL.TestServer/Program.cs +++ b/test/Linq2GraphQL.TestServer/Program.cs @@ -2,14 +2,16 @@ using Linq2GraphQL.TestServer.Models; var builder = WebApplication.CreateBuilder(args); -builder.Services.AddGraphQLServer() - .AddInMemorySubscriptions() - .AddQueryType() - .AddMutationType() - .AddSubscriptionType() - .AddTypeExtension() +builder.Services + .AddGraphQLServer() + .ModifyCostOptions(options => + { + options.EnforceCostLimits = false; + }) + .AddTestServerTypes() .AddType() .AddType() + .AddInMemorySubscriptions() .AddFiltering() .AddSorting(); diff --git a/test/Linq2GraphQL.TestServer/Query.cs b/test/Linq2GraphQL.TestServer/Query.cs index 103c36a6..7792f8e2 100644 --- a/test/Linq2GraphQL.TestServer/Query.cs +++ b/test/Linq2GraphQL.TestServer/Query.cs @@ -3,6 +3,7 @@ namespace Linq2GraphQL.TestServer; +[QueryType] public class Query { public string Hello(string name = "World") @@ -52,10 +53,8 @@ public IQueryable GetAnimals() return SampleData.GetAnimals().AsQueryable(); } - - - - [UseOffsetPaging(DefaultPageSize = 200, IncludeTotalCount = true)] + //[UseOffsetPaging(DefaultPageSize = 200, IncludeTotalCount = true)] + [UsePaging()] [UseFiltering] [UseSorting] public IQueryable GetOrdersOffsetPaging() diff --git a/test/Linq2GraphQL.TestServer/Subscription.cs b/test/Linq2GraphQL.TestServer/Subscription.cs index 49fbbda2..340160a9 100644 --- a/test/Linq2GraphQL.TestServer/Subscription.cs +++ b/test/Linq2GraphQL.TestServer/Subscription.cs @@ -2,6 +2,7 @@ namespace Linq2GraphQL.TestServer; +[SubscriptionType] public class Subscription { [Subscribe] @@ -11,9 +12,10 @@ public Customer CustomerAdded([EventMessage] Customer customer) } [Subscribe] - [Topic("{name}")] + [Topic($"{{{nameof(name)}}}")] public Customer CustomerNameAdded(string name, [EventMessage] Customer customer) { + Console.WriteLine($"Customer {customer.CustomerName} added from topic {name}"); return customer; } } \ No newline at end of file diff --git a/test/Linq2GraphQL.TestServerNullable/Linq2GraphQL.TestServerNullable.csproj b/test/Linq2GraphQL.TestServerNullable/Linq2GraphQL.TestServerNullable.csproj index d26bc39e..b9edda4e 100644 --- a/test/Linq2GraphQL.TestServerNullable/Linq2GraphQL.TestServerNullable.csproj +++ b/test/Linq2GraphQL.TestServerNullable/Linq2GraphQL.TestServerNullable.csproj @@ -1,23 +1,23 @@ - - Exe - net8.0 - enable - enable - + + Exe + net9.0 + enable + enable + - - - - - - + + + + + + + - - - + + + - diff --git a/test/Linq2GraphQL.TestServerNullable/Mutation.cs b/test/Linq2GraphQL.TestServerNullable/Mutation.cs index 335877e8..49a5b347 100644 --- a/test/Linq2GraphQL.TestServerNullable/Mutation.cs +++ b/test/Linq2GraphQL.TestServerNullable/Mutation.cs @@ -2,6 +2,7 @@ namespace Linq2GraphQL.TestServerNullable { + [MutationType] public class Mutation { diff --git a/test/Linq2GraphQL.TestServerNullable/Program.cs b/test/Linq2GraphQL.TestServerNullable/Program.cs index 6cd050b8..94735773 100644 --- a/test/Linq2GraphQL.TestServerNullable/Program.cs +++ b/test/Linq2GraphQL.TestServerNullable/Program.cs @@ -6,13 +6,7 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddGraphQLServer() .AddInMemorySubscriptions() - .AddQueryType() - .AddMutationType() - .AddType() - .AddType() - //.AddSubscriptionType() - //.AddType() - //.AddType() + .AddTestServerNullableTypes() .AddFiltering() .AddSorting(); diff --git a/test/Linq2GraphQL.TestServerNullable/Query.cs b/test/Linq2GraphQL.TestServerNullable/Query.cs index aa91274a..7d3709d0 100644 --- a/test/Linq2GraphQL.TestServerNullable/Query.cs +++ b/test/Linq2GraphQL.TestServerNullable/Query.cs @@ -4,6 +4,7 @@ namespace Linq2GraphQL.TestServerNullable { + [QueryType] public class Query { diff --git a/test/Linq2GraphQL.Tests/Linq2GraphQL.Tests.csproj b/test/Linq2GraphQL.Tests/Linq2GraphQL.Tests.csproj index d7e13526..a34d22ee 100644 --- a/test/Linq2GraphQL.Tests/Linq2GraphQL.Tests.csproj +++ b/test/Linq2GraphQL.Tests/Linq2GraphQL.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable @@ -10,11 +10,12 @@ - - - - - + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -26,10 +27,10 @@ - - - - + + + + diff --git a/test/Linq2GraphQL.Tests/QueryIncludeTests.cs b/test/Linq2GraphQL.Tests/QueryIncludeTests.cs index b5f3c257..81624b35 100644 --- a/test/Linq2GraphQL.Tests/QueryIncludeTests.cs +++ b/test/Linq2GraphQL.Tests/QueryIncludeTests.cs @@ -44,7 +44,6 @@ public async Task IncludePrimitives() //} - [Fact] public async Task IncludePrimitives_MultipleLevels() { @@ -69,7 +68,7 @@ public async Task IncludePrimitives_MultipleLevels() } [Fact] - public async Task IncludePrimitives_AnomousResult() + public async Task IncludePrimitives_AnonymousResult() { var query = sampleClient .Query diff --git a/test/Linq2GraphQL.Tests/SampleClientFixture.cs b/test/Linq2GraphQL.Tests/SampleClientFixture.cs index fa71fe25..44278ad4 100644 --- a/test/Linq2GraphQL.Tests/SampleClientFixture.cs +++ b/test/Linq2GraphQL.Tests/SampleClientFixture.cs @@ -22,10 +22,10 @@ public SampleClientFixture() { SubscriptionProtocol = SubscriptionProtocol.ServerSentEvents, UseSafeMode = true }), application.Services); - + // Cast to interface for testing interface functionality sampleClientInterface = sampleClient; - + //Please note currently only ServerSentEvents work in test project }