reym
Projections/Schema/Field

@from

The @from directive can be used to calculate the value of a field from an expression.

ArgumentDescription
eventsrestrict the usage of the directive to a list of event types
topicsrestrict the usage of the directive to a list of topics
conditionrestrict the usage of the directive to the match of a condition expression
valuecalculate the value of the field by using an expression

Example

Let's say you have the following schema:

user.graphql
type User @upsertOn(...) {
    email: String! @from(
        events: ["createUser", "updateUser"]
        topics: ["userManagement"]
        condition: "payload.name != nil"
        value: "payload.name + '@becklyn.com'"
    )
}

This schema will generate the email field for all events of the topic userManagement that have the types createUser or updateUser and have a payload field name which is not nil. The value will be the value of the payload field name combined with the string @becklyn.com.

For this event Payload:

payload.json
{
    "name": "John"
}

The value of the projection entry field email will be "John@becklyn.com".

On this page