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

Rename Entity to something different? #16

Closed
jonaskello opened this issue Aug 23, 2018 · 7 comments · Fixed by #35
Closed

Rename Entity to something different? #16

jonaskello opened this issue Aug 23, 2018 · 7 comments · Fixed by #35

Comments

@jonaskello
Copy link
Member

Today an object in the cache is referred to as an Entity.

An object in the cache have these characteristics:

  • Identifiable by an ID
  • No hierarchy, instead it has pointers to other IDs (it is normalized)

Other names that might be more self-documenting:

  • CacheRecord
  • NormalizedObject

Entity is nice because it is a single word. Perhaps we can keep it and document the meaning of it better.

@jonaskello jonaskello changed the title Rename Entity to something different Rename Entity to something different? Aug 23, 2018
@Jontem
Copy link
Contributor

Jontem commented Sep 28, 2018

Could you please tell why you thinking about a name change

@jonaskello
Copy link
Member Author

Well, there is no tradition of calling something Entity within the GraphQL world so the meaning is somewhat undefined.

In the gql-cache world an Entity is basically a normalized object which is used as a cache record but this may not be obvious to everyone from the name Entity.

@jonaskello
Copy link
Member Author

One interesting question is what the same thing is called in the apollo and relay worlds.

@jonaskello
Copy link
Member Author

Btw the use of the name Entity comes mainly from the normalizer world which is what I used previous to gql-cache.

@jonaskello
Copy link
Member Author

jonaskello commented Sep 28, 2018

But as I said above, documentation might be all we need. Something like "The GraphQL response is turned into normalized objects that are used as cache records. Each such object must have an unique ID that is also used as cache key. We refer to these objects as Entity. "

@jonaskello
Copy link
Member Author

We actually normalize all objects, even if they have no ID (in that case we generate an ID). Objects that have no ID are refered to as ValueObject (at least in the world on domain driven design). So to call the cache an EntityCache is actually not correct. It is an EntityAndValueObjectCache :-).

This is how it works today, depending on how we resolve #27 this may change.

@jonaskello
Copy link
Member Author

Also calling something a cache implies that it is used to cache stuff. You may use this library to return normalized responses from the server for de-duplication purposes. So it should probably not have "cache" in the name either. NormalizedObjectMap or something like that may be more correct.

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

Successfully merging a pull request may close this issue.

2 participants