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

Add better description of what a normalized graph cache is #383

Open
jnak opened this issue Oct 15, 2018 · 1 comment
Open

Add better description of what a normalized graph cache is #383

jnak opened this issue Oct 15, 2018 · 1 comment

Comments

@jnak
Copy link

jnak commented Oct 15, 2018

In the design exploration, it is not clear how the normalize graph is different than the regular flat map.

The examples look exactly the same:

  • flat map:
{
  ROOT: {
    posts: [
      { __ref: 1 },
      { __ref: 2 },
    ],
  },
  1: {
    id: 1,
    title: 'GraphQL Rocks!',
    author: { __ref: 3 },
  },
  2: {
    id: 2,
    title: 'GraphQL Rocks!',
    author: { __ref: 3 },
  },
  3: {
    id: 3,
    name: 'Gouda',
  },
}
  • normalized graph:
{
  ROOT: {
    posts: [
      {…}, // Reference to <1>
      {…}, // Reference to <2>
    ],
  },
  1: {
    id: 1,
    title: "GraphQL Rocks!",
    author: {…} // Reference to <3>
  },
  2: {
    id: 2,
    title: "Caching Is Hard",
    author: {…} // Reference to <3>
  },
  3: {
    id: 3,
    name: 'Gouda',
  },
}

Would you mind updating the description of the normalized graph cache?

@jnak jnak changed the title Add better description of a normalized graph cache is Add better description of what a normalized graph cache is Oct 15, 2018
@nevir
Copy link
Contributor

nevir commented Oct 31, 2018

Yeah, let me try explaining here to see where I'm missing info:

The main difference is that in the second example, ROOT.posts[0] maps to the exact same javascript object as 1. Whereas in the first example, that mapping is represented by an intermediate object (the { __ref: 1 }). Does that clarify?

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

2 participants