Skip to content

Commit 661df9a

Browse files
author
Andrii Chebukin
committed
Made schema definition errors module public
1 parent 4d91e81 commit 661df9a

1 file changed

Lines changed: 27 additions & 25 deletions

File tree

‎src/FSharp.Data.GraphQL.Shared/TypeSystem.fs‎

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,42 +2280,44 @@ module Patterns =
22802280
/// Active pattern to match GraphQL type defintion with named types.
22812281
let rec (|Named|_|) (tdef : TypeDef) = named tdef
22822282

2283-
module private Errors =
2283+
[<AutoOpen>]
2284+
module SchemaDefinitions =
22842285

2285-
type InputValue with
2286+
module Errors =
22862287

2287-
member inputValue.GetCoerceError(destinationType) =
2288-
let getMessage inputType value = $"Inline value '{value}' of type %s{inputType} cannot be converted to %s{destinationType}"
2289-
let message =
2290-
match inputValue with
2291-
| IntValue value -> getMessage "integer" value
2292-
| FloatValue value -> getMessage "float" value
2293-
| BooleanValue value -> getMessage "boolean" value
2294-
| StringValue value -> getMessage "string" value
2295-
| NullValue -> $"Inline null value cannot be converted to {destinationType}"
2296-
| EnumValue value -> getMessage "enum" value
2297-
| value -> raise <| NotSupportedException $"{value} cannot be passed as scalar input"
2298-
Error [{ new IGQLError with member _.Message = message }]
2288+
type InputValue with
22992289

2300-
type JsonElement with
2290+
member inputValue.GetCoerceError(destinationType) =
2291+
let getMessage inputType value = $"Inline value '{value}' of type %s{inputType} cannot be converted to %s{destinationType}"
2292+
let message =
2293+
match inputValue with
2294+
| IntValue value -> getMessage "integer" value
2295+
| FloatValue value -> getMessage "float" value
2296+
| BooleanValue value -> getMessage "boolean" value
2297+
| StringValue value -> getMessage "string" value
2298+
| NullValue -> $"Inline null value cannot be converted to {destinationType}"
2299+
| EnumValue value -> getMessage "enum" value
2300+
| value -> raise <| NotSupportedException $"{value} cannot be passed as scalar input"
2301+
Error [{ new IGQLError with member _.Message = message }]
23012302

2302-
member e.GetDeserializeError(destinationType, minValue, maxValue ) =
2303-
Error [{ new IGQLError with member _.Message = $"Cannot deserialize JSON value '{e.GetRawText()}' into %s{destinationType} of range from {minValue} to {maxValue}" }]
2303+
type JsonElement with
23042304

2305-
member e.GetDeserializeError(destinationType) =
2306-
Error [{ new IGQLError with member _.Message = $"Cannot deserialize JSON value '{e.GetRawText()}' into %s{destinationType}" }]
2305+
member e.GetDeserializeError(destinationType, minValue, maxValue ) =
2306+
Error [{ new IGQLError with member _.Message = $"Cannot deserialize JSON value '{e.GetRawText()}' into %s{destinationType} of range from {minValue} to {maxValue}" }]
23072307

2308-
let getParseRangeError (destinationType, minValue, maxValue) value =
2309-
Error [{ new IGQLError with member _.Message = $"Cannot parse '%s{value}' into %s{destinationType} of range from {minValue} to {maxValue}" }]
2308+
member e.GetDeserializeError(destinationType) =
2309+
Error [{ new IGQLError with member _.Message = $"Cannot deserialize JSON value '{e.GetRawText()}' into %s{destinationType}" }]
23102310

2311-
let getParseError destinationType value =
2312-
Error [{ new IGQLError with member _.Message = $"Cannot parse '%s{value}' into %s{destinationType}" }]
2311+
let getParseRangeError (destinationType, minValue, maxValue) value =
2312+
Error [{ new IGQLError with member _.Message = $"Cannot parse '%s{value}' into %s{destinationType} of range from {minValue} to {maxValue}" }]
2313+
2314+
let getParseError destinationType value =
2315+
Error [{ new IGQLError with member _.Message = $"Cannot parse '%s{value}' into %s{destinationType}" }]
23132316

2314-
[<AutoOpen>]
2315-
module SchemaDefinitions =
23162317

23172318
open System.Diagnostics
23182319
open System.Globalization
2320+
open System.Reflection
23192321
open Errors
23202322

23212323
/// Tries to convert any value to int.

0 commit comments

Comments
 (0)