Just by reading the title you would wonder what I’m talking about. HotChocolate is a GraphQL server implementation for .NET. And Banana Cake Pop is a GraphQL IDE (similar to Graphiql and GraphQL Playground) by the same authors.
When you include the HotChocolate NuGet package(HotChocolate.AspNetCore) in your ASP.NET Core application, Banana Cake Pop is installed and activated automatically.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using HotChocolate.AspNetCore; | |
var builder = WebApplication.CreateBuilder(args); | |
var app = builder.Build(); | |
//Activates both a GraphQL endpoint and the GraphQL IDE | |
app.MapGraphQL(); | |
app.Run(); |
When you browse to the GraphQL endpoint (by default ‘/graphql’) using a browser Banana Cake Pop will be loaded:
This is something that is really helpful during development but maybe not something you want in production.
To disable Banana Cake Pop outside development you can configure this through the GraphQLServerOptions
:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using HotChocolate.AspNetCore; | |
var builder = WebApplication.CreateBuilder(args); | |
var app = builder.Build(); | |
app.MapGraphQL().WithOptions(new GraphQLServerOptions() | |
{ | |
//Disable GraphQL IDE outside dev | |
Tool = { Enable = app.Environment.IsDevelopment() } | |
}); | |
app.Run(); |