-
-
Notifications
You must be signed in to change notification settings - Fork 798
Open
Labels
Description
Product
Hot Chocolate
Version
15.1.10
Link to minimal reproduction
https://github.com/denys-vynohradov-saltykov/hot-chocolate-nested-list-error-poc
Steps to reproduce
- Create web project with package references
HotChocolate.AspNetCore
andHotChocolate.Types.Analyzers
- Query.cs:
[QueryType]
public class Query
{
[GraphQLName("coordinates")]
[GraphQLType<NonNullType<ListType<NonNullType<ListType<NonNullType<ListType<FloatType>>>>>>>]
public double[][][] GetCoordinates()
{
return
[
[
[
10d,
20d
]
]
];
}
}
- Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.AddGraphQL()
.InitializeOnStartup()
.AddPoCTypes();
var app = builder.Build();
app.MapGraphQL("/graphql", schemaName: null);
app.MapGraphQLSchema("/graphql/schema");
app.Run();
- Run project
What is expected?
- Project started successfully
- when you navigate into
/graphql/
-> schema -> SDL you should see schema
type Query {
coordinates: [[[Float!]!]!]!
}
What is actually happening?
Exception is thrown
HotChocolate.SchemaException: For more details look at the `Errors` property.
1. Unable to resolve type reference `ListType<ListType<ListType<FloatType>!>!>!`. (HotChocolate.Types.ObjectType)
at HotChocolate.Configuration.RegisteredType.GetType[T](TypeReference typeRef)
at HotChocolate.Types.OutputFieldBase.OnCompleteField(ITypeCompletionContext context, ITypeSystemMember declaringMember, OutputFieldDefinitionBase definition)
at HotChocolate.Types.OutputFieldBase.OnCompleteField(ITypeCompletionContext context, ITypeSystemMember declaringMember, FieldDefinitionBase definition)
at HotChocolate.Types.FieldBase.CompleteField(ITypeCompletionContext context, ITypeSystemMember declaringMember)
at HotChocolate.Types.FieldBase.HotChocolate.Types.Helpers.IFieldCompletion.CompleteField(ITypeCompletionContext context, ITypeSystemMember declaringMember)
at HotChocolate.Internal.FieldInitHelper.CompleteFieldsInternal[TField](ITypeCompletionContext context, ITypeSystemMember declaringMember, TField[] fields)
at HotChocolate.Internal.FieldInitHelper.CompleteFieldsInternal[TFieldDefinition,TField](ITypeCompletionContext context, ITypeSystemMember declaringMember, IEnumerable`1 fieldDefinitions, Func`3 fieldFactory, Int32 fieldCount)
at HotChocolate.Internal.FieldInitHelper.CompleteFields[TFieldDefinition,TField](ITypeCompletionContext context, ITypeSystemMember declaringMember, IReadOnlyList`1 fieldDefs, Func`3 fieldFactory)
at HotChocolate.Types.ObjectType.OnCompleteFields(ITypeCompletionContext context, ObjectTypeDefinition definition)
at HotChocolate.Types.ObjectType.OnCompleteType(ITypeCompletionContext context, ObjectTypeDefinition definition)
at HotChocolate.Types.TypeSystemObjectBase`1.CompleteType(ITypeCompletionContext context)
at HotChocolate.Configuration.TypeInitializer.CompleteType(RegisteredType registeredType)
at HotChocolate.Configuration.TypeInitializer.<CompleteTypes>b__33_0(RegisteredType type)
at HotChocolate.Configuration.TypeInitializer.ProcessTypes(TypeDependencyFulfilled fulfilled, Func`2 action)
at HotChocolate.Configuration.TypeInitializer.CompleteTypes()
at HotChocolate.Configuration.TypeInitializer.Initialize()
at HotChocolate.SchemaBuilder.Setup.InitializeTypes(SchemaBuilder builder, IDescriptorContext context, IReadOnlyList`1 types)
at HotChocolate.SchemaBuilder.Setup.Create(SchemaBuilder builder, LazySchema lazySchema, IDescriptorContext context)
at HotChocolate.SchemaBuilder.Create(IDescriptorContext context)
at HotChocolate.SchemaBuilder.HotChocolate.ISchemaBuilder.Create(IDescriptorContext context)
at HotChocolate.Execution.RequestExecutorResolver.CreateSchemaAsync(ConfigurationContext context, RequestExecutorSetup setup, RequestExecutorOptions executorOptions, IServiceProvider schemaServices, TypeModuleChangeMonitor typeModuleChangeMonitor, CancellationToken cancellationToken)
at HotChocolate.Execution.RequestExecutorResolver.CreateSchemaServicesAsync(ConfigurationContext context, RequestExecutorSetup setup, TypeModuleChangeMonitor typeModuleChangeMonitor, CancellationToken cancellationToken)
at HotChocolate.Execution.RequestExecutorResolver.CreateRequestExecutorAsync(String schemaName, Boolean isInitialCreation, CancellationToken cancellationToken)
at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorAsync(String schemaName, CancellationToken cancellationToken)
at HotChocolate.Execution.RequestExecutorResolver.<WarmupAsync>g__WarmupSchemaAsync|40_0(String schemaName, CancellationToken cancellationToken)
at HotChocolate.Execution.RequestExecutorResolver.WarmupAsync(CancellationToken cancellationToken)
at HotChocolate.AspNetCore.Warmup.RequestExecutorWarmupService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__14_1(IHostedService service, CancellationToken token)
at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Program.<Main>$(String[] args)
Relevant log output
Additional context
There is a hardcoded limit to how many nested lists HotChocolate allows
if (lists > 2) |
Why do we need triple-nested arrays in the schema:
- to introduce subset of GeoJSON standard into the schema. GeoJSON Polygon coordinates is an array of array of array.
https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6 - HotChocolate.Data.Spatial is overkill since we do not need most of the types provided in the package
Known workaround is to introduce custom scalar that represents float array
"""
Array of floating point numbers
For example: [3.14, 2.7]
"""
scalar Position
type Query {
coordinates: [[Position!]!]!
}
ruslan-monar, zelenskiyMykhailo, kovalenko-Max, PotiraiRostyslav, dmitryspain and 3 more