graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Class/Record requires some primitive field to be sortable

Open tsinghammer opened this issue 3 years ago • 3 comments

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.

  1. InputObject ContractSelectionSortInput has 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, IReadOnlyList1 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

  1. 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

tsinghammer avatar Apr 25 '22 13:04 tsinghammer

Here is a demo project to reproduce the issue:

https://github.com/ChilliCream/hotchocolate/tree/tsi/empty-record-as-input

At src/Demo

tsinghammer avatar Apr 25 '22 19:04 tsinghammer

@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

PascalSenn avatar Apr 26 '22 07:04 PascalSenn

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.

stale[bot] avatar Sep 09 '22 03:09 stale[bot]