Skip to content

Instantly share code, notes, and snippets.

@xperiandri
Last active December 4, 2020 23:25
Show Gist options
  • Save xperiandri/c24c17c1570866ac8aba34bd63d2572e to your computer and use it in GitHub Desktop.
Save xperiandri/c24c17c1570866ac8aba34bd63d2572e to your computer and use it in GitHub Desktop.
let handleRequest (serviceProvider : IServiceProvider) (requestBodyStream : Stream) = async {
...
try
...
let! result =
match request with
| ValueSome (query, ValueSome variables) ->
async {
let query = removeWhitespacesAndLineBreaks query
let root = serviceProvider.GetRequiredService<Root>()
let! result = Schema.executor.AsyncExecute (query, root, variables)
return result
}
| ValueSome (query, ValueNone) ->
async {
let query = removeWhitespacesAndLineBreaks query
let root = serviceProvider.GetRequiredService<Root>()
let! result = Schema.executor.AsyncExecute(query, root)
return result
}
| ValueNone ->
Schema.executor.AsyncExecute(Introspection.IntrospectionQuery)
return result
with | ex ->
log.LogError ("Exception! {message}", ex.Message)
let result = GQLResponse.Error (ex.Message, Metadata.Empty)
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment