convoyinc / apollo-cache-hermes

A cache implementation for Apollo Client, tuned for performance
Other
483 stars 30 forks source link

Implement or document dataIdFromObject #418

Open cmbirk opened 5 years ago

cmbirk commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

nevir commented 5 years ago

Fantastic! Thanks as well

On Wed, Jul 3, 2019, 15:53 Chris Birk notifications@github.com wrote:

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

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/convoyinc/apollo-cache-hermes/issues/418?email_source=notifications&email_token=AAAKDHKO2N5HAJYFFL4QUYTP5UUVJA5CNFSM4H5HVCJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZF36YA#issuecomment-508280672, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAKDHOTDAUK6HOTAJFJPILP5UUVJANCNFSM4H5HVCJA .

wmertens commented 5 years ago

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