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

(graphcache) - Refactor SelectionIterator and clean up exports #1060

Merged
merged 4 commits into from
Oct 14, 2020

Conversation

kitten
Copy link
Member

@kitten kitten commented Oct 14, 2020

Summary

These changes were initially started to remove obsolete exports from Graphcache. Previously we would expose some data.ts internals so they could be used externally, but since we forgot to expose initDataState those exports wouldn't be of much use anyway. So instead we can reduce our exports to a minimum just to satisfy our benchmark's needs.

Also this made me search for some more bundlesize opportunities, and I found that a small traversal helper could be rewritten and the shared SelectionIterator could be optimised a little. This also gave us a small micro-benchmark performance bump, since it's a hotpath.

Set of changes

  • Remove noopDataState, writeOptimistic, and reserveLayer from exports
  • Rewrite getFragments utility in ast/traversal.ts
  • Rewrite makeSelectionIterator to become nested if needed and remove intermediary iterator object

In theory these undocumented APIs could be used to write a custom
normalized cache based on Graphcache's internal logic. However, we
forgot to expose `initDataState` anyway and additionally these APIs
were not actually in use by anyone. So for now we'll remove them.
- Replace object with just an iterate function
- Reduce cost of iteration by adding recursive iterators
@kitten kitten requested a review from JoviDeCroock October 14, 2020 12:57
@changeset-bot
Copy link

changeset-bot bot commented Oct 14, 2020

🦋 Changeset detected

Latest commit: 96a797d

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

This PR includes changesets to release 1 package
Name Type
@urql/exchange-graphcache 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

@JoviDeCroock JoviDeCroock merged commit 2c26cd5 into main Oct 14, 2020
@JoviDeCroock JoviDeCroock deleted the chore/remove-private-graphcache-exports branch October 14, 2020 20:38
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.

2 participants