Automatic value for creation_date and modification_date

Hey there,

I’m very new to DGraph and GraphQL, and I’m trying to achieve a very basic thing.

I have a type Article that has both creation_date and modification_date and I need their value to be auto generated upon creation and modification.
I guess I could script that from the server if I would be running one (though I’m guessing it would not be the best way), and I wonder how I could get the value to be created when using it serverless (connecting straight from a webclient to Slash Dgraph of an self-hosted version).

Is there a special modifier or function to assign?

If I’m missing a documentation that you think I missed I’d be very glad to get through it.
Thanks! :slight_smile:

humm,

hey @gja, do you know if lambdas works with mutations? I think that would be the case here. Make something like date.now().

I don’t think that rely on the end application would be safe (end users can exploit the date if so). This type of thing should be done in the server side. And as we have a GraphQL server, this should be available or give a possibility to do so(like using lambda).

I think that Prisma guys has createdAt and updatedAt by default. And just expose them if the user request it. Maybe we should do the same.

No, lambdas currently don’t work as hooks, though it’s on the roadmap. This seems like a good feature for the graphql roadmap @pawan

2 Likes

Right, thanks for the prompt replies!

That makes me wonder how DGraph real-world users actually deal with this pattern.
I’m sure you had the need to sort or filter by creation date or last modified items.
How do you currently achieve these?

I’m certainly missing a concept here.
Should DGraph actually always be traversed through a trusted server that overrides mutations and eventually the builtin DGraph/GraphQL for reading data directly?
Should the DGraph/GraphQL be only used from trusted source (no end user client)?

The documentation is really great for getting into the details and challenge the system in many ways, I’m very excited to also get the overall idea :slight_smile:

1 Like

Related topic

1 Like

Thanks for that link, that’s indeed helpful first not to feel like I’m the only one for who that’s a common need, and second for getting a start of a concrete answer. :+1:

I’ll see what can be done with createdAt: DateTime @default(expr: $now) and try to figure a way to solve the updatedAt.
I guess while it’s not completed on the roadmap a server is still required in the middle.

1 Like

Hi,

Reading the discussion here it appears that the ability to add a createdAt and updatedAt timestamp on the DB side when an entity is created or updated is still missing. We have recently started our journey with Dgraph cloud and this is an important feature that’s missing. Is there a timeline on when this will be released?

2 Likes