Skip to content

Commit

Permalink
Fixed coerceUriInput definition to use the common error creation
Browse files Browse the repository at this point in the history
  • Loading branch information
xperiandri committed Oct 19, 2023
1 parent 01ced21 commit 955ec87
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,18 @@ module SchemaDefinitions =

/// Tries to resolve AST query input to URI.
let coerceUriInput =
let destinationType = "URI"
function
| Variable e when e.ValueKind = JsonValueKind.String ->
match Uri.TryCreate(e.GetString(), UriKind.RelativeOrAbsolute) with
| true, uri -> Ok uri
| false, _ -> Error [{ new IGQLError with member _.Message = $"Cannot deserialize '{e.GetRawText()}' into URI" }]
| Variable e -> e.GetDeserializeError "URI"
| false, _ -> e.GetDeserializeError destinationType
| Variable e -> e.GetDeserializeError destinationType
| InlineConstant (StringValue s) ->
match Uri.TryCreate(s, UriKind.RelativeOrAbsolute) with
| true, uri -> Ok uri
| false, _ -> Error [{ new IGQLError with member _.Message = $"Cannot parse '{s}' into URI" }]
| InlineConstant value -> value.GetCoerceError "URI"
| false, _ -> getParseError destinationType s
| InlineConstant value -> value.GetCoerceError destinationType

/// Tries to resolve AST query input to DateTimeOffset.
let coerceDateTimeOffsetInput =
Expand Down

0 comments on commit 955ec87

Please sign in to comment.