Product
Hot Chocolate
Version
14.2.0
Link to minimal reproduction
https://github.com/scottstubbs/HotChocolate-Fusion-Hide-Mutations
Steps to reproduce
To run the solution:
- Run
dotnet tool restore
- Build
HotChocolate-Fusion-Mutations.sln
- Run all projects (Gateway, Owners and Cars) in the solution
- Open
https://localhost:50000/graphql in a browser
- Create a new document in Nitro
At this point the introspection fails.
To make changes to the subgraphs, rebuild the gateway from the root directory:
- Run
./Fuse.ps1 to pack and compose all projects OR
- Run
./Fuse.ps1 -Project {ProjectFolder} to pack and compose a specific project
What is expected?
Introspection should succeed. The Mutation type should be gone from the supergraph schema.
What is actually happening?
Introspection fails and the error is logged to the Nitro console and the Visual Studio Output window.
Relevant log output
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:50000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\users\sstubbs\source\repos\ReadOnly\Gateway
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
HotChocolate.SchemaException: For more details look at the `Errors` property.
1. The object type `Mutation` has to at least define one field in order to be valid. (HotChocolate.Types.ObjectType)
at HotChocolate.SchemaBuilder.Setup.CompleteSchema(SchemaBuilder builder, IDescriptorContext context, LazySchema lazySchema, TypeRegistry typeRegistry)
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.HttpGetSchemaMiddleware.HandleRequestAsync(HttpContext context)
at HotChocolate.AspNetCore.HttpGetSchemaMiddleware.InvokeAsync(HttpContext context)
at HotChocolate.AspNetCore.HttpGetMiddleware.InvokeAsync(HttpContext context)
at HotChocolate.AspNetCore.HttpMultipartMiddleware.InvokeAsync(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.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Additional context
This happens because all subgraph mutations were marked with the [Internal] attribute. The fusion compose command doesn't remove the empty Mutation type from the supergraph schema. The same result happens when using the [Tag(name: "internal")] attribute.
Product
Hot Chocolate
Version
14.2.0
Link to minimal reproduction
https://github.com/scottstubbs/HotChocolate-Fusion-Hide-Mutations
Steps to reproduce
To run the solution:
dotnet tool restoreHotChocolate-Fusion-Mutations.slnhttps://localhost:50000/graphqlin a browserAt this point the introspection fails.
To make changes to the subgraphs, rebuild the gateway from the root directory:
./Fuse.ps1to pack and compose all projects OR./Fuse.ps1 -Project {ProjectFolder}to pack and compose a specific projectWhat is expected?
Introspection should succeed. The Mutation type should be gone from the supergraph schema.
What is actually happening?
Introspection fails and the error is logged to the Nitro console and the Visual Studio Output window.
Relevant log output
info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:50000 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: C:\users\sstubbs\source\repos\ReadOnly\Gateway fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. HotChocolate.SchemaException: For more details look at the `Errors` property. 1. The object type `Mutation` has to at least define one field in order to be valid. (HotChocolate.Types.ObjectType) at HotChocolate.SchemaBuilder.Setup.CompleteSchema(SchemaBuilder builder, IDescriptorContext context, LazySchema lazySchema, TypeRegistry typeRegistry) 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.HttpGetSchemaMiddleware.HandleRequestAsync(HttpContext context) at HotChocolate.AspNetCore.HttpGetSchemaMiddleware.InvokeAsync(HttpContext context) at HotChocolate.AspNetCore.HttpGetMiddleware.InvokeAsync(HttpContext context) at HotChocolate.AspNetCore.HttpMultipartMiddleware.InvokeAsync(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.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)Additional context
This happens because all subgraph mutations were marked with the
[Internal]attribute. Thefusion composecommand doesn't remove the emptyMutationtype from the supergraph schema. The same result happens when using the[Tag(name: "internal")]attribute.