Skip to content

Commit aa84865

Browse files
Copilotxperiandri
andauthored
Address review feedback on deterministic documentId changes
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/020d0296-28b1-416d-bd12-9dd0790516ba Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent e94d15f commit aa84865

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

src/FSharp.Data.GraphQL.Server/Executor.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ type Executor<'Root>(schema: ISchema<'Root>, middlewares : IExecutorMiddleware s
8282

8383
let middlewaresList = Seq.toList middlewares
8484

85+
/// Generates a deterministic document identifier from the canonical query string.
8586
let getDocumentId (document : Document) =
8687
let canonicalQuery = document.ToQueryString()
8788
let queryBytes = Encoding.UTF8.GetBytes canonicalQuery

tests/FSharp.Data.GraphQL.Tests/ExecutionTests.fs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ module FSharp.Data.GraphQL.Tests.ExecutionTests
55

66
open Xunit
77
open System
8-
open System.Buffers.Binary
9-
open System.Security.Cryptography
10-
open System.Text
118
open System.Text.Json
129
open System.Text.Json.Serialization
1310
open System.Collections.Immutable
@@ -20,7 +17,6 @@ open FSharp.Data.GraphQL.Shared
2017
open FSharp.Data.GraphQL.Types
2118
open FSharp.Data.GraphQL.Parser
2219
open FSharp.Data.GraphQL.Execution
23-
open FSharp.Data.GraphQL.Ast.Extensions
2420

2521
type TestSubject = {
2622
a: string
@@ -388,12 +384,7 @@ let ``Execution when querying returns unique document id with response`` () =
388384
Define.Field("b", IntType, fun _ x -> x.B)
389385
]))
390386
let query = "query Example { a, b, a }"
391-
let expectedDocumentId =
392-
let canonicalQuery =
393-
let ast = parse query
394-
ast.ToQueryString()
395-
let hash = SHA256.HashData(Encoding.UTF8.GetBytes canonicalQuery)
396-
BinaryPrimitives.ReadInt32BigEndian(ReadOnlySpan<byte>(hash, 0, 4))
387+
let expectedDocumentId = -2063861555
397388
let result1 = sync <| Executor(schema).AsyncExecute(query, getMockInputContext, { A = "aa"; B = 2 })
398389
let result2 = sync <| Executor(schema).AsyncExecute(query, getMockInputContext, { A = "aa"; B = 2 })
399390
result1.DocumentId |> notEquals Unchecked.defaultof<int>

0 commit comments

Comments
 (0)