-
Notifications
You must be signed in to change notification settings - Fork 432
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
fix(core): drafts not using server actions always generate a created at #7503
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
Component Testing Report Updated Sep 15, 2024 10:00 PM (UTC) ✅ All Tests Passed -- expand for details
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jordanl17! This looks like a very sensible fix to me. Left a couple of comments/suggestions. I think the isString check in particular isn't neccessary, so would be good to remove it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! Thank you for taking the time to write tests as well.
Description
Closes SDX-1519
There are currently instances where (when NOT using server actions), a document would be published with a
_createdAt
of the publish time, rather than the time at which the draft was created.This occurred due to
_createdAt
on the draft not being set on creation, thus on publish the content lake was default setting tonow
. This issue wouldn't be present if a refresh occurred between creating the draft and then publishing (since again content lake would fabricate acreatedAt
value for the draft which would then pull through in studio and be used in publish. This issue didn't occur with server actions since the server always reconciled thecreatedAt
and used the local server version rather than the client memory draft.What to review
The issue seemingly is just that
params.timestamp
was never set on the mutation execution.It feels most appropriate to guarantee a valid
createdAt
be defined whencreate
,createIfNotExists
orcreateOrReplace
mutation are called, since these are the instances at which a draft/published doc are conceived. Even if thetimestamp
is not defined, really this should be defaulted anyway.Do you feel this makes sense, or does it feel more appropriate to require that the caller define this, otherwise they potentially risk encountering this issue again
Testing
SquashedBuffer
mock for global date to validate that thecreatedAt
is being set according to the default fallback the first time the draft iscreateIfNotExists
Notes for release
Fix for an issue where published documents would be assigned a
createdAt
timestamp of their publish time, rather than the timestamp of when the associated draft was first created.