-
Notifications
You must be signed in to change notification settings - Fork 75
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 38 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
e05c326
Use deterministic SHA-256 based documentId generation
Copilot e4fcfd3
Update introspection fixture documentId values
Copilot 83c9abb
Address review feedback on deterministic documentId changes
Copilot 30999e3
Document expected deterministic documentId in test
Copilot e1ad222
Clarify hash truncation and expected documentId derivation
Copilot 69a70fa
Refine hash span usage and test value explanation
Copilot 5f18153
Address review feedback on literals and documentId hashing
Copilot 6643d98
Switch documentId to deterministic SHA-256 string
Copilot c0e61ac
Apply follow-up review suggestions
Copilot 48362e8
Fixed ReadMe
xperiandri 5ac9ba6
Use ValidationResultKey directly in cache instead of GetHashCode()
Copilot 7fc28ff
Make SchemaId deterministic using SHA-256 hash of introspection schem…
Copilot 54f138e
Apply code review feedback: use uppercase hex for Unicode escapes and…
Copilot 7b16475
Optimize: cache JsonSerializerOptions and reduce StringBuilder overhead
Copilot d16133f
Minor optimization: avoid sprintf in character loop for better perfor…
Copilot 8399f0d
Fix trailing whitespace in string escaping code
Copilot 18d0715
Ensure deterministic JSON serialization and use lowercase hex for Uni…
Copilot 7d0f33a
Add documentation for UnsafeRelaxedJsonEscaping usage and SHA256 inst…
Copilot fca3129
Optimize SchemaId serialization and improve code formatting
Copilot 98ebcfe
Add comprehensive test coverage for documentId and validation cache
Copilot 568a630
AI review fix
xperiandri 7565c5c
Cache schema ID at Executor level to avoid recomputing on every request
Copilot 7de25ba
Fix schema ID computation to run after middleware compilation
Copilot 42b5487
Add comprehensive test coverage for ToQueryString string escaping
Copilot 6aa547d
Simplify SchemaId generation to use GetHashCode
Copilot 1a94ecc
Clarify SchemaId GetHashCode scope in XML docs
Copilot 66bc73b
Change validation SchemaId type to int
Copilot da4d951
Remove unnecessary SchemaId helper module
Copilot ec333b2
Formatted changed files
xperiandri e926838
Escape U+2028/U+2029 in ToQueryString and add regression tests
Copilot 51b7def
Made `ExecutionTests` asynchronous
xperiandri 01c75cb
Fixed comments
xperiandri a89e07c
Removed unnecessary test
xperiandri f76de93
Make concurrent cache test actually run in parallel
Copilot 76cbccd
Rename worker readiness gate in concurrent cache test
Copilot 31639fc
Fix cross-platform documentId hashing and AstExtensions List.choose
Copilot ce57938
Improved query normalization
xperiandri 398c17a
Simplified cache test
xperiandri 3c0a672
Execution plan cache fix
xperiandri 7371e7d
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) | ||
|
|
||
| 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 "" | ||
|
|
||
|
|
||
|
xperiandri marked this conversation as resolved.
|
||
| /// <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.