没有可用的架构 graphql asp net core
no schema available graphiql aspnet core
我的存储库位于 https://github.com/nmarun/customergraph。当我 运行 应用程序时,我在文档资源管理器中看不到任何架构。我在查看“网络”选项卡时看到 404。
我认为我需要配置 GraphiQl 以调用 /graphql 端点来检索模式详细信息,并且出于某种原因,我的 HTTP POST 操作方法没有在 /graph 端点被命中。
当我到达终点时,通过邮递员的所有呼叫都工作正常:http://localhost:54068/graphql
请协助。
using CustomerGraph.Models.Schema;
using CustomerGraph.Models.Services;
using GraphiQl;
using GraphQL;
using GraphQL.Server;
using GraphQL.Types;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace CustomerGraph
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddScoped<IDocumentExecuter, DocumentExecuter>();
services.AddSingleton<ICustomerService, CustomerService>();
services.AddSingleton<CustomerType>();
services.AddSingleton<AddressType>();
services.AddSingleton<ContactType>();
services.AddSingleton<ContactMethodType>();
services.AddSingleton<CustomersQuery>();
services.AddSingleton<CustomerSchema>();
services.AddSingleton<IDependencyResolver>(
c => new FuncDependencyResolver(type => c.GetRequiredService(type)));
services.AddGraphQL(_ =>
{
_.EnableMetrics = true;
_.ExposeExceptions = true;
});
var sp = services.BuildServiceProvider();
services.AddSingleton<ISchema>(new CustomerSchema(new FuncDependencyResolver(type => sp.GetService(type))));
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseGraphiQl("/graphiql");
app.UseGraphQL<ISchema>("/graphql");
app.UseGraphQLWebSockets<CustomerSchema>("/graphql");
app.UseWebSockets();
app.UseHttpsRedirection();
app.UseMvc();
}
}
}
谢谢,
A运行
这是由 UseGraphIQL 方法引起的,它假定 graphql 端点与 GraphQL 在同一位置 api。
通过替换以下内容来修复它:
app.UseGraphiQl("/graphiql");
//app.UseGraphQL<CustomerSchema>("/graph");
//app.UseGraphQLWebSockets<CustomerSchema>("/graphql");
//app.UseWebSockets();
app.UseHttpsRedirection();
app.UseMvc();
作者:
app.UseGraphiQl("/graphiql", "/graphql");
app.UseGraphQL<CustomerSchema>("/graphql");
app.UseGraphQLWebSockets<CustomerSchema>("/graphql");
app.UseWebSockets();
app.UseHttpsRedirection();
app.UseMvc();
我的存储库位于 https://github.com/nmarun/customergraph。当我 运行 应用程序时,我在文档资源管理器中看不到任何架构。我在查看“网络”选项卡时看到 404。
我认为我需要配置 GraphiQl 以调用 /graphql 端点来检索模式详细信息,并且出于某种原因,我的 HTTP POST 操作方法没有在 /graph 端点被命中。
当我到达终点时,通过邮递员的所有呼叫都工作正常:http://localhost:54068/graphql
请协助。
using CustomerGraph.Models.Schema;
using CustomerGraph.Models.Services;
using GraphiQl;
using GraphQL;
using GraphQL.Server;
using GraphQL.Types;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace CustomerGraph
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddScoped<IDocumentExecuter, DocumentExecuter>();
services.AddSingleton<ICustomerService, CustomerService>();
services.AddSingleton<CustomerType>();
services.AddSingleton<AddressType>();
services.AddSingleton<ContactType>();
services.AddSingleton<ContactMethodType>();
services.AddSingleton<CustomersQuery>();
services.AddSingleton<CustomerSchema>();
services.AddSingleton<IDependencyResolver>(
c => new FuncDependencyResolver(type => c.GetRequiredService(type)));
services.AddGraphQL(_ =>
{
_.EnableMetrics = true;
_.ExposeExceptions = true;
});
var sp = services.BuildServiceProvider();
services.AddSingleton<ISchema>(new CustomerSchema(new FuncDependencyResolver(type => sp.GetService(type))));
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseGraphiQl("/graphiql");
app.UseGraphQL<ISchema>("/graphql");
app.UseGraphQLWebSockets<CustomerSchema>("/graphql");
app.UseWebSockets();
app.UseHttpsRedirection();
app.UseMvc();
}
}
}
谢谢, A运行
这是由 UseGraphIQL 方法引起的,它假定 graphql 端点与 GraphQL 在同一位置 api。
通过替换以下内容来修复它:
app.UseGraphiQl("/graphiql");
//app.UseGraphQL<CustomerSchema>("/graph");
//app.UseGraphQLWebSockets<CustomerSchema>("/graphql");
//app.UseWebSockets();
app.UseHttpsRedirection();
app.UseMvc();
作者:
app.UseGraphiQl("/graphiql", "/graphql");
app.UseGraphQL<CustomerSchema>("/graphql");
app.UseGraphQLWebSockets<CustomerSchema>("/graphql");
app.UseWebSockets();
app.UseHttpsRedirection();
app.UseMvc();