-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add implicit cache redirect #1034
Conversation
@joarwilk it's a neat idea, but is it actually useful in practice? How often do you make a query that requests exactly one item by id? And in those cases, is it unreasonable to force developers to write a bit more boilerplate? |
@helfer I would guess most apps have some sort of listing -> details flow. For example: a blog post listing -> blog post, a list of videos -> video, list of emails -> email, the sidebar of a manpage -> manpage entry. All those cases have some data that can be reused, and they would probably benefit from this. In the case of documentation / boilerplate vs built-in feature, I would compare it to this pr: #228. Similar to this functionality, that could have been something that would have been added by hand to each project as a documented network middleware. |
I second this, I actually thought this would be the default behaviour. |
@joarwilk I think the main difference is that |
@helfer Yeah that's a good point. I guess |
@joarwilk well, if you pass the function to ApolloClient at initialization, you can also use the |
@helfer Sounds good, I'll update the PR to make it optional |
@joarwilk just to be clear, I think we should try an option named |
@helfer Updated. I realised that this requires globally unique IDs as it wont work when objects are stored in cache using the popular |
@joarwilk if you're still interested in this, can you please open a new issue or PR for discussion? Thanks! 🙂 |
Haha I read this and was like "All the bloody time". |
I wanted to open this issue as a PR because its sometimes easier to convey ideas that way.
This PR makes this issue #332 automatic.
When typing this message it felt a bit unnecessary since every field which would like to use local cache lookups will look exactly the same.
Based on my experience from working with apollo and relay, as well as the reactions from people in the chat, I'd say people assume that this functionality is present. Writing resolvers for your own cache is not expected behaviour.
This PR is not a good implementation, but it works and I figured I'd start here. I dont think everyone wants this, so it might be good to hide behind a flag. Also, not everyone uses the literal
id
as the id param.TODO: