-
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
2e4a740
Use deterministic SHA-256 based documentId generation
Copilot 2512443
Update introspection fixture documentId values
Copilot 66bb9fe
Address review feedback on deterministic documentId changes
Copilot 1535070
Document expected deterministic documentId in test
Copilot 2f6317c
Clarify hash truncation and expected documentId derivation
Copilot ab4f703
Refine hash span usage and test value explanation
Copilot 4a1c125
Address review feedback on literals and documentId hashing
Copilot bef0a93
Switch documentId to deterministic SHA-256 string
Copilot 7a41e71
Apply follow-up review suggestions
Copilot 547b790
Fixed ReadMe
xperiandri c729a3d
Use ValidationResultKey directly in cache instead of GetHashCode()
Copilot 355d611
Make SchemaId deterministic using SHA-256 hash of introspection schem…
Copilot 86faa93
Apply code review feedback: use uppercase hex for Unicode escapes and…
Copilot 93db5f8
Optimize: cache JsonSerializerOptions and reduce StringBuilder overhead
Copilot cdee804
Minor optimization: avoid sprintf in character loop for better perfor…
Copilot cba2e8e
Fix trailing whitespace in string escaping code
Copilot b5c10b2
Ensure deterministic JSON serialization and use lowercase hex for Uni…
Copilot 68aed4c
Add documentation for UnsafeRelaxedJsonEscaping usage and SHA256 inst…
Copilot c8a86a1
Optimize SchemaId serialization and improve code formatting
Copilot a7a7e98
Add comprehensive test coverage for documentId and validation cache
Copilot c12bac6
AI review fix
xperiandri a3e7da4
Cache schema ID at Executor level to avoid recomputing on every request
Copilot 2c575af
Fix schema ID computation to run after middleware compilation
Copilot 9b17899
Add comprehensive test coverage for ToQueryString string escaping
Copilot df453d3
Simplify SchemaId generation to use GetHashCode
Copilot 5a79527
Clarify SchemaId GetHashCode scope in XML docs
Copilot 4388510
Change validation SchemaId type to int
Copilot fd2f69a
Remove unnecessary SchemaId helper module
Copilot d819ed2
Formatted changed files
xperiandri bb491fe
Escape U+2028/U+2029 in ToQueryString and add regression tests
Copilot fa8cf55
Made `ExecutionTests` asynchronous
xperiandri 5f9a11b
Fixed comments
xperiandri 5ac58e1
Removed unnecessary test
xperiandri 4645c8e
Make concurrent cache test actually run in parallel
Copilot d024f22
Rename worker readiness gate in concurrent cache test
Copilot 2f7f0e5
Fix cross-platform documentId hashing and AstExtensions List.choose
Copilot 8d87662
Improved query normalization
xperiandri b30c765
Simplified cache test
xperiandri 09e6f86
Execution plan cache fix
xperiandri a343179
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.