diff --git a/src/FSharp.Data.GraphQL.Client/BaseTypes.fs b/src/FSharp.Data.GraphQL.Client/BaseTypes.fs index 4011a78a7..141d12219 100644 --- a/src/FSharp.Data.GraphQL.Client/BaseTypes.fs +++ b/src/FSharp.Data.GraphQL.Client/BaseTypes.fs @@ -348,7 +348,7 @@ module internal JsonValueHelper = | Some "Date" -> match DateTime.TryParse(s, CultureInfo.InvariantCulture, DateTimeStyles.None) with | (true, d) -> box d - | _ -> failwith "A string was received in the query response, and the schema recognizes it as a date and time sring, but the conversion failed." + | _ -> failwith "A string was received in the query response, and the schema recognizes it as a date and time string, but the conversion failed." | Some _ -> box s | _ -> failwith "A string type was received in the query response item, but the matching schema field is not a string based type." @@ -357,14 +357,16 @@ module internal JsonValueHelper = | None -> failwith "Item type is a non null type, but no underlying type exists on the schema definition of the type." | TypeKind.SCALAR -> match schemaField.SchemaTypeRef.Name with + | Some "String" | Some "ID" -> + s |> makeSomeIfNeeded | Some "URI" -> - System.Uri(s) |> makeSomeIfNeeded + s |> System.Uri |> makeSomeIfNeeded | Some "Date" -> match DateTime.TryParse(s, CultureInfo.InvariantCulture, DateTimeStyles.None) with | (true, d) -> makeSomeIfNeeded d - | _ -> failwith "A string was received in the query response, and the schema recognizes it as a date and time sring, but the conversion failed." + | _ -> failwith "A string was received in the query response, and the schema recognizes it as a date and time string, but the conversion failed." | Some _ -> - makeSomeIfNeeded s + s |> makeSomeIfNeeded | _ -> failwith "A string type was received in the query response item, but the matching schema field is not a string based type." | TypeKind.ENUM when schemaField.SchemaTypeRef.Name.IsSome -> EnumBase(schemaField.SchemaTypeRef.Name.Value, s) |> makeSomeIfNeeded | _ -> failwith "A string type was received in the query response item, but the matching schema field is not a string based type or an enum type." diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests.Server/Schema.fs b/tests/FSharp.Data.GraphQL.IntegrationTests.Server/Schema.fs index 64a698b81..772b93fec 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests.Server/Schema.fs +++ b/tests/FSharp.Data.GraphQL.IntegrationTests.Server/Schema.fs @@ -20,7 +20,8 @@ type InputField = StringOption : string option IntOption : int option Uri : System.Uri - Guid : System.Guid } + Guid : System.Guid + GuidOption : System.Guid option } type Input = { Single : InputField option @@ -74,6 +75,10 @@ module Schema = Define.AutoField("intOption", Nullable IntType, description = "An integer option value.") Define.AutoField("uri", UriType, description = "An URI value.") Define.AutoField("guid", GuidType, description = "A Guid value.") + Define.Field("guidId", IDType, description = "A Guid Id value.", resolve = fun _ o -> o.Guid |> string) + Define.Field("stringId", IDType, description = "A String Id value.", resolve = fun _ o -> o.String) + Define.Field("guidIdOption", Nullable IDType, description = "A Guid Id value.", resolve = fun _ o -> o.GuidOption |> Option.map string) + Define.Field("stringIdOption", Nullable IDType, description = "A String Id value.", resolve = fun _ o -> o.StringOption) Define.Field("deprecated", StringType, resolve = (fun _ x -> x.String), description = "A string value through a deprecated field.", deprecationReason = "This field is deprecated.", args = []) ]) let UploadedFileType =