Skip to content

Commit 0a13288

Browse files
Copilotxperiandri
andauthored
Add documentation for UnsafeRelaxedJsonEscaping usage and SHA256 instance creation
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/ce0fba11-9043-452f-b948-e03c8b644f26 Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent f9206c1 commit 0a13288

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/FSharp.Data.GraphQL.Shared/ValidationResultCache.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module SchemaId =
2121
let private formatByteAsLowerHex (value : byte) =
2222
value.ToString("x2", System.Globalization.CultureInfo.InvariantCulture)
2323

24+
// Note: UnsafeRelaxedJsonEscaping is used here only for deterministic hashing,
25+
// not for output to untrusted contexts. The JSON is never exposed externally.
2426
let private jsonOptions = JsonSerializerOptions(
2527
WriteIndented = false,
2628
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.Never,
@@ -36,6 +38,8 @@ module SchemaId =
3638
let fromIntrospectionSchema (introspectionSchema : IntrospectionSchema) =
3739
let json = JsonSerializer.Serialize(introspectionSchema, jsonOptions)
3840
let jsonBytes = Encoding.UTF8.GetBytes json
41+
// Note: Creating SHA256 instance per call is acceptable since schema ID computation
42+
// happens infrequently (typically once per schema during validation cache key creation)
3943
use sha256 = SHA256.Create()
4044
let hash = sha256.ComputeHash jsonBytes
4145
hash

0 commit comments

Comments
 (0)