11namespace FSharp.Data.GraphQL.Samples.StarWarsApi
22
33open System
4+ open System.Threading .Tasks
45open Microsoft.AspNetCore .Builder
56open Microsoft.AspNetCore .Http
67open Microsoft.Extensions .Configuration
78open Microsoft.Extensions .DependencyInjection
89open Microsoft.Extensions .Logging
910open Microsoft.Extensions .Hosting
10- open Giraffe
11+ open Oxpecker
1112open FSharp.Data .GraphQL .Server .AspNetCore
12- open FSharp.Data .GraphQL .Server .AspNetCore .Giraffe
13+ open FSharp.Data .GraphQL .Server .AspNetCore .Oxpecker
1314
1415type Startup private () =
1516
@@ -25,20 +26,13 @@ type Startup private () =
2526 Startup ()
2627 then this.Configuration <- configuration
2728
28- member _.ConfigureServices ( services : IServiceCollection ) =
29+ member _.ConfigureServices ( services : IServiceCollection ) : unit =
2930 services
30- .AddGiraffe ()
31+ .AddOxpecker ()
3132 .AddGraphQL< Root> ( Schema.executor, rootFactory, configure = configure)
3233 |> ignore
3334
34- member _.Configure
35- (
36- app : IApplicationBuilder ,
37- env : IHostEnvironment
38- ) =
39- let errorHandler ( ex : Exception ) ( log : ILogger ) =
40- log.LogError ( EventId (), ex, " An unhandled exception has occurred while executing the request." )
41- clearResponse >=> setStatusCode 500
35+ member _.Configure ( app : IApplicationBuilder , env : IHostEnvironment ) : unit =
4236
4337 if env.IsDevelopment () then
4438 app.UseGraphQLAltair " /altair" |> ignore
@@ -50,15 +44,19 @@ type Startup private () =
5044 |> ignore
5145
5246 app
53- .UseGiraffeErrorHandler( errorHandler)
47+ //.UseGiraffeErrorHandler(errorHandler)
48+ .UseRouting()
5449 .UseWebSockets()
5550 .UseWebSocketsForGraphQL< Root>()
56- .UseGiraffe (
57- // Set CORS to allow external servers (React samples) to call this API
58- setHttpHeader " Access-Control-Allow-Origin" " *"
59- >=> setHttpHeader " Access-Control-Allow-Headers" " content-type"
60- >=> ( setHttpHeader " Request-Type" " Classic" ) // For integration testing purposes
61- >=> HttpHandlers.graphQL< Root>
62- )
51+ .UseEndpoints ( fun endpoints ->
52+ // Simple declaration
53+ //endpoints.MapOxpeckerEndpoint (HttpEndpoints.graphQL<Root>("/", id))
54+ let handler =
55+ setHttpHeader " Access-Control-Allow-Origin" " *"
56+ >=> setHttpHeader " Access-Control-Allow-Headers" " content-type"
57+ >=> ( setHttpHeader " Request-Type" " Classic" ) // For integration testing purposes
58+ >=> HttpEndpointHandlers.graphQL< Root>
59+ endpoints.MapOxpeckerEndpoint ( route " /" handler))
60+ |> ignore
6361
6462 member val Configuration : IConfiguration = null with get, set
0 commit comments