-
Notifications
You must be signed in to change notification settings - Fork 74
Make documentId deterministic SHA-256 string and keep schemaId as in-memory int cache key
#575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
40
commits into
dev
Choose a base branch
from
copilot/fix-documentid-issue
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
f640cdd
Use deterministic SHA-256 based documentId generation
Copilot 2a8e1f9
Update introspection fixture documentId values
Copilot 74d522b
Address review feedback on deterministic documentId changes
Copilot bc5e2c4
Document expected deterministic documentId in test
Copilot bc49f5d
Clarify hash truncation and expected documentId derivation
Copilot 7266a62
Refine hash span usage and test value explanation
Copilot a9de885
Address review feedback on literals and documentId hashing
Copilot e9281f7
Switch documentId to deterministic SHA-256 string
Copilot 892130c
Apply follow-up review suggestions
Copilot 77f42d0
Fixed ReadMe
xperiandri 85cc833
Use ValidationResultKey directly in cache instead of GetHashCode()
Copilot 12845a6
Make SchemaId deterministic using SHA-256 hash of introspection schem…
Copilot 72a71df
Apply code review feedback: use uppercase hex for Unicode escapes and…
Copilot 4566f37
Optimize: cache JsonSerializerOptions and reduce StringBuilder overhead
Copilot f092046
Minor optimization: avoid sprintf in character loop for better perfor…
Copilot 29a7eb4
Fix trailing whitespace in string escaping code
Copilot 632c8c9
Ensure deterministic JSON serialization and use lowercase hex for Uni…
Copilot aaf216e
Add documentation for UnsafeRelaxedJsonEscaping usage and SHA256 inst…
Copilot 7de7fbf
Optimize SchemaId serialization and improve code formatting
Copilot 06212d5
Add comprehensive test coverage for documentId and validation cache
Copilot 5962d18
AI review fix
xperiandri 6da8d6d
Cache schema ID at Executor level to avoid recomputing on every request
Copilot e726cff
Fix schema ID computation to run after middleware compilation
Copilot 4921bf2
Add comprehensive test coverage for ToQueryString string escaping
Copilot b9e55fa
Simplify SchemaId generation to use GetHashCode
Copilot 3db55a2
Clarify SchemaId GetHashCode scope in XML docs
Copilot a7de093
Change validation SchemaId type to int
Copilot c5fbaf8
Remove unnecessary SchemaId helper module
Copilot a963959
Formatted changed files
xperiandri 73f394f
Escape U+2028/U+2029 in ToQueryString and add regression tests
Copilot 3a85fd8
Made `ExecutionTests` asynchronous
xperiandri de8621b
Fixed comments
xperiandri 1b33a38
Removed unnecessary test
xperiandri c3eb6a9
Make concurrent cache test actually run in parallel
Copilot 71891c1
Rename worker readiness gate in concurrent cache test
Copilot 6a1e518
Fix cross-platform documentId hashing and AstExtensions List.choose
Copilot 08d0f90
Improved query normalization
xperiandri 30bdf0c
Simplified cache test
xperiandri e3dc5c4
Execution plan cache fix
xperiandri 5393fd9
Fix escaped-string documentId test to execute valid argument path
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| module FSharp.Data.GraphQL.DocumentId | ||
|
|
||
| open System.Globalization | ||
| open System.Runtime.CompilerServices | ||
| open System.Security.Cryptography | ||
| open System.Text | ||
|
|
||
| let private formatByteAsLowerHex (value : byte) = value.ToString ("x2", CultureInfo.InvariantCulture) | ||
|
|
||
|
xperiandri marked this conversation as resolved.
|
||
| let internal fromCanonicalQueryUnsafe (canonicalQuery : string) = | ||
| let queryBytes = Encoding.UTF8.GetBytes canonicalQuery | ||
| use sha256 = SHA256.Create () | ||
| let hash = sha256.ComputeHash queryBytes | ||
| hash |> Seq.map formatByteAsLowerHex |> String.concat "" | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// Computes a deterministic document identifier from a canonical GraphQL query string. | ||
| /// </summary> | ||
| /// <param name="canonicalQuery">The canonical GraphQL query string (must already be properly escaped according to GraphQL specification).</param> | ||
| /// <returns>A lowercase hexadecimal SHA-256 hash string that uniquely identifies the document content.</returns> | ||
| [<CompiledName("FromCanonicalQuery")>] | ||
| let fromCanonicalQuery (canonicalQuery : string) = | ||
| let normalizedCanonicalQuery = | ||
| let crIndex = canonicalQuery.IndexOf '\r' | ||
| if crIndex < 0 then | ||
| canonicalQuery | ||
| else | ||
| let sb = StringBuilder (canonicalQuery.Length) | ||
| sb.Append (canonicalQuery, 0, crIndex) |> ignore | ||
| let mutable i = crIndex | ||
| while i < canonicalQuery.Length do | ||
| let c = canonicalQuery[i] | ||
| if c = '\r' then | ||
| sb.Append '\n' |> ignore | ||
| if i + 1 < canonicalQuery.Length && canonicalQuery[i + 1] = '\n' then | ||
| i <- i + 2 | ||
| else | ||
| i <- i + 1 | ||
| else | ||
| sb.Append c |> ignore | ||
| i <- i + 1 | ||
| sb.ToString () | ||
| fromCanonicalQueryUnsafe normalizedCanonicalQuery | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
xperiandri marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.