Skip to content

Added Voyager, Playground and Banana Cake Pop to StarWars sample project #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<PackageReference Update="EntityFramework" Version="1.*" />
<PackageReference Update="FSharp.Data.TypeProviders" Version="1.*" />
<PackageReference Update="Giraffe" Version="6.*" />
<PackageReference Update="GraphQL.Server.Ui.Playground" Version="7.1.*" />
<PackageReference Update="GraphQL.Server.Ui.Voyager" Version="7.1.*" />
<PackageReference Update="HotChocolate.AspNetCore" Version="12.16.*" />
<PackageReference Update="Iced" Version="1.17.*" />
<PackageReference Update="Microsoft.CodeCoverage" Version="17.3.*" />
<PackageReference Update="Microsoft.Diagnostics.NETCore.Client" Version="0.2.*" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<ItemGroup>
<PackageReference Include="Giraffe" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="GraphQL.Server.Ui.Playground" />
<PackageReference Include="GraphQL.Server.Ui.Voyager" />
<PackageReference Include="HotChocolate.AspNetCore" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 12 additions & 3 deletions samples/star-wars-api/Startup.fs
Original file line number Diff line number Diff line change
@@ -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 =
Expand All @@ -19,10 +21,17 @@ type Startup private () =
.Configure(Action<IISServerOptions>(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()
Expand Down