ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.14k stars 736 forks source link

Unexpected execution error using Fusion and interface types #7365

Open maartenkools opened 1 month ago

maartenkools commented 1 month ago

Product

Hot Chocolate

Version

13.9.11

Link to minimal reproduction

https://github.com/maartenkools/fusion-bug

Steps to reproduce

Using Fusion, make sure one of the sub graphs implements multiple types based on an interface. When you query those types, and include fields that come from different sub graphs, an error is generated: Unexpected Execution Error. This happens since 13.9.8, while on 13.9.7 it still works.

Also see the projected I've included in the report. It can be tested with the following query:

query Programmes {
    programmes {
        department {
            name
            displayName
        }
        id
        ... on AdministrativeProgramme {
            id
            departmentId
        }
        ... on DegreeProgramme {
            id
            departmentId
        }
    }
}

What is expected?

A result is returned

What is actually happening?

No result is returned, causing an error

Relevant log output

{
    "errors": [
        {
            "message": "Unexpected Execution Error",
            "extensions": {
                "message": "A GraphQL result must have data, errors or both.",
                "stackTrace": "   at HotChocolate.Execution.Processing.ResultBuilder.BuildResult()\r\n   at HotChocolate.Fusion.Execution.Nodes.QueryPlan.ExecuteAsync(FusionExecutionContext context, CancellationToken cancellationToken)\r\n   at HotChocolate.Fusion.Execution.FederatedQueryExecutor.ExecuteAsync(FusionExecutionContext context, CancellationToken cancellationToken)\r\n   at HotChocolate.Fusion.Execution.Pipeline.DistributedOperationExecutionMiddleware.InvokeAsync(IRequestContext context, IBatchDispatcher batchDispatcher)\r\n   at HotChocolate.Execution.Pipeline.OperationVariableCoercionMiddleware.InvokeAsync(IRequestContext context)\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

maartenkools commented 2 weeks ago

I've tested this with HC 14.rc0, and while it no longer produces an unexpected execution error, I do get a different error now:

{
    "errors": [
        {
            "message": "Cannot return null for non-nullable field.",
            "locations": [
                {
                    "line": 5,
                    "column": 13
                }
            ],
            "path": [
                "programmes",
                2,
                "department",
                "displayName"
            ],
            "extensions": {
                "code": "HC0018"
            }
        },
        {
            "message": "Cannot return null for non-nullable field.",
            "locations": [
                {
                    "line": 5,
                    "column": 13
                }
            ],
            "path": [
                "programmes",
                1,
                "department",
                "displayName"
            ],
            "extensions": {
                "code": "HC0018"
            }
        },
        {
            "message": "Cannot return null for non-nullable field.",
            "locations": [
                {
                    "line": 5,
                    "column": 13
                }
            ],
            "path": [
                "programmes",
                0,
                "department",
                "displayName"
            ],
            "extensions": {
                "code": "HC0018"
            }
        }
    ],
    "data": null
}