Graphcool / graphcool-framework

Apache License 2.0
1.78k stars 130 forks source link

provide automatic versioning of model data #22

Open marktani opened 6 years ago

marktani commented 6 years ago

Issue by balupton Tuesday Jan 31, 2017 at 09:09 GMT Originally opened as https://github.com/graphcool/prisma/issues/82


it would be nice if every change of model data created a new version of that particular model item - such that one can go back and revert a previous model item or cycle through revision history of a model item

marktani commented 6 years ago

Comment by schickling Tuesday Jan 31, 2017 at 10:36 GMT


That's a really interesting idea, @balupton. Would you imagine that only the newest model version is exposed via the GraphQL schema? How would you want to access older versions of the schema?

marktani commented 6 years ago

Comment by balupton Tuesday Jan 31, 2017 at 10:45 GMT


yeah, by default only the latest model is exposed, older versions can be returned by passing a version field

marktani commented 6 years ago

Comment by sorenbs Friday Mar 03, 2017 at 15:42 GMT


What should happen when the model schema changes?

Say the Photo model looks like this:

type {
  url: String!
}

and has this data:

{url: "some.url"}

now you change the model like this:

type {
  url: String!,
  title: String!
}

with a migration value for the title.

If you want to query the old values through the same schema we would have to apply the migration value to historical nodes. Ie:

{
  allPhotos(version:1){
    title
  }
}

would return the migration value.

Do you think this is reasonable?