I am new to GraphQL, when I try to upgrade .net core version from 2.2 to 3.0
I got problem about UI display on /graphql page when using UseGraphiQl
API is working normally but the UI is display incorrect. I googled for find out solutions, but nothing really helpful.
Here is my config for graphql:
services.AddRazorPages().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
app.UseGraphiQLServer(new GraphiQLOptions());
app.UseGraphiQl("/graphiql", "/graphql");
app.UseEndpoints(x =>
{
x.MapControllers();
});
Any help is greatly appreciated, thanks.
Finally, I find out the solution:
services.AddRazorPages().AddNewtonsoftJson();
As part of the work to improve the ASP.NET Core shared framework, Json.NET has been removed from the ASP.NET Core shared framework.
To use Json.NET in an ASP.NET Core 3.0 project:
Add a package reference to Microsoft.AspNetCore.Mvc.NewtonsoftJson.
Update Startup.ConfigureServices to call AddNewtonsoftJson.