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

refactor(populate): fields-based populate #2897

Merged
merged 3 commits into from
Jan 10, 2023
Merged

Conversation

JoviDeCroock
Copy link
Collaborator

@JoviDeCroock JoviDeCroock commented Dec 20, 2022

Resolves #1149

Summary

This changes the way we populate slightly, rather than going over queries and assembling fragments for all the fields we find, we iterate over all selections within queries and hold a graph of all the requested fields. When we see a mutation we look at the return-type and start filling out the selection-sets based on the observed fields.

The issue now becomes that this keeps growing, we could say that when a teardown happens that we remove the fields but then we run the risk that data in the cache remains stale as a torn down query does not mean we remove the cached data so mutations on data that isn't mounted would become stale.

Proposal: we introduce a max-depth of for instance 3 so it only fills out that much in the selection sets, most commonly in mutations the first-level already reflects most things needed.

Todo:

  • support fields with arguments
  • support all types in field-arguments
  • add aliases for duplicate fields with different arguments
  • find solution to the fields-graph growing endlessly

Future pull requests:

  • support the viewer field
  • support re-fetching through populating relevant queries

@JoviDeCroock JoviDeCroock marked this pull request as ready for review December 23, 2022 13: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.

@urql/exchange-populate: fragments breaking in versions >=0.2.0
2 participants