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

Implement or document dataIdFromObject #418

Open
cmbirk opened this issue Jul 3, 2019 · 4 comments
Open

Implement or document dataIdFromObject #418

cmbirk opened this issue Jul 3, 2019 · 4 comments

Comments

@cmbirk
Copy link

cmbirk commented Jul 3, 2019

It would be useful for apollo-cache-hermes to allow a different cache key other than id on a given object. In-memory-cache uses dataIdFromObject that can be read about in their normalization documentation here: https://www.apollographql.com/docs/react/advanced/caching/#normalization

We have used that function to determine different cache keys by __typename.

👋 I would be willing to help implement this feature or document it if it currently exists, but will need some guidance from your team.

I didn't see this on your roadmap, but is this something you would be willing to add?

@nevir
Copy link
Contributor

nevir commented Jul 3, 2019

You're in luck! It's something we support today 💪. You can customize the id behavior by passing the entityIdForNode configuration option when instantiating the cache

@cmbirk
Copy link
Author

cmbirk commented Jul 3, 2019

Perfect, thanks! I'll open a PR to update the readme with instructions.

@nevir
Copy link
Contributor

nevir commented Jul 3, 2019 via email

@wmertens
Copy link

why not support dataIdFromObject so conversion from inmemory is without changes? Isn't it just an alias?

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

3 participants