Cool thing! Kudos for building it.
However, it might be beneficial to mention that there is no specification that says that “id” elements must be present for GraphQL objects, or anything about their semantics. The “__typename” and “id” combination might not be unique, or it might be that “id” alone is unique across all objects. So, your deduplicator works if:
- Every object has an “id” field
- The “id” and “__typename” combination is unique across all objects
- The client asks “id” and “__typename” for all objects
I would love to see the generation of the cache key be configurable for the cases where the unique identity of an object is composed of other fields.