ChilliCream / ChilliCream/graphql-platform

Removing all mutations from subgraphs doesn't remove the Mutation type from the supergraph schema

Open
#7,813 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ hot chocolate Area: Fusion
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

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:

  1. Run dotnet tool restore
  2. Build HotChocolate-Fusion-Mutations.sln
  3. Run all projects (Gateway, Owners and Cars) in the solution
  4. Open https://localhost:50000/graphql in a browser
  5. 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.

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 with the linked minimal reproduction: restore its dotnet tools, build HotChocolate-Fusion-Mutations.sln, and compose the gateway with Fuse.ps1. Check the fusion compose output and the gateway schema during Nitro introspection; done means introspection succeeds and the empty Mutation type is absent from the supergraph.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.