diff --git a/Packages.props b/Packages.props index ba114c465..0d1d8dc2c 100644 --- a/Packages.props +++ b/Packages.props @@ -38,6 +38,9 @@ + + + diff --git a/samples/star-wars-api/FSharp.Data.GraphQL.Samples.StarWarsApi.fsproj b/samples/star-wars-api/FSharp.Data.GraphQL.Samples.StarWarsApi.fsproj index 643e4c7c8..e50280407 100644 --- a/samples/star-wars-api/FSharp.Data.GraphQL.Samples.StarWarsApi.fsproj +++ b/samples/star-wars-api/FSharp.Data.GraphQL.Samples.StarWarsApi.fsproj @@ -9,6 +9,9 @@ + + + diff --git a/samples/star-wars-api/Startup.fs b/samples/star-wars-api/Startup.fs index 8c10598a6..8bf111464 100644 --- a/samples/star-wars-api/Startup.fs +++ b/samples/star-wars-api/Startup.fs @@ -1,12 +1,14 @@ namespace FSharp.Data.GraphQL.Samples.StarWarsApi open Microsoft.AspNetCore.Builder +open Microsoft.AspNetCore.Http +open Microsoft.AspNetCore.Server.Kestrel.Core open Microsoft.Extensions.Configuration open Microsoft.Extensions.DependencyInjection -open Giraffe +open Microsoft.Extensions.Hosting open Microsoft.Extensions.Logging +open Giraffe open System -open Microsoft.AspNetCore.Server.Kestrel.Core type Startup private () = new (configuration: IConfiguration) as this = @@ -19,10 +21,17 @@ type Startup private () = .Configure(Action(fun x -> x.AllowSynchronousIO <- true)) |> ignore - member _.Configure(app: IApplicationBuilder) = + member _.Configure(app: IApplicationBuilder, env: IHostEnvironment) = let errorHandler (ex : Exception) (log : ILogger) = log.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.") clearResponse >=> setStatusCode 500 + + if env.IsDevelopment() then + app.UseGraphQLPlayground("/playground") |> ignore + app.UseGraphQLVoyager("/voyager") |> ignore + app.UseRouting() |> ignore + app.UseEndpoints(fun endpoints -> endpoints.MapBananaCakePop(PathString("/cakePop")) |> ignore) |> ignore + app .UseGiraffeErrorHandler(errorHandler) .UseWebSockets()