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.27k stars 748 forks source link

Unable to add custom middleware for mutations. #5497

Closed jeremyraadttwins closed 2 years ago

jeremyraadttwins commented 2 years ago

Is there an existing issue for this?

Describe the bug

When I add custom middleware to mutations I get an error block with the message "The type HotChocolate.Execution.Processing.ResultMapList is not supported as list value." and the extension code "EXEC_LIST_TYPE_NOT_SUPPORTED".

Steps to reproduce

Here is my basic test case. The middleware does nothing, but I still get the "EXEC_LIST_TYPE_NOT_SUPPORTED" error.

Mutation.cs:

    [ExtendObjectType(OperationTypeNames.Mutation)]
    public class CarMutations
    {
        [UseMyThing]
        public Car AddCar(
            AddCarInput input)
        {
            // save car into database.
        }
    }

Client Query:

  addCar(input: {
    make: "Ford"
  }) {
    car {
      make
    }
  }
}

Middleware:

    public class UseMyThingMiddleware
    {
        private readonly FieldDelegate _next;

        public UseMyThingMiddleware(FieldDelegate next)
        {
            _next = next;
        }

        public async Task InvokeAsync(IMiddlewareContext context)
        {
            await _next(context);
        }
    }

Relevant log output

No response

Additional Context?

No response

Product

Hot Chocolate

Version

12.15.0

jeremyraadttwins commented 2 years ago

I figured out my issue. In my UseMyThingAttribute class I had descriptor.Type<ListType<ObjectType<Look>>>(); when I needed descriptor.Type<ObjectType<Look>>();. I was using the same middleware for returning a list of cars and a single car.