0

我需要使用First命名类作为 GraphQL 输入类型,所以我创建了FirstInputType类。

我可以映射Name属性,FirstInputType但不能映射MyArray命名的二维数组。我应该如何映射它?

public class First
{
    public string Name {get;set;}
    public Second[][] MyArray {get;set;}
}

public class Second
{
    public string Prop1 {get; set;}
    public int Prop2 {get; set;}
}



public class FirstInputType : InputObjectGraphType<First>
{

    public FirstInputType()
    {
        Field(x => x.Name);

        /*
            In Runtime: System.ArgumentOutOfRangeException: 'Type '...SecondInputType[][]' is not a graph type. (Parameter 'value')'
        */
        Field(x=>x.MyArray, type: typeof(SecondInputType[][]));
    }
}

public class SecondInputType : InputObjectGraphType<Second>
{
    public SecondInputType()
    {
        Field(x => x.Prop1);
        Field(x => x.Prop2);
    }
}
dotnetcore v3.1
GraphQL.Server.Transports.AspNetCore v5.0.2
4

0 回答 0