Skip to content
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

Fix the query hashing algorithm #6205

Merged
merged 106 commits into from
Nov 29, 2024
Merged

Fix the query hashing algorithm #6205

merged 106 commits into from
Nov 29, 2024

Conversation

Geal
Copy link
Contributor

@Geal Geal commented Oct 29, 2024

This splits part of the work from #5255 to make it easier to merge. This PR only covers the fixes for the query hashing algorithm, which is currently used in entity caching, without integrating the changes to the query planner cache key.


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@Geal
Copy link
Contributor Author

Geal commented Nov 5, 2024

@IvanGoncharov I added the initial support for the context directives. I will take another look tomorrow, but I think the approach is sound:

  • as we go through the query, whenever we encounter a @context directive, we record the type in a map context name -> [Type}
  • when we encounter a field with the join__field directive and its contextArguments argument, then for each argument, we take the context name and selection
  • we look up the types linked to that context name. Considering the way we go through the query and relevant types, it might return types that would not appear in this query, so it might be a bit stricter than necessary
  • for each of those type, we then use the selection and hash that in the same way we handle @key and @requires

There are some assumptions in there that we might want to check, like what happens when a contextArgument refers to a context that we did not find in the query (maybe that would have been prevented at composition?)

@bnjjj bnjjj requested a review from IvanGoncharov November 18, 2024 15:38
@IvanGoncharov IvanGoncharov self-assigned this Nov 26, 2024
@IvanGoncharov IvanGoncharov marked this pull request as draft November 26, 2024 19:41
@IvanGoncharov
Copy link
Member

Converting to draft as result of internal discussion regarding the risks introduced by parent PR, see details in #5255

@IvanGoncharov IvanGoncharov marked this pull request as ready for review November 27, 2024 15:28
@IvanGoncharov IvanGoncharov merged commit c5e1246 into dev Nov 29, 2024
14 checks passed
@IvanGoncharov IvanGoncharov deleted the geal/fix-query-hashing branch November 29, 2024 16:32
IvanGoncharov added a commit that referenced this pull request Nov 30, 2024
`dev` wasn't merge in #6205 before it was squashed and committed.
Because of that `dev` had some changes in tests that didn't change hash produced by old query hash agorithm but resulted in a hash change once #6205 was merged.
Example: #6310 Added test changes related to @context and #6205 added a special case to handle @context directives
SimonSapin added a commit that referenced this pull request Dec 6, 2024
* `main` has commit 043e62c "Miscellaneous @context/@fromcontext bugfixes (#6380)"
* `dev` has commit 92e6847 "tests: Fix snapshots after #6205 was merged (#6367)"
@BrynCooke BrynCooke mentioned this pull request Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants