diff --git a/Directory.Packages.support.props b/Directory.Packages.support.props
index c460a9722..400df97b8 100644
--- a/Directory.Packages.support.props
+++ b/Directory.Packages.support.props
@@ -5,10 +5,10 @@
-
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/src/HotChocolate/Configuration/ConfigureRootTypeSchemaInterceptor.cs b/src/HotChocolate/Configuration/ConfigureRootTypeSchemaInterceptor.cs
index 5dc8d31b0..a3a03f4c8 100644
--- a/src/HotChocolate/Configuration/ConfigureRootTypeSchemaInterceptor.cs
+++ b/src/HotChocolate/Configuration/ConfigureRootTypeSchemaInterceptor.cs
@@ -3,6 +3,7 @@
using HotChocolate.Language;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors;
+using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,75 +12,77 @@ namespace Rocket.Surgery.LaunchPad.HotChocolate.Configuration
{
public class ConfigureRootTypeSchemaInterceptor : SchemaInterceptor
{
+ private readonly ILogger _logger;
private readonly IConfigureGraphqlRootType[] _configureMutationTypes;
private readonly IConfigureGraphqlRootType[] _configureQueryTypes;
private readonly IConfigureGraphqlRootType[] _configureSubscriptionTypes;
public ConfigureRootTypeSchemaInterceptor(
+ ILogger logger,
NameString? name,
IEnumerable configureGraphqlRootTypes
)
{
- var _configureGraphqlRootTypes = configureGraphqlRootTypes.ToArray();
- _configureMutationTypes = _configureGraphqlRootTypes
+ _logger = logger;
+ var configureRootTypes = configureGraphqlRootTypes.ToArray();
+ _configureMutationTypes = configureRootTypes
.Where(z => z.OperationType == OperationType.Mutation)
.ToArray();
- _configureQueryTypes = _configureGraphqlRootTypes
+ _configureQueryTypes = configureRootTypes
.Where(z => z.OperationType == OperationType.Query)
.ToArray();
- _configureSubscriptionTypes = _configureGraphqlRootTypes
+ _configureSubscriptionTypes = configureRootTypes
.Where(z => z.OperationType == OperationType.Subscription)
.ToArray();
}
public override void OnBeforeCreate(IDescriptorContext context, ISchemaBuilder schemaBuilder)
{
- ConfigureType(context, schemaBuilder, OperationType.Mutation, _configureMutationTypes);
- ConfigureType(context, schemaBuilder, OperationType.Query, _configureQueryTypes);
- ConfigureType(context, schemaBuilder, OperationType.Subscription, _configureSubscriptionTypes);
+ ConfigureType(context, schemaBuilder, OperationType.Mutation, _configureMutationTypes, _logger);
+ ConfigureType(context, schemaBuilder, OperationType.Query, _configureQueryTypes, _logger);
+ ConfigureType(context, schemaBuilder, OperationType.Subscription, _configureSubscriptionTypes, _logger);
}
private static void ConfigureType(
IDescriptorContext context,
ISchemaBuilder schemaBuilder,
OperationType operationType,
- IEnumerable actions
+ IEnumerable actions,
+ ILogger logger
)
{
- // var descriptor = ObjectTypeDescriptor.FromSchemaType(context, typeof(ObjectType));
- // descriptor.Name(operationType.ToString());
- // foreach (var item in actions)
- // {
- // item(descriptor);
- // }
- //
- // if (descriptor.CreateDefinition().Fields.Any())
- // {
if (!actions.Any())
return;
- schemaBuilder.AddRootType(
- new ObjectType(
- descriptor =>
- {
- descriptor.Name(operationType.ToString());
- foreach (var item in actions
- .Where(
- z => z.SchemaName is null
- || (
- context.ContextData.TryGetValue("SchemaName", out var name) && name is string ns && ns == z.SchemaName
- )
- )
- )
+
+ try
+ {
+ schemaBuilder.AddRootType(
+ new ObjectType(
+ descriptor =>
{
- item.Configure(descriptor);
+ descriptor.Name(operationType.ToString());
+ foreach (var item in actions
+ .Where(
+ z => z.SchemaName is null
+ || (
+ context.ContextData.TryGetValue("SchemaName", out var name) && name is string ns && ns == z.SchemaName
+ )
+ )
+ )
+ {
+ item.Configure(descriptor);
+ }
}
- }
- ),
- operationType
- );
- // }
+ ),
+ operationType
+ );
+ }
+ catch (ArgumentException e)
+ {
+ logger.LogWarning(e, "Unable to configure {OperationType}", operationType);
+ }
}
}
}
\ No newline at end of file