【发布时间】:2021-08-20 17:08:05
【问题描述】:
我是 .NET 核心的 GraphQL 新手。 我在源代码中添加了 GraphQL,但在调试时未添加到控制器中。它去了我的 ObjectGrapType 查看图片详情:
- 在 GrapiQL 中单击开始 enter image description here
- 然后它不去控制器 enter image description here 3.进入订单查询 enter image description here
我不明白为什么会这样
你能不能帮我检查一下。 这是一个错误吗? 我的创业班:
public void ConfigureServices(IServiceCollection services)
{
services.AddDiscoveryClient(Configuration);
services.AddCustomDbContext(Configuration);
services.AddControllers()
.AddNewtonsoftJson(o => o.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
services.AddMediatR(typeof(Startup).GetTypeInfo().Assembly);
services.AddCustomSwagger();
services.AddCustomDependency(Configuration);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseDiscoveryClient();
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
app.UseGraphiQl("/graphql");
app.UseRouting();
app.UseAuthorization();
app.UseGraphQL<OrderQuerySchema>();
app.UseGraphQLPlayground(options: new GraphQLPlaygroundOptions());
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
非常感谢,祝你有美好的一天
LamNV
【问题讨论】:
标签: c# asp.net-core controller graphql