@sequence
The @sequence
directive is used to mark a field as a sequence field in a projection.
A sequence can be applied to a field of type Int!
.
Example
type User @upsertOn(...) {
userId: Int! @sequence
}
In this case, the @identifier directive marks the userId
field as a second identifying field of the User
projection.
Groups
Sequences can be grouped. This means that the sequence will exist per group.
A group is defined by fields given in the group
argument of the directive.
The group
argument is a list of field names that are used to group the sequence.
type User @upsertOn(...) {
sequence: Int! @sequence(group: ["name"])
}
In this case, the sequence
field is a sequence field that is grouped by the name
field.
Practically, this means that for each name the sequence will count up from 1. So the field will tell you that the user is the nth user with that name.
Grouping can only be done on fields that have the @immutable
and the @index
directives applied to them.
Offset
The offset
argument can be used to set the starting value of the sequence.
type User @upsertOn(...) {
sequence: Int! @sequence(offset: 100)
}
In this case, the sequence
field will start counting from 100.