reym
CRUD/Schema/Object

@expires

The @expires directive allows you to specify a condition under which the entry will expire and be removed.

Argument condition

When using the @expires directive on a crud type, the condition expression environment will only have the projection fields available for this operation. These expressions are documented here: Expressions.

user.graphql
type User @crudType @expires(condition: "now > projection.expiresAt") {
    expiresAt: DateTime!
}

Argument after

As an alternative to the condition argument, you can use the after argument to specify a time to live. The entry will expire if the timespan between the creation date of the entry and right now is longer than the given time to live.

user.graphql
type User @crudType @expires(after: { days: 10 }) {
    expiresAt: DateTime!
}

This will automatically delete the entry 10 days after it was created.