diff --git a/src/GraphQL.AspNetCore3/WebSockets/GraphQLWs/SubscriptionServer.cs b/src/GraphQL.AspNetCore3/WebSockets/GraphQLWs/SubscriptionServer.cs
index 8e75172..d858588 100644
--- a/src/GraphQL.AspNetCore3/WebSockets/GraphQLWs/SubscriptionServer.cs
+++ b/src/GraphQL.AspNetCore3/WebSockets/GraphQLWs/SubscriptionServer.cs
@@ -182,10 +182,9 @@ await Connection.SendMessageAsync(new OperationMessage {
///
protected override async Task ExecuteRequestAsync(OperationMessage message)
{
- var request = Serializer.ReadNode(message.Payload);
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
- if (request == null)
- throw new ArgumentNullException(nameof(message) + "." + nameof(OperationMessage.Payload));
+ var request = Serializer.ReadNode(message.Payload)
+ ?? throw new ArgumentNullException(nameof(message) + "." + nameof(OperationMessage.Payload));
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
using var scope = ServiceScopeFactory.CreateScope();
try {
diff --git a/src/GraphQL.AspNetCore3/WebSockets/SubscriptionsTransportWs/SubscriptionServer.cs b/src/GraphQL.AspNetCore3/WebSockets/SubscriptionsTransportWs/SubscriptionServer.cs
index 4d41a11..2e72846 100644
--- a/src/GraphQL.AspNetCore3/WebSockets/SubscriptionsTransportWs/SubscriptionServer.cs
+++ b/src/GraphQL.AspNetCore3/WebSockets/SubscriptionsTransportWs/SubscriptionServer.cs
@@ -162,10 +162,9 @@ await Connection.SendMessageAsync(new OperationMessage {
///
protected override async Task ExecuteRequestAsync(OperationMessage message)
{
- var request = Serializer.ReadNode(message.Payload);
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
- if (request == null)
- throw new ArgumentNullException(nameof(message) + "." + nameof(OperationMessage.Payload));
+ var request = Serializer.ReadNode(message.Payload)
+ ?? throw new ArgumentNullException(nameof(message) + "." + nameof(OperationMessage.Payload));
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
using var scope = ServiceScopeFactory.CreateScope();
try {
diff --git a/src/Tests/Middleware/WebSocketTests.cs b/src/Tests/Middleware/WebSocketTests.cs
index 72c764c..90123e0 100644
--- a/src/Tests/Middleware/WebSocketTests.cs
+++ b/src/Tests/Middleware/WebSocketTests.cs
@@ -9,10 +9,8 @@ public class WebSocketTests : IDisposable
private void Configure(Action? configureOptions = null, Action? configureServices = null)
{
- if (configureOptions == null)
- configureOptions = _ => { };
- if (configureServices == null)
- configureServices = _ => { };
+ configureOptions ??= _ => { };
+ configureServices ??= _ => { };
var hostBuilder = new WebHostBuilder();
hostBuilder.ConfigureServices(services => {