Just a little POC to add a versioning system with graphcool.
The trick is to add a beforeOperation
hook that save the last state into a separate collection.
- clone the repo
gcf deploy
gcf playground
Create a user
mutation {
createUser( name: "fabien0102") {
id
}
}
Create a post
mutation {
createPost(title: "test", authorId: "cjclxr2wg006b0102d50flrwn") {
id
title
}
}
Update a post
mutation {
updatePost(id: "cjclxs4vw006h0102por7sy81", title: "po po po") {
id
title
}
}
Get the generated history
{
allPosts {
id
author {
id
}
title
history {author {id} title}
}
}