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

perf(vue): use shallowRef for data #3641

Merged
merged 1 commit into from
Jul 29, 2024
Merged

Conversation

yurks
Copy link
Contributor

@yurks yurks commented Jul 26, 2024

Summary

As graphql response usually contains a quite huge nested objects structure, wrapping it with ref() is not memory efficient.
Instead of doing this, it's more efficient to use shallowRef() for data reactive variable, where the payload is stored.

However, in #3611 while optimizing other variables, @negezor missed the data variable. I can assume there was a reason for that, so I consider this PR as a suggestion/discussion. Personally, I don't see any negative side effects from using shallowRef(), but maybe you guys have some thought on it.

I see only one possible scenario in which this would be a "breaking change": updating some nested data parts manually outside of this plugin, but I'd say - this is a quite specific pattern.

Set of changes

  • Replaces ref() with shallowRef() for the data variable

Copy link

changeset-bot bot commented Jul 26, 2024

🦋 Changeset detected

Latest commit: fc215b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@urql/vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@negezor
Copy link
Contributor

negezor commented Jul 27, 2024

Makes sense, I wasn't originally looking at data as to how field level changes might be happening there. But I forgot that we always replace the contents of ref 😅

Copy link
Member

@kitten kitten left a comment

Choose a reason for hiding this comment

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

Don't really see what could go wrong here, since types aren't relevant and computed was already mentioned and recommended across several issues/discussions 👍

@kitten kitten merged commit 1315df1 into urql-graphql:main Jul 29, 2024
13 checks passed
@github-actions github-actions bot mentioned this pull request Jul 29, 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.

3 participants