1. There is no object type implementing interface `IAddress`. (HotChocolate.Types.InterfaceType<Grains.Models.Interfaces.IAddress>)
at HotChocolate.Configuration.TypeInitializer.Initialize(Func`1 schemaResolver, IReadOnlySchemaOptions options)
at HotChocolate.SchemaBuilder.Setup.InitializeTypes(SchemaBuilder builder, DescriptorContext context, IBindingLookup bindingLookup, IReadOnlyList`1 types, LazySchema lazySchema)
at HotChocolate.SchemaBuilder.Setup.Create(SchemaBuilder builder)
at HotChocolate.SchemaBuilder.Create()
at HotChocolate.SchemaBuilder.HotChocolate.ISchemaBuilder.Create()
at HotChocolate.Execution.RequestExecutorResolver.CreateSchemaAsync(NameString schemaName, RequestExecutorSetup options, IServiceProvider serviceProvider, CancellationToken cancellationToken)
at HotChocolate.Execution.RequestExecutorResolver.CreateSchemaServicesAsync(NameString schemaName, RequestExecutorSetup options, CancellationToken cancellationToken)
at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorNoLockAsync(NameString schemaName, CancellationToken cancellationToken)
at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorAsync(NameString schemaName, CancellationToken cancellationToken)
at HotChocolate.Execution.RequestExecutorProxy.GetRequestExecutorAsync(CancellationToken cancellationToken)
at HotChocolate.AspNetCore.HttpPostMiddleware.HandleRequestAsync(HttpContext context, AllowedContentType contentType)
at HotChocolate.AspNetCore.HttpPostMiddleware.InvokeAsync(HttpContext context)
at HotChocolate.AspNetCore.WebSocketSubscriptionMiddleware.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)在使用.Net web api实现graphql服务时,面临上述问题。
public class UserModel
{
public List<IAddress> Addresses { get; set; }
}这是查询
public class Query
{
readonly IUserService _userService = null;
public Query(IUserService userService)
{
_userService = userService;
}
public List<UserModel> Users => _userService.GetUsers();
}这是配置
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddMvc();
_ = services.AddControllers();
_ = services.AddSingleton(CreateClusterClient);
_ = services.AddScoped<IUserService, UserService>();
_ = services.AddScoped<Query>();
_ = services.AddGraphQLServer().AddQueryType<Query>();
_ = services.AddGraphQLServer().AddType<UserType>();
}我正在使用上面的配置,模型,查询和其他东西。
发布于 2021-05-17 21:31:01
您的objectType定义是否实现了该接口?或者对象定义中的返回类型在指定的位置定义为union?
https://stackoverflow.com/questions/67570173
复制相似问题