diff --git a/Packages.props b/Packages.props
index 6ab045fc..ba48ae2c 100644
--- a/Packages.props
+++ b/Packages.props
@@ -31,6 +31,7 @@
+
diff --git a/src/FSharp.Data.GraphQL.Client/Extensions.fs b/src/FSharp.Data.GraphQL.Client/Extensions.fs
index 794118f6..7b5178c6 100644
--- a/src/FSharp.Data.GraphQL.Client/Extensions.fs
+++ b/src/FSharp.Data.GraphQL.Client/Extensions.fs
@@ -11,14 +11,15 @@ open System.Security.Cryptography
/// Extensions for types used by the GraphQL client library.
[]
module internal Extensions =
+
+ let private changeFirstChar mapping (s : string) =
+ let span = s.AsSpan()
+ let c = mapping span[0]
+ if c = span[0] then s else string c + span.Slice(1).ToString()
+
type String with
/// Returns the input string with the first character in upper case.
- member this.FirstCharUpper() =
- this.Substring(0, 1).ToUpperInvariant() + this.Substring(1)
-
- /// Returns the input string with the first character in lower case.
- member this.FirstCharLower() =
- this.Substring(0, 1).ToLowerInvariant() + this.Substring(1)
+ member this.FirstCharUpper () = changeFirstChar Char.ToUpperInvariant this
member this.MD5Hash() =
Encoding.UTF8.GetBytes(this)
diff --git a/src/FSharp.Data.GraphQL.Client/FSharp.Data.GraphQL.Client.fsproj b/src/FSharp.Data.GraphQL.Client/FSharp.Data.GraphQL.Client.fsproj
index 46901b93..6a8bae93 100644
--- a/src/FSharp.Data.GraphQL.Client/FSharp.Data.GraphQL.Client.fsproj
+++ b/src/FSharp.Data.GraphQL.Client/FSharp.Data.GraphQL.Client.fsproj
@@ -69,6 +69,8 @@
runtime
+
+
diff --git a/src/FSharp.Data.GraphQL.Client/GraphQLClient.fs b/src/FSharp.Data.GraphQL.Client/GraphQLClient.fs
index 6a757fc2..7888edab 100644
--- a/src/FSharp.Data.GraphQL.Client/GraphQLClient.fs
+++ b/src/FSharp.Data.GraphQL.Client/GraphQLClient.fs
@@ -8,6 +8,7 @@ open System.Collections.Generic
open System.Collections.Immutable
open System.Net.Http
open System.Text
+open System.Text.Json
open System.Threading
open System.Threading.Tasks
@@ -131,7 +132,7 @@ module GraphQLClient =
| :? IDictionary as x ->
x
|> Seq.collect (fun kvp ->
- tryMapFileVariable (name + "." + (kvp.Key.FirstCharLower ()), kvp.Value)
+ tryMapFileVariable (name + "." + JsonNamingPolicy.CamelCase.ConvertName kvp.Key, kvp.Value)
|> Option.defaultValue [||])
|> Array.ofSeq
|> Some
diff --git a/src/FSharp.Data.GraphQL.Client/Serialization.fs b/src/FSharp.Data.GraphQL.Client/Serialization.fs
index 6572c1aa..68e03648 100644
--- a/src/FSharp.Data.GraphQL.Client/Serialization.fs
+++ b/src/FSharp.Data.GraphQL.Client/Serialization.fs
@@ -8,6 +8,7 @@ open System.Collections.Generic
open System.Diagnostics
open System.Globalization
open System.Reflection
+open System.Text.Json
open Microsoft.FSharp.Reflection
open FSharp.Data.GraphQL
open FSharp.Data.GraphQL.Client.ReflectionPatterns
@@ -176,7 +177,7 @@ module Serialization =
| :? Upload as u -> JsonValue.String u.Name
| :? IDictionary as items ->
items
- |> Seq.map (fun (KeyValue (k, v)) -> k.FirstCharLower(), toJsonValue v)
+ |> Seq.map (fun (KeyValue (k, v)) -> JsonNamingPolicy.CamelCase.ConvertName k, toJsonValue v)
|> Seq.toArray
|> JsonValue.Record
| EnumerableValue items ->
@@ -187,7 +188,7 @@ module Serialization =
| EnumValue x -> JsonValue.String x
| _ ->
let props = t.GetProperties(BindingFlags.Public ||| BindingFlags.Instance)
- let items = props |> Array.map (fun p -> (p.Name.FirstCharLower(), p.GetValue(x) |> toJsonValue))
+ let items = props |> Array.map (fun p -> (JsonNamingPolicy.CamelCase.ConvertName p.Name, p.GetValue(x) |> toJsonValue))
JsonValue.Record items)
let serializeRecord (x : obj) =