Skip to content

Commit 5ee1581

Browse files
Added Voyager, Playground and Banana Cake Pop to StarWars sample project (#421)
1 parent bd8fa09 commit 5ee1581

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Packages.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
<PackageReference Update="EntityFramework" Version="1.*" />
3939
<PackageReference Update="FSharp.Data.TypeProviders" Version="1.*" />
4040
<PackageReference Update="Giraffe" Version="6.*" />
41+
<PackageReference Update="GraphQL.Server.Ui.Playground" Version="7.1.*" />
42+
<PackageReference Update="GraphQL.Server.Ui.Voyager" Version="7.1.*" />
43+
<PackageReference Update="HotChocolate.AspNetCore" Version="12.16.*" />
4144
<PackageReference Update="Iced" Version="1.17.*" />
4245
<PackageReference Update="Microsoft.CodeCoverage" Version="17.3.*" />
4346
<PackageReference Update="Microsoft.Diagnostics.NETCore.Client" Version="0.2.*" />

samples/star-wars-api/FSharp.Data.GraphQL.Samples.StarWarsApi.fsproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<ItemGroup>
1010
<PackageReference Include="Giraffe" />
1111
<PackageReference Include="Newtonsoft.Json" />
12+
<PackageReference Include="GraphQL.Server.Ui.Playground" />
13+
<PackageReference Include="GraphQL.Server.Ui.Voyager" />
14+
<PackageReference Include="HotChocolate.AspNetCore" />
1215
</ItemGroup>
1316

1417
<ItemGroup>

samples/star-wars-api/Startup.fs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
namespace FSharp.Data.GraphQL.Samples.StarWarsApi
22

33
open Microsoft.AspNetCore.Builder
4+
open Microsoft.AspNetCore.Http
5+
open Microsoft.AspNetCore.Server.Kestrel.Core
46
open Microsoft.Extensions.Configuration
57
open Microsoft.Extensions.DependencyInjection
6-
open Giraffe
8+
open Microsoft.Extensions.Hosting
79
open Microsoft.Extensions.Logging
10+
open Giraffe
811
open System
9-
open Microsoft.AspNetCore.Server.Kestrel.Core
1012

1113
type Startup private () =
1214
new (configuration: IConfiguration) as this =
@@ -19,10 +21,17 @@ type Startup private () =
1921
.Configure(Action<IISServerOptions>(fun x -> x.AllowSynchronousIO <- true))
2022
|> ignore
2123

22-
member _.Configure(app: IApplicationBuilder) =
24+
member _.Configure(app: IApplicationBuilder, env: IHostEnvironment) =
2325
let errorHandler (ex : Exception) (log : ILogger) =
2426
log.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.")
2527
clearResponse >=> setStatusCode 500
28+
29+
if env.IsDevelopment() then
30+
app.UseGraphQLPlayground("/playground") |> ignore
31+
app.UseGraphQLVoyager("/voyager") |> ignore
32+
app.UseRouting() |> ignore
33+
app.UseEndpoints(fun endpoints -> endpoints.MapBananaCakePop(PathString("/cakePop")) |> ignore) |> ignore
34+
2635
app
2736
.UseGiraffeErrorHandler(errorHandler)
2837
.UseWebSockets()

0 commit comments

Comments
 (0)