From 6015f208a688d8fdcd7990d94c2df9d02888ede5 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Tue, 21 Feb 2023 18:59:47 +0100 Subject: [PATCH] Fixed WithOptions for WebSocket endpoint. (#5879) --- .../Extensions/EndpointRouteBuilderExtensions.cs | 8 +++++--- .../AspNetCore/src/AspNetCore/GraphQLSocketOptions.cs | 4 ++-- .../test/AspNetCore.Tests.Utilities/ServerTestBase.cs | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/Extensions/EndpointRouteBuilderExtensions.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/Extensions/EndpointRouteBuilderExtensions.cs index 58c14b388ed..dc7436ace59 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/Extensions/EndpointRouteBuilderExtensions.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/Extensions/EndpointRouteBuilderExtensions.cs @@ -199,7 +199,7 @@ public static GraphQLHttpEndpointConventionBuilder MapGraphQLHttp( /// /// The is null. /// - public static IEndpointConventionBuilder MapGraphQLWebSocket( + public static WebSocketEndpointConventionBuilder MapGraphQLWebSocket( this IEndpointRouteBuilder endpointRouteBuilder, string pattern = _graphQLWebSocketPath, string? schemaName = default) @@ -224,7 +224,7 @@ public static IEndpointConventionBuilder MapGraphQLWebSocket( /// /// The is null. /// - public static IEndpointConventionBuilder MapGraphQLWebSocket( + public static WebSocketEndpointConventionBuilder MapGraphQLWebSocket( this IEndpointRouteBuilder endpointRouteBuilder, RoutePattern pattern, string? schemaName = default) @@ -251,10 +251,12 @@ public static IEndpointConventionBuilder MapGraphQLWebSocket( return Task.CompletedTask; }); - return new GraphQLEndpointConventionBuilder( + var builder = new GraphQLEndpointConventionBuilder( endpointRouteBuilder .Map(pattern, requestPipeline.Build()) .WithDisplayName("Hot Chocolate GraphQL WebSocket Pipeline")); + + return new WebSocketEndpointConventionBuilder(builder); } /// diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore/GraphQLSocketOptions.cs b/src/HotChocolate/AspNetCore/src/AspNetCore/GraphQLSocketOptions.cs index 54c3ab92462..f00e8fd7e3d 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore/GraphQLSocketOptions.cs +++ b/src/HotChocolate/AspNetCore/src/AspNetCore/GraphQLSocketOptions.cs @@ -20,8 +20,8 @@ public sealed class GraphQLSocketOptions /// /// If the interval is set to null the server will send no keep alive messages. /// - /// Default: TimeSpan.FromSeconds(30) + /// Default: TimeSpan.FromSeconds(5) /// public TimeSpan? KeepAliveInterval { get; set; } = - TimeSpan.FromSeconds(30); + TimeSpan.FromSeconds(5); } diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs index ec2986b47df..bd62a54fa24 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs @@ -111,7 +111,8 @@ protected virtual TestServer CreateStarWarsServer( endpoints.MapGraphQL("/batching"). WithOptions(new GraphQLServerOptions { - + // with defaults + // EnableBatching = false }); })); }