diff --git a/src/StrawberryShake/Client/src/Transport.Http/HttpConnection.cs b/src/StrawberryShake/Client/src/Transport.Http/HttpConnection.cs index 25ab30e9f07..9914571d30a 100644 --- a/src/StrawberryShake/Client/src/Transport.Http/HttpConnection.cs +++ b/src/StrawberryShake/Client/src/Transport.Http/HttpConnection.cs @@ -1,3 +1,4 @@ +using System.Collections.Immutable; using System.Text; using System.Text.Json; using HotChocolate.Transport.Http; @@ -10,6 +11,7 @@ public class HttpConnection : IHttpConnection { public const string RequestUri = "StrawberryShake.Transport.Http.HttpConnection.RequestUri"; public const string HttpClient = "StrawberryShake.Transport.Http.HttpConnection.HttpClient"; + public const string HttpStatusCodeCaptureKey = "StrawberryShake.Transport.Http.HttpConnection.HttpStatusCodeCaptureKey"; private readonly Func _createClient; private readonly object? _clientFactoryState; @@ -37,7 +39,7 @@ public IAsyncEnumerable> ExecuteAsync(OperationRequest re return Create( CreateClient(request), CreateHttpRequest(request), - CreateResponse); + context => CreateResponse(context, request)); } protected virtual HttpClient CreateClient(OperationRequest request) @@ -105,6 +107,34 @@ protected virtual GraphQLHttpRequest CreateHttpRequest(OperationRequest request) return new GraphQLHttpRequest(operation) { EnableFileUploads = hasFiles }; } + private Response CreateResponse( + HttpResponseContext responseContext, + OperationRequest operationRequest) + { + // Capture the status code of the response if requested + if (operationRequest.ContextData.TryGetValue(HttpStatusCodeCaptureKey, out var key) + && key is string stringKey + && !string.IsNullOrEmpty(stringKey)) + { + var responseContextData = responseContext.ContextData; + var mutableResponseContextData = + responseContextData as IImmutableDictionary ?? + responseContextData?.ToImmutableDictionary() ?? + ImmutableDictionary.Empty; + + responseContext = new HttpResponseContext( + responseContext.Response, + responseContext.Body, + responseContext.Exception, + responseContext.IsPatch, + responseContext.HasNext, + responseContext.Extensions, + mutableResponseContextData.Add(stringKey, responseContext.Response.StatusCode)); + } + + return CreateResponse(responseContext); + } + protected virtual Response CreateResponse( HttpResponseContext responseContext) { diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs index 9d1b9f01c85..5c3f6d1f7b4 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs @@ -306,7 +306,8 @@ private static IReadOnlyList GenerateCSharpDocuments( settings.NoStore, settings.InputRecords, settings.EntityRecords, - settings.RazorComponents); + settings.RazorComponents, + settings.GenerateWithHttpStatusCodeCaptureMethod); var results = new List(); diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGeneratorSettings.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGeneratorSettings.cs index 438ea7aafbb..598b0a02dc6 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGeneratorSettings.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGeneratorSettings.cs @@ -76,4 +76,10 @@ public class CSharpGeneratorSettings subscription: TransportType.WebSocket) ]; + + /// + /// A value indicating whether to generate the + /// WithHttpStatusCodeCapture(string key = "HttpStatusCode")-method. + /// + public bool GenerateWithHttpStatusCodeCaptureMethod { get; set; } } diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/OperationServiceGenerator.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/OperationServiceGenerator.cs index 0d1988a4584..d15895afcf2 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/OperationServiceGenerator.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/OperationServiceGenerator.cs @@ -105,7 +105,7 @@ protected override void Generate( var serializerAssignments = UseInjectedSerializers(descriptor, privateConstructorBuilder); - foreach (var method in CreateWitherMethods(descriptor, serializerAssignments)) + foreach (var method in CreateWitherMethods(descriptor, serializerAssignments, settings)) { classBuilder.AddMethod(method); } @@ -387,9 +387,9 @@ private MethodBuilder CreateExecuteMethod( .AddArgument("false"))); } - private static IEnumerable CreateWitherMethods( - OperationDescriptor operationDescriptor, - string serializerAssignments) + private static IEnumerable CreateWitherMethods(OperationDescriptor operationDescriptor, + string serializerAssignments, + CSharpSyntaxGeneratorSettings settings) { var withMethod = MethodBuilder .New() @@ -439,6 +439,26 @@ private static IEnumerable CreateWitherMethods( string.Format( "return With(r => r.ContextData[\"{0}\"] = httpClient);" + Environment.NewLine, "StrawberryShake.Transport.Http.HttpConnection.HttpClient"))); + + if (settings.GenerateWithHttpStatusCodeCaptureMethod) + { + var withHttpStatusCodeCaptureUriMethod = MethodBuilder + .New() + .SetPublic() + .SetReturnType(operationDescriptor.InterfaceType.ToString()) + .SetName("WithHttpStatusCodeCapture"); + + withHttpStatusCodeCaptureUriMethod + .AddParameter("key") + .SetDefault("\"HttpStatusCode\"") + .SetType(TypeNames.String); + + yield return withHttpStatusCodeCaptureUriMethod + .AddCode(CodeInlineBuilder.From( + string.Format( + "return With(r => r.ContextData[\"{0}\"] = key);" + Environment.NewLine, + "StrawberryShake.Transport.Http.HttpConnection.HttpStatusCodeCaptureKey"))); + } } private static MethodBuilder CreateRequestVariablesMethod( diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/OperationServiceInterfaceGenerator.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/OperationServiceInterfaceGenerator.cs index cc036c7c3c9..2978d3b10d7 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/OperationServiceInterfaceGenerator.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/OperationServiceInterfaceGenerator.cs @@ -41,7 +41,7 @@ protected override void Generate(OperationDescriptor descriptor, if (descriptor is not SubscriptionOperationDescriptor) { - foreach (var method in CreateWitherMethods(descriptor)) + foreach (var method in CreateWitherMethods(descriptor, settings)) { interfaceBuilder.AddMethod(method); } @@ -111,8 +111,8 @@ private static MethodBuilder CreateExecuteMethod( return executeMethod; } - private static IEnumerable CreateWitherMethods( - OperationDescriptor operationDescriptor) + private static IEnumerable CreateWitherMethods(OperationDescriptor operationDescriptor, + CSharpSyntaxGeneratorSettings settings) { var withMethod = MethodBuilder .New() @@ -149,5 +149,21 @@ private static IEnumerable CreateWitherMethods( .SetType("global::System.Net.Http.HttpClient"); yield return withHttpClientMethod; + + if (settings.GenerateWithHttpStatusCodeCaptureMethod) + { + var withHttpStatusCodeCaptureUriMethod = MethodBuilder + .New() + .SetOnlyDeclaration() + .SetReturnType(operationDescriptor.InterfaceType.ToString()) + .SetName("WithHttpStatusCodeCapture"); + + withHttpStatusCodeCaptureUriMethod + .AddParameter("key") + .SetDefault("\"HttpStatusCode\"") + .SetType(TypeNames.String); + + yield return withHttpStatusCodeCaptureUriMethod; + } } } diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration/CSharpSyntaxGeneratorSettings.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration/CSharpSyntaxGeneratorSettings.cs index 45039d1f034..93670c20f51 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration/CSharpSyntaxGeneratorSettings.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration/CSharpSyntaxGeneratorSettings.cs @@ -13,13 +13,15 @@ public CSharpSyntaxGeneratorSettings( bool noStore, bool inputRecords, bool entityRecords, - bool razorComponents) + bool razorComponents, + bool generateWithHttpStatusCodeCaptureMethod) { AccessModifier = accessModifier; NoStore = noStore; InputRecords = inputRecords; EntityRecords = entityRecords; RazorComponents = razorComponents; + GenerateWithHttpStatusCodeCaptureMethod = generateWithHttpStatusCodeCaptureMethod; } /// @@ -46,4 +48,10 @@ public CSharpSyntaxGeneratorSettings( /// Generate Razor components. /// public bool RazorComponents { get; } + + /// + /// A value indicating whether to generate the + /// WithHttpStatusCodeCapture(string key = "HttpStatusCode")-method. + /// + public bool GenerateWithHttpStatusCodeCaptureMethod { get; set; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/GeneratorTestHelper.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/GeneratorTestHelper.cs index d64c6f64b92..28cde96135d 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/GeneratorTestHelper.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/GeneratorTestHelper.cs @@ -93,7 +93,8 @@ public static void AssertResult( NoStore = settings.NoStore, InputRecords = settings.InputRecords, EntityRecords = settings.EntityRecords, - RazorComponents = settings.RazorComponents + RazorComponents = settings.RazorComponents, + GenerateWithHttpStatusCodeCaptureMethod = settings.GenerateWithHttpStatusCodeCaptureMethod }); Assert.False( @@ -198,6 +199,7 @@ public static AssertSettings CreateIntegrationTest( TransportProfile[]? profiles = null, AccessModifier accessModifier = AccessModifier.Public, bool noStore = false, + bool generateWithHttpStatusCodeCaptureMethod = false, [CallerMemberName] string? testName = null) { var snapshotFullName = Snapshot.FullName(); @@ -226,6 +228,7 @@ public static AssertSettings CreateIntegrationTest( testName + "Test.Client.cs"), RequestStrategy = requestStrategy, NoStore = noStore, + GenerateWithHttpStatusCodeCaptureMethod = generateWithHttpStatusCodeCaptureMethod, Profiles = (profiles ?? [ TransportProfile.Default @@ -282,5 +285,7 @@ public class AssertSettings public RequestStrategyGen RequestStrategy { get; set; } = RequestStrategyGen.Default; + + public bool GenerateWithHttpStatusCodeCaptureMethod { get; set; } } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs index eacc73e6775..1b0530d0f94 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.Client.cs @@ -518,6 +518,11 @@ private GetHeroQuery(global::StrawberryShake.IOperationExecutor return With(r => r.ContextData["StrawberryShake.Transport.Http.HttpConnection.HttpClient"] = httpClient); } + public global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.IGetHeroQuery WithHttpStatusCodeCapture(global::System.String key = "HttpStatusCode") + { + return With(r => r.ContextData["StrawberryShake.Transport.Http.HttpConnection.HttpStatusCodeCaptureKey"] = key); + } + public async global::System.Threading.Tasks.Task> ExecuteAsync(global::System.Threading.CancellationToken cancellationToken = default) { var request = CreateRequest(); @@ -575,6 +580,7 @@ public partial interface IGetHeroQuery : global::StrawberryShake.IOperationReque global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.IGetHeroQuery With(global::System.Action configure); global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.IGetHeroQuery WithRequestUri(global::System.Uri requestUri); global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.IGetHeroQuery WithHttpClient(global::System.Net.Http.HttpClient httpClient); + global::StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.IGetHeroQuery WithHttpStatusCodeCapture(global::System.String key = "HttpStatusCode"); global::System.Threading.Tasks.Task> ExecuteAsync(global::System.Threading.CancellationToken cancellationToken = default); global::System.IObservable> Watch(global::StrawberryShake.ExecutionStrategy? strategy = null); } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.cs index a2f38bbd649..cc3a68e52a1 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsGetHeroTest.cs @@ -1,9 +1,11 @@ +using System.Net; using HotChocolate.AspNetCore.Tests.Utilities; using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero.State; using StrawberryShake.Transport.WebSockets; using StrawberryShake.Persistence.SQLite; +using StrawberryShake.Transport.Http; namespace StrawberryShake.CodeGeneration.CSharp.Integration.StarWarsGetHero; @@ -40,6 +42,41 @@ public async Task Execute_StarWarsGetHero_Test() Assert.Equal("R2-D2", result.Data!.Hero!.Name); } + [Theory] + [InlineData(HttpStatusCode.OK)] + [InlineData(HttpStatusCode.Forbidden)] + public async Task Execute_StarWarsGetHero_ShouldCaptureExpectedStatusCode(HttpStatusCode expectedStatusCode) + { + // Arrange + using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20)); + using var host = TestServerHelper.CreateServer(_ => { }, out var port); + + var services = new ServiceCollection(); + + services + .AddStarWarsGetHeroClient() + .ConfigureHttpClient(client => + { + if (expectedStatusCode == HttpStatusCode.Forbidden) + { + client.DefaultRequestHeaders.Add("sendErrorStatusCode", "1"); + } + }); + + var serviceProvider = services.BuildServiceProvider(); + var client = serviceProvider.GetRequiredService(); + + // Act + var result = await client.GetHero + .WithRequestUri(new Uri($"http://localhost:{port}/graphql")) + .WithHttpStatusCodeCapture(key: "foo") + .ExecuteAsync(cts.Token); + + // Assert + Assert.Equal("R2-D2", result.Data!.Hero!.Name); + Assert.Equal(expectedStatusCode, result.ContextData["foo"]); + } + [Fact] public async Task Watch_StarWarsGetHero_Test() { diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs index 07983f605b3..e4e304a2a23 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/TestGeneration.cs @@ -9,7 +9,7 @@ public class TestGeneration [Fact] public void StarWarsGetHero() => AssertStarWarsResult( - CreateIntegrationTest(), + CreateIntegrationTest(generateWithHttpStatusCodeCaptureMethod: true), @"query GetHero { hero(episode: NEW_HOPE) { name diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/GeneratorTestHelper.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/GeneratorTestHelper.cs index 39fb736d23b..f27bf427d08 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/GeneratorTestHelper.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/GeneratorTestHelper.cs @@ -92,7 +92,8 @@ public static void AssertResult( NoStore = settings.NoStore, InputRecords = settings.InputRecords, EntityRecords = settings.EntityRecords, - RazorComponents = settings.RazorComponents + RazorComponents = settings.RazorComponents, + GenerateWithHttpStatusCodeCaptureMethod = settings.GenerateWithHttpStatusCodeCaptureMethod }); Assert.False( @@ -276,5 +277,7 @@ public class AssertSettings public RequestStrategyGen RequestStrategy { get; set; } = RequestStrategyGen.Default; + + public bool GenerateWithHttpStatusCodeCaptureMethod { get; set; } } } diff --git a/src/StrawberryShake/Tooling/src/Configuration/StrawberryShakeSettings.cs b/src/StrawberryShake/Tooling/src/Configuration/StrawberryShakeSettings.cs index 23411a7fc7b..33fb42e726a 100644 --- a/src/StrawberryShake/Tooling/src/Configuration/StrawberryShakeSettings.cs +++ b/src/StrawberryShake/Tooling/src/Configuration/StrawberryShakeSettings.cs @@ -65,6 +65,13 @@ public class StrawberryShakeSettings /// public bool? RazorComponents { get; set; } + /// + /// Defines if the generator shall generate the + /// WithHttpStatusCodeCapture(string key = "HttpStatusCode")-method + /// that can be used to capture the HTTP status code. + /// + public bool? GenerateWithHttpStatusCodeCaptureMethod { get; set; } + /// /// Gets the record generator settings. /// diff --git a/src/StrawberryShake/Tooling/src/dotnet-graphql/GenerateCommand.cs b/src/StrawberryShake/Tooling/src/dotnet-graphql/GenerateCommand.cs index e403de110b4..131d5d6d76b 100644 --- a/src/StrawberryShake/Tooling/src/dotnet-graphql/GenerateCommand.cs +++ b/src/StrawberryShake/Tooling/src/dotnet-graphql/GenerateCommand.cs @@ -64,6 +64,11 @@ public static void Build(CommandLineApplication generate) "Console output as JSON.", CommandOptionType.NoValue); + var generateWithHttpStatusCodeCaptureMethodArg = generate.Option( + "--generateWithHttpStatusCodeCaptureMethod", + "Generate the 'WithHttpStatusCodeCapture'-method.", + CommandOptionType.NoValue); + generate.OnExecuteAsync( ct => { @@ -86,7 +91,8 @@ public static void Build(CommandLineApplication generate) outputDirArg.Value(), strategy, operationOutputDir, - relayFormatArg.HasValue()); + relayFormatArg.HasValue(), + generateWithHttpStatusCodeCaptureMethodArg.HasValue()); var handler = CommandTools.CreateHandler(jsonArg); return handler.ExecuteAsync(arguments, ct); }); @@ -321,7 +327,8 @@ public GenerateCommandArguments( string? outputDir, RequestStrategy strategy, string? operationOutputDir, - bool relayFormat) + bool relayFormat, + bool generateWithHttpStatusCodeCaptureMethod) { Path = path; RootNamespace = rootNamespace; @@ -334,6 +341,7 @@ public GenerateCommandArguments( Strategy = strategy; RelayFormat = relayFormat; OperationOutputDir = operationOutputDir; + GenerateWithHttpStatusCodeCaptureMethod = generateWithHttpStatusCodeCaptureMethod; if (operationOutputDir is null && outputDir is not null) { @@ -362,5 +370,7 @@ public GenerateCommandArguments( public string? OperationOutputDir { get; } public bool RelayFormat { get; } + + public bool GenerateWithHttpStatusCodeCaptureMethod { get; } } } diff --git a/src/StrawberryShake/Tooling/src/dotnet-graphql/GeneratorHelpers.cs b/src/StrawberryShake/Tooling/src/dotnet-graphql/GeneratorHelpers.cs index d88ccc2abca..5e68c334150 100644 --- a/src/StrawberryShake/Tooling/src/dotnet-graphql/GeneratorHelpers.cs +++ b/src/StrawberryShake/Tooling/src/dotnet-graphql/GeneratorHelpers.cs @@ -84,7 +84,8 @@ public static CSharpGeneratorSettings CreateSettings( SingleCodeFile = configSettings.UseSingleFile ?? args.UseSingleFile, RequestStrategy = configSettings.RequestStrategy ?? args.Strategy, HashProvider = GetHashProvider(configSettings.HashAlgorithm ?? args.HashAlgorithm), - TransportProfiles = MapTransportProfiles(configSettings.TransportProfiles) + TransportProfiles = MapTransportProfiles(configSettings.TransportProfiles), + GenerateWithHttpStatusCodeCaptureMethod = configSettings.GenerateWithHttpStatusCodeCaptureMethod ?? args.GenerateWithHttpStatusCodeCaptureMethod }; } diff --git a/src/StrawberryShake/Tooling/test/Configuration.Tests/GraphQLConfigTests.cs b/src/StrawberryShake/Tooling/test/Configuration.Tests/GraphQLConfigTests.cs index d1087831607..209c04aaefa 100644 --- a/src/StrawberryShake/Tooling/test/Configuration.Tests/GraphQLConfigTests.cs +++ b/src/StrawberryShake/Tooling/test/Configuration.Tests/GraphQLConfigTests.cs @@ -83,6 +83,40 @@ public void Load_Json_With_Transport_Profiles() ").MatchSnapshot(); } + [Fact] + public void Load_Json_With_GenerateWithHttpStatusCodeCaptureMethod() + { + GraphQLConfig.FromJson(@"{ + ""schema"": ""schema.graphql"", + ""documents"": ""**/*.graphql"", + ""extensions"": { + ""strawberryShake"": { + ""name"": ""Client"", + ""accessModifier"": ""public"", + ""dependencyInjection"": true, + ""strictSchemaValidation"": true, + ""hashAlgorithm"": ""md5"", + ""useSingleFile"": true, + ""requestStrategy"": ""Default"", + ""outputDirectoryName"": ""Generated"", + ""noStore"": false, + ""emitGeneratedCode"": true, + ""records"": { + ""inputs"": false, + ""entities"": false + }, + ""transportProfiles"": [ + { + ""default"": ""Http"", + ""subscription"": ""WebSocket"" + }], + ""GenerateWithHttpStatusCodeCaptureMethod"": true + } + } + } + ").MatchSnapshot(); + } + [Fact] public void Load_Json_With_Records() { diff --git a/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json.snap b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json.snap index b99bdbbfcb9..597cd9498d2 100644 --- a/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json.snap +++ b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json.snap @@ -1,4 +1,4 @@ -{ +{ "Schema": "schema.graphql", "Documents": "**/*.graphql", "Location": null, @@ -16,6 +16,7 @@ "OutputDirectoryName": "Generated", "NoStore": false, "RazorComponents": null, + "GenerateWithHttpStatusCodeCaptureMethod": null, "Records": { "Inputs": false, "Entities": false diff --git a/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Documents_Array.snap b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Documents_Array.snap index de4506d8477..3786f44c6b7 100644 --- a/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Documents_Array.snap +++ b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Documents_Array.snap @@ -1,4 +1,4 @@ -{ +{ "Schema": "schema.graphql", "Documents": [ "**/*.graphql", @@ -19,6 +19,7 @@ "OutputDirectoryName": "Generated", "NoStore": false, "RazorComponents": null, + "GenerateWithHttpStatusCodeCaptureMethod": null, "Records": { "Inputs": true, "Entities": true diff --git a/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_GenerateWithHttpStatusCodeCaptureMethod.snap b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_GenerateWithHttpStatusCodeCaptureMethod.snap new file mode 100644 index 00000000000..a0fef815439 --- /dev/null +++ b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_GenerateWithHttpStatusCodeCaptureMethod.snap @@ -0,0 +1,35 @@ +{ + "Schema": "schema.graphql", + "Documents": "**/*.graphql", + "Location": null, + "Extensions": { + "StrawberryShake": { + "Name": "Client", + "Namespace": null, + "Url": null, + "AccessModifier": "public", + "DependencyInjection": true, + "StrictSchemaValidation": true, + "HashAlgorithm": "md5", + "UseSingleFile": true, + "RequestStrategy": "Default", + "OutputDirectoryName": "Generated", + "NoStore": false, + "RazorComponents": null, + "GenerateWithHttpStatusCodeCaptureMethod": true, + "Records": { + "Inputs": false, + "Entities": false + }, + "TransportProfiles": [ + { + "Name": null, + "Default": "Http", + "Query": null, + "Mutation": null, + "Subscription": "WebSocket" + } + ] + } + } +} diff --git a/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Records.snap b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Records.snap index cfb96fd12f7..5e662f6ce39 100644 --- a/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Records.snap +++ b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Records.snap @@ -1,4 +1,4 @@ -{ +{ "Schema": "schema.graphql", "Documents": "**/*.graphql", "Location": null, @@ -16,6 +16,7 @@ "OutputDirectoryName": "Generated", "NoStore": false, "RazorComponents": null, + "GenerateWithHttpStatusCodeCaptureMethod": null, "Records": { "Inputs": true, "Entities": true diff --git a/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Transport_Profiles.snap b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Transport_Profiles.snap index bddede28d00..1b9d047156a 100644 --- a/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Transport_Profiles.snap +++ b/src/StrawberryShake/Tooling/test/Configuration.Tests/__snapshots__/GraphQLConfigTests.Load_Json_With_Transport_Profiles.snap @@ -1,4 +1,4 @@ -{ +{ "Schema": "schema.graphql", "Documents": "**/*.graphql", "Location": null, @@ -16,6 +16,7 @@ "OutputDirectoryName": "Generated", "NoStore": false, "RazorComponents": null, + "GenerateWithHttpStatusCodeCaptureMethod": null, "Records": { "Inputs": false, "Entities": false