Azure / Azure/data-api-builder

Use of enum type causes schema builder to fail

Open
#748 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cosmos engine graphql known-issue
Dominant language
C#
Stars
1.5k
Forks
372
Avg merge
3d 22h
Merged PRs (30d)
9

Description

If an Object Type is using a GraphQL enum, the schema will fail to build.

Here's an example schema:

enum Foo {
    Bar
}

type Model @model {
    id: String!
    foo: Foo!
}

Here's the error in the console:

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HMK73NKBA43B", Request id "0HMK73NKBA43B:00000027": An unhandled exception was thrown by the application.
      HotChocolate.SchemaException: For more details look at the `Errors` property.
      
      1. Unable to resolve type reference `None: FooOrderByInput`. (HotChocolate.Types.InputObjectType)
      
         at HotChocolate.Configuration.RegisteredType.GetType[T](ITypeReference typeRef)
         at HotChocolate.Types.InputField.OnCompleteField(ITypeCompletionContext context, ITypeSystemMember declaringMember, InputFieldDefinition definition)
         at HotChocolate.Types.FieldBase`1.CompleteField(ITypeCompletionContext context, ITypeSystemMember declaringMember)
         at HotChocolate.Types.FieldBase`1.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.InputObjectType.OnCompleteFields(ITypeCompletionContext context, InputObjectTypeDefinition definition)
         at HotChocolate.Types.InputObjectType.OnCompleteType(ITypeCompletionContext context, InputObjectTypeDefinition definition)
         at HotChocolate.Types.TypeSystemObjectBase`1.CompleteType(ITypeCompletionContext context)
         at HotChocolate.Configuration.TypeInitializer.<CompleteTypes>g__CompleteType|27_0(RegisteredType registeredType)
         at HotChocolate.Configuration.TypeInitializer.ProcessTypes(TypeDependencyKind kind, 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, 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 Azure.DataApiBuilder.Service.AuthenticationHelpers.AuthenticationMiddleware.InvokeAsync(HttpContext httpContext) in /home/vsts/work/1/s/src/Service/AuthenticationHelpers/AuthenticationMiddleware.cs:line 87
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Azure.DataApiBuilder.Service.Startup.<>c__DisplayClass8_0.<<Configure>b__2>d.MoveNext() in /home/vsts/work/1/s/src/Service/Startup.cs:line 280
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the GraphQL schema shown in the issue and inspect the schema builder path around the unresolved FooOrderByInput type. No source or test file is named; done means the schema builds successfully when an object type uses a GraphQL enum, with coverage for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, graphql
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.