-
Notifications
You must be signed in to change notification settings - Fork 61
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: async query pager fetch with cache policy #444
feat: async query pager fetch with cache policy #444
Conversation
👷 Deploy request for apollo-ios-docc pending review.Visit the deploys page to approve it
|
👷 Deploy request for eclectic-pie-88a2ba pending review.Visit the deploys page to approve it
|
@AnthonyMDev @Iron-Ham Any reason either of you have that we wouldn't want to do something like this? |
I'd love to learn more about this use-case. I have some concerns that this would result in unexpected outcomes (when fetched using Is the idea that this data has already been fetched elsewhere in the app (in an existing session) and should be reused? If that's the case, having the second usage Otherwise... I think we could accomplish the same behavior by removing the |
The app is structured around many View/ViewModel components that are more or less tied to a feature. There's very few environment objects passed down (i.e. user model). So each part of the app defines it's own GraphQL queries and heavily relies on the normalized cache to avoid a crazy number of fetch requests. Also since all the queries are implemented with watchers it's very easy to keep state in sync when the normalized cache is updated directly or indirectly. In the particular case of pagination, we have a view that can be presented through multiple entry points like you mentioned. One thing to keep in mind though with the View/ViewModel pattern described above is that when views are popped from the screen, swift also garbage collects any state and view models that came with them. So even when you go back and forth on the same View, we end up triggering a bunch of fetch requests with the current apollo pagination package.
This would be just as good as my modification to the fetch API. Before I created this PR I did try making everything based on |
Gotcha. Thank you for the additional context @pondorasti. I'm happy with this feature with a few changes:
|
This reverts commit ed338f8.
…e-fetch-with-cache-policy
Done!
Looks like apollo-ios-dev/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPagerCoordinator.swift Lines 39 to 41 in 94be720
|
Looks good to me! I'm happy with the What do y'all think @BobaFetters @AnthonyMDev? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and simple! Thanks for working through this @pondorasti and @Iron-Ham!
017a468c feat: async query pager fetch with cache policy (#444) git-subtree-dir: apollo-ios-pagination git-subtree-split: 017a468c3ce4a6444b56294a1dd6cb17fd902e8a
…h with cache policy git-subtree-dir: apollo-ios-pagination git-subtree-mainline: 930a866 git-subtree-split: 017a468c3ce4a6444b56294a1dd6cb17fd902e8a
resolves apollographql/apollo-ios#3418