You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -159,6 +159,18 @@ module SchemaDefinitions =
159
159
|false,_-> None
160
160
| other -> None
161
161
162
+
/// Tries to convert any value to TimeOnly.
163
+
letcoerceTimeOnlyValue(x :obj):TimeOnly option =
164
+
match x with
165
+
|null-> None
166
+
|:? TimeOnly as d -> Some d
167
+
|:? DateTime as d -> Some (TimeOnly.FromDateTime d)
168
+
|:? string as s ->
169
+
match TimeOnly.TryParse(s)with
170
+
|true, time -> Some time
171
+
|false,_-> None
172
+
| other -> None
173
+
162
174
/// Tries to convert any value to Guid.
163
175
letcoerceGuidValue(x :obj):Guid option =
164
176
match x with
@@ -348,6 +360,22 @@ module SchemaDefinitions =
348
360
|false,_-> getParseRangeError(destinationType, DateOnly.MinValue, DateOnly.MaxValue) s
349
361
| InlineConstant value -> value.GetCoerceRangeError(destinationType, DateOnly.MinValue, DateOnly.MaxValue)
350
362
363
+
/// Tries to resolve AST query input to TimeOnly.
364
+
letcoerceTimeOnlyInput=
365
+
letdestinationType="time"
366
+
function
367
+
| Variable e when e.ValueKind = JsonValueKind.String ->
368
+
lets= e.GetString()
369
+
match TimeOnly.TryParse(s)with
370
+
|true, time -> Ok time
371
+
|false,_-> e.GetDeserializeError destinationType
372
+
| Variable e -> e.GetDeserializeError destinationType
373
+
| InlineConstant (StringValue s)->
374
+
match TimeOnly.TryParse(s)with
375
+
|true, time -> Ok time
376
+
|false,_-> getParseRangeError(destinationType, TimeOnly.MinValue, TimeOnly.MaxValue) s
377
+
| InlineConstant value -> value.GetCoerceRangeError(destinationType, TimeOnly.MinValue, TimeOnly.MaxValue)
378
+
351
379
/// Tries to resolve AST query input to Guid.
352
380
letcoerceGuidInput=
353
381
letdestinationType="GUID"
@@ -473,6 +501,15 @@ module SchemaDefinitions =
473
501
CoerceInput = coerceDateOnlyInput
474
502
CoerceOutput = coerceDateOnlyValue }
475
503
504
+
/// GraphQL type for System.TimeOnly
505
+
letTimeOnlyType:ScalarDefinition<TimeOnly>=
506
+
{ Name ="TimeOnly"
507
+
Description =
508
+
Some
509
+
"The `TimeOnly` scalar type represents a Time value without Date component. The `TimeOnly` type appears in a JSON response as a `String` representation of full-time value as specified by [IETF 3339](https://www.ietf.org/rfc/rfc3339.txt)."
510
+
CoerceInput = coerceTimeOnlyInput
511
+
CoerceOutput = coerceTimeOnlyValue }
512
+
476
513
/// GraphQL type for System.Guid
477
514
letGuidType:ScalarDefinition<Guid>=
478
515
{ Name ="Guid"
@@ -759,6 +796,7 @@ module SchemaDefinitions =
759
796
/// </summary>
760
797
/// <param name="name">Type name. Must be unique in scope of the current schema.</param>
761
798
/// <param name="fields">List of input fields defined by the current input object. </param>
Copy file name to clipboardExpand all lines: tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
{
2
-
"documentId": 1481480240,
2
+
"documentId": -128167532,
3
3
"data": {
4
4
"__schema": {
5
5
"queryType": {
@@ -82,6 +82,16 @@
82
82
"enumValues": null,
83
83
"possibleTypes": null
84
84
},
85
+
{
86
+
"kind": "SCALAR",
87
+
"name": "TimeOnly",
88
+
"description": "The `TimeOnly` scalar type represents a Time value without Date component. The `TimeOnly` type appears in a JSON response as a `String` representation of full-time value as specified by [IETF 3339](https://www.ietf.org/rfc/rfc3339.txt).",
Copy file name to clipboardExpand all lines: tests/FSharp.Data.GraphQL.Tests/IntrospectionTests.fs
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -691,6 +691,16 @@ let ``Introspection executes an introspection query`` () =
691
691
"enumValues",null
692
692
"possibleTypes",null
693
693
]
694
+
box <| NameValueLookup.ofList [
695
+
"kind",upcast"SCALAR"
696
+
"name",upcast"TimeOnly"
697
+
"description",upcast"The `TimeOnly` scalar type represents a Time value without Date component. The `TimeOnly` type appears in a JSON response as a `String` representation of full-time value as specified by [IETF 3339](https://www.ietf.org/rfc/rfc3339.txt)."
0 commit comments