Skip to content

Multiple Errors on Mutation caused an error to fetch schema #8586

@tessierp

Description

@tessierp

Product

Hot Chocolate

Version

16

Link to minimal reproduction

I do not have any reproduction URL

Steps to reproduce

Hi,

Not sure if I'm doing something wrong but, following the documentation which specifies that we can handle more than one error on a mutation, I have tried this

[MutationType]
public class ManufacturerMutation
{
    private readonly IManufacturerDal  _manufacturerDal;
    
    public ManufacturerMutation(IManufacturerDal manufacturerDal)
    {
        _manufacturerDal = manufacturerDal;
    }

    [Error(typeof(ManufacturerErrorFactory))]
    public async Task<ManufacturerDto?> AddManufacturer(ManufacturerInput input)
    {
        return await _manufacturerDal.AddManufacturerAsync(input);
    }
}

public static class ManufacturerErrorFactory
{
    public static ManufacturerValidationExceptionError CreateErrorFrom(ValidationException ex)
    {
        return ManufacturerValidationExceptionError.CreateErrorFrom(ex);
    }
    
    public static ManufacturerDbExceptionError CreateErrorFrom(DbException ex)
    {
        return ManufacturerDbExceptionError.CreateErrorFrom(ex);
    }
}

public class ManufacturerDbExceptionError
{
    public DbException Exception { get; }
    public string? Message { get; }
    
    private ManufacturerDbExceptionError(DbException dbEx, string? message = null)
    {
        Exception = dbEx;
        Message = message;
    }
    
    public static ManufacturerDbExceptionError CreateErrorFrom(DbException ex)
    {
        return new ManufacturerDbExceptionError(ex, ex.Message);
    }
}

public class ManufacturerValidationExceptionError
{
    public ValidationException Exception { get; }
    public string? Message { get; }
    
    private ManufacturerValidationExceptionError(ValidationException ex, string? message = null)
    {
        Exception = ex;
        Message = message;
    }

    public static ManufacturerValidationExceptionError CreateErrorFrom(ValidationException ex)
    {
        return new ManufacturerValidationExceptionError(ex, ex.Message);
    }
}

Which gives me the following error

Image

According to the documentation for V16 this should work.. Is there anything I'm missing??

What is expected?

I should be getting a valid schema

What is actually happening?

Schema generation fails and get an error.

Relevant log output

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions