File tree Expand file tree Collapse file tree
src/FSharp.Data.GraphQL.Shared Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,16 +108,18 @@ type Document with
108108 let escaped = StringBuilder( s.Length + 2 )
109109 escaped.Append( '"' ) |> ignore
110110 for c in s do
111- match c with
112- | '"' -> escaped.Append( " \\\" " ) |> ignore
113- | '\\' -> escaped.Append( " \\\\ " ) |> ignore
114- | '\b' -> escaped.Append( " \\ b" ) |> ignore
115- | '\f' -> escaped.Append( " \\ f" ) |> ignore
116- | '\n' -> escaped.Append( " \\ n" ) |> ignore
117- | '\r' -> escaped.Append( " \\ r" ) |> ignore
118- | '\t' -> escaped.Append( " \\ t" ) |> ignore
119- | c when c < '\u0020' -> escaped.AppendFormat( " \\ u{0:X4}" , int c) |> ignore
120- | c -> escaped.Append( c) |> ignore
111+ let appendStr =
112+ match c with
113+ | '"' -> " \\\" "
114+ | '\\' -> " \\\\ "
115+ | '\b' -> " \\ b"
116+ | '\f' -> " \\ f"
117+ | '\n' -> " \\ n"
118+ | '\r' -> " \\ r"
119+ | '\t' -> " \\ t"
120+ | c when c < '\u0020' -> sprintf " \\ u%04X " ( int c)
121+ | c -> string c
122+ escaped.Append( appendStr) |> ignore
121123 escaped.Append( '"' ) .ToString()
122124 let withQuotes = escapeGraphQLString
123125 let rec printValue x =
Original file line number Diff line number Diff line change @@ -21,17 +21,18 @@ module SchemaId =
2121 let private formatByteAsLowerHex ( value : byte ) =
2222 value.ToString( " x2" , System.Globalization.CultureInfo.InvariantCulture)
2323
24+ let private jsonOptions = JsonSerializerOptions(
25+ WriteIndented = false ,
26+ DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.Never
27+ )
28+
2429 /// <summary >
2530 /// Computes a deterministic schema identifier from an introspection schema.
2631 /// </summary >
2732 /// <param name =" introspectionSchema " >The introspection schema to hash.</param >
2833 /// <returns >A lowercase hexadecimal SHA-256 hash string that uniquely identifies the schema structure.</returns >
2934 let fromIntrospectionSchema ( introspectionSchema : IntrospectionSchema ) =
30- let options = JsonSerializerOptions(
31- WriteIndented = false ,
32- DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.Never
33- )
34- let json = JsonSerializer.Serialize( introspectionSchema, options)
35+ let json = JsonSerializer.Serialize( introspectionSchema, jsonOptions)
3536 let jsonBytes = Encoding.UTF8.GetBytes json
3637 use sha256 = SHA256.Create()
3738 let hash = sha256.ComputeHash jsonBytes
You can’t perform that action at this time.
0 commit comments