apollo-cache-hermes icon indicating copy to clipboard operation
apollo-cache-hermes copied to clipboard

Implement or document dataIdFromObject

Open cmbirk opened this issue 5 years ago • 4 comments

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?

cmbirk avatar Jul 03 '19 16:07 cmbirk

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

nevir avatar Jul 03 '19 18:07 nevir

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

cmbirk avatar Jul 03 '19 22:07 cmbirk

Fantastic! Thanks as well

On Wed, Jul 3, 2019, 15:53 Chris Birk [email protected] 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 .

nevir avatar Jul 03 '19 23:07 nevir

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

wmertens avatar Jul 22 '19 16:07 wmertens