You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the FieldBindingFlags.Default with mutation conventions, error types do not function as expected, despite having object types defined for the exceptions and or errors being thrown.
If exceptions or object types are properly defined and expose the message field, a SchemaException should not occur.
What is actually happening?
It consistently throws a SchemaException, indicating that the exception does not expose a message property.
Relevant log output
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HN3Q8NUENKE7", Request id "0HN3Q8NUENKE7:00000001": An unhandled exception was thrown by the application.
HotChocolate.SchemaException: For more details look at the `Errors` property.
1. For more details look at the `Errors` property.
1. Error while building type HotChocolate.Types.ErrorObjectType`1[[HC_7111.GraphQL.DomainError, HC_7111, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]. The runtime type HC_7111.GraphQL.DomainError does not define a property named `Message` (HotChocolate.Types.ErrorObjectType<HC_7111.GraphQL.DomainError>) at HotChocolate.Configuration.TypeInitializer.DiscoverTypes() 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, CancellationToken cancellationToken) at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorNoLockAsync(String schemaName, CancellationToken cancellationToken) at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorAsync(String schemaName, CancellationToken cancellationToken) at HotChocolate.Execution.RequestExecutorProxy.GetRequestExecutorAsync(CancellationToken cancellationToken) at HotChocolate.AspNetCore.HttpPostMiddlewareBase.HandleRequestAsync(HttpContext context) at HotChocolate.AspNetCore.HttpPostMiddlewareBase.InvokeAsync(HttpContext context) at Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.<>c__DisplayClass23_0.<<UseCancellation>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
Additional context
No response
The text was updated successfully, but these errors were encountered:
This is actually not a bug ... what we do internally is register an error type for mutation convention errors ... this is the ErrorObjectType that you can see.
@michaelstaib, thanks for the follow up. You're right when using the code below, it internally registers an error type for the mutation conventions and does not raise any SchemaException.
[MutationType]publicclassLibraryMutation{[Error<DomainException>]publicLibrary?LibraryCreate(stringname){thrownew DomainException("bad");}}publicclassDomainException(string type):Exception{publicstringMessage=>"a domain exception was thrown...";publicstringType{get;}= type;}
The issue that now arises is that I am unable to configure which fields I want to expose to the GraphQL layer (or I might be doing it incorrectly). Without configuring the object type extension, it only exposes the Message field, which is expected since it's required for mutation conventions. However, in this case, I also want to expose the DomainException.Type property, which I cannot seem to achieve.
Introducing the following object type configuration does not resolve the issue, as only the Message field continues to be exposed in the schema:
How can I configure these additional fields on the exceptions so that they are exposed in the GraphQL layer, while still using FieldBindingFlags.Default?
Product
Hot Chocolate
Version
14.0.0-p.100
Link to minimal reproduction
https://github.com/PHILLIPS71/HC-7111
Steps to reproduce
When using the
FieldBindingFlags.Default
with mutation conventions, error types do not function as expected, despite having object types defined for the exceptions and or errors being thrown.What is expected?
If exceptions or object types are properly defined and expose the message field, a
SchemaException
should not occur.What is actually happening?
It consistently throws a
SchemaException
, indicating that the exception does not expose a message property.Relevant log output
Additional context
No response
The text was updated successfully, but these errors were encountered: