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

[Epic] Load reader ASTs only when a non-null parent object is encountered #73

Open
rbalicki2 opened this issue Apr 21, 2024 · 0 comments

Comments

@rbalicki2
Copy link
Collaborator

rbalicki2 commented Apr 21, 2024

  • Developers should be able to mark certain parent fields that are likely to be null or certain child fields that are expensive with e.g. directives or pipes or something in isograph literals. Examples:
field User.DetailComponent @component {
  best_friend @likelyToBeNull {
    BestFriendDisplay
  }
  worst_enemy {
    WorstEnemyVideoPlayer @expensive
  }
}
  • The behavior in the above situation is as follows. The BestFriendDisplay and WorstEnemyVideoPlayer reader ASTs are lazily loaded (i.e. () => import(...)), i.e. not hard required in the User.DetailComponent reader AST.
  • Instead, the normalization artifact will have the reader ASTs we must load when we encounter a non-null best_friend/worst_enemy. Upon receiving data that makes these fields non-null, we start a network request for these readers. When complete, we write the resulting BestFriendDisplay (etc) into the store into a field that never gets GC'ed (probably).
  • The readers will suspend if they encounter a not-yet-loaded BestFriendDisplay etc
  • Readers should also be able to fall back to loading this. At minimum, readers need to also keep track of the nested components that are lazily dependent.
  • When we modify data in the store, we run through each subscription and get encountered records. When we re-read those fragments, we also check and potentially run the function to import.
  • Special __asConcreteType fields that refine to a concrete type should also be valid parents, in which case the above works iff the parent object exists and has the right type. So, we get Relay 3D.
@rbalicki2 rbalicki2 changed the title [Epic] Load reader ASTs if a non-null parent object is encountered [Epic] Load reader ASTs only when a non-null parent object is encountered Apr 21, 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

No branches or pull requests

1 participant