.Net Framework Web 中的 Graphiql playground API

Graphiql playground in a .Net Framework Web API

我们如何在 ASP.NET 框架 Web 应用程序中实现 Graphql 游乐场?我能够使用 Postman 的新 GraphQL POST 进行查询,并且它按预期工作。但是我无法使用 HotChocolate 的 AspNet Classic GraphiQL nuget 托管 graphiql 游乐场。

https://www.nuget.org/packages/HotChocolate.AspNetClassic.GraphiQL/

如果有人能提供特定于 ASP.NET 框架的代码片段或文档,那将非常有帮助。

您所要做的就是将其添加到您的 startup.cs 文件中:

 //Graph QL add to pipeline and use schemas
 // app.UseWebSockets()
    app.UseGraphQL("/graphql")
       .UsePlayground();

如果需要,您也可以自动启动它。每次点击调试时,如果您在项目属性中设置 url

,它就会打开 playground