-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathIO.fs
More file actions
85 lines (76 loc) · 3.56 KB
/
Copy pathIO.fs
File metadata and controls
85 lines (76 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
namespace FSharp.Data.GraphQL
open System
open System.Collections.Generic
open System.Text.Json.Serialization
open FSharp.Data.GraphQL
open FSharp.Data.GraphQL.Extensions
open FSharp.Data.GraphQL.Types
type Output = IDictionary<string, obj>
type GQLResponse =
{ DocumentId: int
Data : Output Skippable
Errors : GQLProblemDetails list Skippable }
static member Direct(documentId, data, errors) =
{ DocumentId = documentId
Data = Include data
Errors = Skippable.ofList errors }
static member Stream(documentId) =
{ DocumentId = documentId
Data = Include null
Errors = Skip }
static member RequestError(documentId, errors) =
{ DocumentId = documentId
Data = Skip
Errors = Include errors }
type GQLExecutionResult =
{ DocumentId: int
Content : GQLResponseContent
Metadata : Metadata }
static member Direct(documentId, data, errors, meta) =
{ DocumentId = documentId
Content = Direct (data, errors)
Metadata = meta }
static member Deferred(documentId, data, errors, deferred, meta) =
{ DocumentId = documentId
Content = Deferred (data, errors, deferred)
Metadata = meta }
static member Stream(documentId, data, meta) =
{ DocumentId = documentId
Content = Stream data
Metadata = meta }
static member RequestError(documentId, errors, meta) =
{ DocumentId = documentId
Content = RequestError errors
Metadata = meta }
static member Empty(documentId, meta) =
GQLExecutionResult.Direct(documentId, Map.empty, [], meta)
static member Error(documentId, errors, meta) =
GQLExecutionResult.RequestError(documentId, errors, meta)
static member Error(documentId, error, meta) =
GQLExecutionResult.RequestError(documentId, [ error ], meta)
static member Error(documentId, error, meta) =
GQLExecutionResult.RequestError(documentId, [ GQLProblemDetails.OfError error ], meta)
static member Error(documentId, errors, meta) =
GQLExecutionResult.RequestError(documentId, errors |> List.map GQLProblemDetails.OfError, meta)
static member Error(documentId, msg, meta) =
GQLExecutionResult.RequestError(documentId, [ GQLProblemDetails.Create msg ], meta)
static member ErrorFromException(documentId : int, ex : Exception, meta : Metadata) =
GQLExecutionResult.RequestError(documentId, [ GQLProblemDetails.Create (ex.Message, ex) ], meta)
static member Invalid(documentId, errors, meta) =
GQLExecutionResult.RequestError(documentId, errors, meta)
static member ErrorAsync(documentId, msg : string, meta) =
AsyncVal.wrap (GQLExecutionResult.Error (documentId, msg, meta))
static member ErrorAsync(documentId, error : IGQLError, meta) =
AsyncVal.wrap (GQLExecutionResult.Error (documentId, error, meta))
// TODO: Rename to PascalCase
and GQLResponseContent =
| RequestError of Errors: GQLProblemDetails list
| Direct of Data : Output * Errors: GQLProblemDetails list
| Deferred of Data : Output * Errors : GQLProblemDetails list * Defer : IObservable<GQLDeferredResponseContent>
| Stream of Stream : IObservable<GQLSubscriptionResponseContent>
and GQLDeferredResponseContent =
| DeferredResult of Data : obj * Path : FieldPath
| DeferredErrors of Data : obj * Errors: GQLProblemDetails list * Path : FieldPath
and GQLSubscriptionResponseContent =
| SubscriptionResult of Data : Output
| SubscriptionErrors of Data : Output * Errors: GQLProblemDetails list