【发布时间】:2021-09-29 14:27:54
【问题描述】:
我是 GraphQL 的新手,我已经使用 GraphQL 构建了一个示例项目,该项目运行良好,但 'Documentation Explore'(我的自定义架构)未加载到 Browser .net core 3.1 中也附加了 StartUp.cs。 注意:在 .net core 2.0 中有效。
这里是 startup.cs
using GraphiQl;
using GraphQL;
using GraphQL.Server;
using GraphQL.Types;
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.Configure<IISServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
services.AddSingleton<IDependencyResolver>(c => new FuncDependencyResolver(type => c.GetRequiredService(type)));
services.AddDbContext<RealEstateContext>(options => options.UseSqlServer(Configuration["ConnectionStrings:RealEstateDb"]));
services.AddScoped<IDocumentExecuter, DocumentExecuter>();
services.AddScoped<PropertyQuery>();
services.AddScoped<PropertyMutation>();
services.AddScoped<PropertyType>();
services.AddScoped<ConstituencyType>();
services.AddScoped<PropertyInputType>();
services.AddScoped<PaymentType>();
services.AddGraphQL(options =>
{
options.EnableMetrics = true;
options.ExposeExceptions = true;
}).AddWebSockets();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env,RealEstateContext db)
{
app.UseWebSockets();
app.UseGraphQLWebSockets<RealEstateSchema>("/graphql");
app.UseGraphQL<RealEstateSchema>("/graphql");
db.EnsureSeedData();
}
}
}
【问题讨论】:
标签: graphql .net-core-3.1