graphql-platform
graphql-platform copied to clipboard
Class/Record requires some primitive field to be sortable
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
It seems that if there is a record/class in the type hierarchy, that only contains non-primitive properties like again records or classes, schema creation fails with the following error:
HotChocolate.SchemaException: For more details look at the Errors` property.
-
InputObject
ContractSelectionSortInputhas no fields declared. (HotChocolate.Data.Sorting.SortInputType<Likron.NavigatorBFF.Models.Contracts.ContractSelection>)at HotChocolate.Configuration.TypeInitializer.EnsureNoErrors() at HotChocolate.Configuration.TypeInitializer.CompleteTypes() at HotChocolate.Configuration.TypeInitializer.Initialize() at HotChocolate.SchemaBuilder.Setup.InitializeTypes(SchemaBuilder builder, IDescriptorContext context, IReadOnlyList
1 types, LazySchema lazySchema) 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(NameString schemaName, RequestExecutorSetup options, RequestExecutorOptions executorOptions, IServiceProvider serviceProvider, TypeModuleChangeMonitor typeModuleChangeMonitor, CancellationToken cancellationToken) at HotChocolate.Execution.RequestExecutorResolver.CreateSchemaServicesAsync(NameString schemaName, RequestExecutorSetup options, CancellationToken cancellationToken) at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorNoLockAsync(NameString schemaName, CancellationToken cancellationToken) at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorAsync(NameString schemaName, CancellationToken cancellationToken) at HotChocolate.Execution.RequestExecutorProxy.GetRequestExecutorAsync(CancellationToken cancellationToken) at HotChocolate.AspNetCore.HttpPostMiddlewareBase.HandleRequestAsync(HttpContext context, AllowedContentType contentType) at HotChocolate.AspNetCore.HttpPostMiddlewareBase.InvokeAsync(HttpContext context) at Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.<>c__DisplayClass13_0.<<UseCancellation>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application)`
I will try to investigate this and create an example or unit test that narrows this down.
Steps to reproduce
- record A(B b, C, c); record B() record C()
Relevant log output
No response
Additional Context?
No response
Product
Hot Chocolate
Version
12.0.7
Here is a demo project to reproduce the issue:
https://github.com/ChilliCream/hotchocolate/tree/tsi/empty-record-as-input
At src/Demo
@tsinghammer the problem with this demo is the mutation type. It builds without issue.
I think the sorting issue you describe happens when you do this
public record Foo(Bar bar, String SomeOtherField);
public record Bar(IEnumerable<Baz> baz)
public record Baz(string Qux)
sorting discovers the Foo type and then the Bar type. But it cannot find any fields on the Bar type that are sortable, as you cannot sort on lists. Then it explodes.
You can work around this issue by defining a custom SortInputType<Foo> and ingore the field Bar
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.