Skip to content

Fusion tries to resolve data from subgraph without top-level resolverย #6727

@interad-woergoetter

Description

@interad-woergoetter

Is there an existing issue for this?

  • I have searched the existing issues

Product

Hot Chocolate

Describe the bug

Fusion will try to resolve data from the first subgraph that has all (or the most of) the requested data in its schema, regardless of whether that subgraph has a top-level resolver for the type in question.
This leads to an error during execution plan creation.

It appears that the query plan generator iterates over all subgraphs in order, i.e. alphabetically, meaning the names of the subgraphs impact the reproducability of this issue.

Steps to reproduce

  1. Set up a Fusion gateway server with the attached gateway package.
    gateway.fgp.zip
  2. Start the gateway server.
  3. Send the query query { foos { id name nameReversed } } to the gateway.
  4. Confirm that the gateway is able to create a query plan fetching additional data from Subgraph3.
  5. Now send the query query { foos { id name } } to the gateway.
  6. Notice that the gateway is not able to create a query plan.

Relevant log output

{
  "errors": [
    {
      "message": "Unexpected Execution Error",
      "extensions": {
        "message": "There must be a field resolver definition in this context!",
        "stackTrace": "   at HotChocolate.Fusion.Planning.Pipeline.ExecutionStepDiscoveryMiddleware.CreateExecutionSteps(QueryPlanContext context, Queue`1 backlog, ObjectTypeMetadata selectionSetTypeMetadata, IReadOnlyList`1 selections, ISelection parentSelection, SelectionPath parentSelectionPath, Boolean preferBatching)\r\n   at HotChocolate.Fusion.Planning.Pipeline.ExecutionStepDiscoveryMiddleware.Invoke(QueryPlanContext context, QueryPlanDelegate next)\r\n   at HotChocolate.Fusion.Planning.QueryPlanPipelineBuilder.<>c__DisplayClass5_1`1.<Use>b__1(QueryPlanContext context)\r\n   at HotChocolate.Fusion.Planning.QueryPlanner.Plan(IOperation operation)\r\n   at HotChocolate.Fusion.Execution.Pipeline.OperationQueryPlanCompiler.OptimizeOperation(OperationOptimizerContext context)\r\n   at HotChocolate.Execution.Processing.OperationCompiler.CreateOperation(String operationId, OperationDefinitionNode operationDefinition, ObjectType operationType, DocumentNode document, ISchema schema)\r\n   at HotChocolate.Execution.Processing.OperationCompiler.Compile(String operationId, OperationDefinitionNode operationDefinition, ObjectType operationType, DocumentNode document, ISchema schema, IReadOnlyList`1 optimizers, Boolean enableNullBubbling)\r\n   at HotChocolate.Execution.Pipeline.OperationResolverMiddleware.CompileOperation(IRequestContext context, String operationId, OperationDefinitionNode operationDefinition, ObjectType operationType)\r\n   at HotChocolate.Execution.Pipeline.OperationResolverMiddleware.InvokeAsync(IRequestContext context)\r\n   at HotChocolate.Execution.Pipeline.OperationComplexityMiddleware.InvokeAsync(IRequestContext context)\r\n   at HotChocolate.Execution.Pipeline.OperationCacheMiddleware.InvokeAsync(IRequestContext context)\r\n   at HotChocolate.Execution.Pipeline.DocumentValidationMiddleware.InvokeAsync(IRequestContext context)\r\n   at HotChocolate.Execution.Pipeline.DocumentParserMiddleware.InvokeAsync(IRequestContext context)\r\n   at HotChocolate.Execution.Pipeline.DocumentCacheMiddleware.InvokeAsync(IRequestContext context)\r\n   at HotChocolate.Execution.Pipeline.TimeoutMiddleware.InvokeAsync(IRequestContext context)\r\n   at HotChocolate.Execution.Pipeline.ExceptionMiddleware.InvokeAsync(IRequestContext context)"
      }
    }
  ]
}

Additional Context?

No response

Version

13.7.0

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions