小编Har*_*ryM的帖子

GraphQL .NET - 架构加载时出现 AutoRegisteringObjectGraphType 错误:无法注册 GraphType

我有一个 CustomerDetails 类:

public record CustomerDetails{
      public string? Code { get; init; }
      public string? Name { get; init; }
      public string? Notes { get; init; }
}
Run Code Online (Sandbox Code Playgroud)

在 GraphQL 方面,我有以下内容:

在查询方面:

public class CustomerDetailsGraphType : AutoRegisteringObjectGraphType<CustomerDetails> { }
Run Code Online (Sandbox Code Playgroud)

在突变方面:

public class CustomerDetailsInputGraphType : AutoRegisteringInputObjectGraphType<CustomerDetails> {}
Run Code Online (Sandbox Code Playgroud)

当我运行此命令并尝试在 Altair 中查看架构时,它给出了以下类型的错误:

 "message": "GraphQL.Execution.UnhandledError: Error executing document.\r\n ---> System.InvalidOperationException: Unable to register GraphType 'MyProject.Customers.Mutations.ContactDetailsInputGraphType' with the name 'ContactDetails';\nthe name 'ContactDetails' is already registered to 'MyProject.Customers.Query.ContactDetailsGraphType'.\r\n..."
Run Code Online (Sandbox Code Playgroud)

我不明白为什么会这样?

.net c# graphql

4
推荐指数
1
解决办法
1327
查看次数

标签 统计

.net ×1

c# ×1

graphql ×1