julienvincent / modelizr

Generate GraphQL queries from models that can be mocked and normalized.
http://julienvincent.github.io/modelizr
176 stars 6 forks source link

normalizr for mutations? #1

Closed matthewmueller closed 8 years ago

matthewmueller commented 8 years ago

hey this is a cool library, i'm starting to think about the same thing.

I was wondering if you thought about using normalizr going the other way for mutations. Something like this:

mutation:

user.create({
  name: 'matt',
  notes: [
    {
      id: 123,
      title: 'blah',
      body: 'hi'
    }
  ]
})

normalized:

entities: {
  users: [
    {
    name: 'matt',
    notes: [1]
    }
  ],
  notes: [
    {
      id: 123,
      title: 'blah',
      body: 'hi'
    }
  ]
}

database inserts:

INSERT INTO users VALUES (...)
INSERT INTO notes VALUES (...)

any downsides you foresee with this approach?

julienvincent commented 8 years ago

I'm not quite sure what you are proposing?