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

feat(graphql): Support custom equality function for cache comparison #1431

Merged

Conversation

kvenn
Copy link
Contributor

@kvenn kvenn commented May 15, 2024

Summary

  • The current equality check has received some dissatisfaction due to performance (and is a source of jank/missed frames in my application)
  • This is an unopinionated way to allow those consumers to provide their own equality function with better performance

Details

@vincenzopalazzo
Copy link
Collaborator

LGTM, I am wondering if you can work around about the test failure?

--------------------------------------------------------------------------------
example:
Formatted 3 files (0 changed) in 0.20 seconds.
Analyzing ....
No issues found!
example: SUCCESS
--------------------------------------------------------------------------------
graphql:
Formatted 55 files (0 changed) in 0.66 seconds.
Analyzing ....

   info - lib/src/cache/fragment.dart:8:8 - The import of 'package:gql_exec/gql_exec.dart' is unnecessary because all of the used elements are also provided by the import of 'package:graphql/client.dart'. Try removing the import directive. - unnecessary_import

1 issue found.

It is just a make fmt iirc

@kvenn kvenn marked this pull request as ready for review June 1, 2024 16:43
@kvenn
Copy link
Contributor Author

kvenn commented Jun 1, 2024

Got it! Removed the unused important.

I also cleaned it up a little

  • Added the new helper function as an export
  • Left the default equality check as it is now so that this PR changes zero functionality, just adds customizability
  • Removed the commented out code.
  • Improved docs

Would you like me to document the new constructor argument? Or leave it as it is now with the global being documented?

@RobertBrunhage
Copy link

@vincenzopalazzo is this something we can get in so I don't have to use a forked version? :)

@vincenzopalazzo
Copy link
Collaborator

Ops I missed this for some reason, we can remove the merge commits @kvenn ?

Maybe just rebasing on main?

Thanks

@RobertBrunhage
Copy link

sorry for bumping this again @kvenn. Would be nice to do the above to get it in or if you are swamped I could make a PR

@kvenn kvenn force-pushed the custom-equality-support branch 3 times, most recently from b402de8 to b1c4bf8 Compare August 4, 2024 21:51
@kvenn
Copy link
Contributor Author

kvenn commented Aug 4, 2024

I rebased and squashed all my commits together. Please let me know if there's anything else I can do! We've been using this fork for the past 2 months and it's been blazing fast!

Also, if you'd like to keep the git history clean, squash merging these types of feature branches seems like a good alternative.

vincenzopalazzo
vincenzopalazzo previously approved these changes Aug 5, 2024
Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT, thanks!

It need to be rebased on main and then we are good to go

- The current equality check has received some dissatisfaction due to performance (and is a source of jank/missed frames in my application)
- This is an unopinionated way to allow those consumers to provide their own equality function with better performance via optimizedDeepEquals
@kvenn
Copy link
Contributor Author

kvenn commented Aug 5, 2024

Done! Thanks for the reviews :)

@vincenzopalazzo vincenzopalazzo merged commit 59bb1d5 into zino-hofmann:main Aug 5, 2024
4 checks passed
@kvenn kvenn deleted the custom-equality-support branch August 5, 2024 19:40
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.

Allow using a custom compare function
3 participants