-
Notifications
You must be signed in to change notification settings - Fork 147
Implement @created and @updated directives for automatic server timestamps #364
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #364 +/- ##
==========================================
+ Coverage 96.31% 96.38% +0.06%
==========================================
Files 24 24
Lines 2821 2875 +54
==========================================
+ Hits 2717 2771 +54
Misses 104 104
Continue to review full report at Codecov.
|
Hey @colinskow - thanks for the PR! This feature was requested in #230 One issue I see is how to handle this for |
@johnymontana the Cypher code to update the timestamps really depends on the type of mutation, which we don't really know in the case of custom code. For a developer who is already going to the trouble to implement custom mutation logic, adding timestamps is trivial. It would be quite complex for us to try to do it and we'd risk breaking the query. |
Agreed. Still a nice to have feature :) |
Rebased from master since I'm using this PR in my own development. |
Any updates on this? I'd like to use this myself. What's the holdup? |
I added
@created
and@updated
GraphQL directives which when attached to aDateTime
field will automatically populate with a server timestamp every time the object is created or modified. These work on nodes as well as relationship objects.@created
will add a timestamp when a node or relationship is created through CREATE or MERGE.@updated
will update the timestamp on CREATE, MERGE, and UPDATE.Example:
Includes unit tests for Cypher generation, and I've also tested manually with Neo4J Desktop to ensure the Cypher works as expected.