Does anyone know how I would go about versioning a...
# prisma-whats-new
i
Does anyone know how I would go about versioning a specific resource? For example, say I was re-writing Facebook. How would I go about using GraphQL/Graphcool to version a Post? (That a User can access the latest version on but also access previous versions of that same Post.)
I know that GraphQL is versionless. I personally love that. But I’m not talking about the API as a whole. I am talking about specific resources where you could time travel to it’s previous versions. (Just here for extra clarity!)
p
@iamclaytonray If it were up to me, I'd do either of the two: 1. Create a new type called
PastPost
which is a replica of
Post
but with a reference to the newest version of the post. Then have a
past
array field in
Post
with references to old versions of the post. Every time the post gets updated, I'd create a new
Post
, convert the old
Post
into a
PastPost
, and link them. 2. If only a subset of the post data is versioned (for example,
body
), I'd create a
PostBody
type instead and simply convert
body
in
Post
into an array. That way I always just fetch the latest and have access to old. This would save a lot of storage space if your
Post
type is quite large and only a subset is updated.
i
That’s what I was afraid of. Thanks for answering!
p
Yeah, not a very elegant solution. Maybe @nilan can shine some light in case I overlooked something.
🙂 1
i
@Pkmmte - I opened up an issue to add resource/type versioning to the spec. Not sure how far it would go, how involved it would be, or if it’s even realistic, but I guess I’ll find out soon. Thought you might be interested though! https://github.com/facebook/graphql/issues/380
👍 1
And, @nilan, if you have any thoughts on the matter, I’d love to hear them!