Operations are functions available within an Mutate Transaction callback with access to internal context including the current mutable version of the
DocumentStore being operated on.
The ones that are provided by GraphQL Paper out-of-the-box are
queueEvent. These are covered in Mutating Data.
What makes Operations different than regular functions is that the first argument is bound (via
.bind) at the beginning of every transaction, for each operation, with
The shape of the Operation Context is:
storeis the current mutable version of the store available during the transaction
schemais an instance of
GraphQLSchemabased on the schema passed into
eventQueueis an array of events that will be emitted at the end of the transaction
Creating Custom Operations
Additional Operations can be added to be used within the Mutate Transaction callback.
The first argument is reserved and must be the
context object even if it's not used for the custom operation. What is provided by the
OperationContext argument is described above.
If using typescript, import the
OperationContext for the first argument of the function. Setting up your Operation this way should allow the types and autocomplete to work within the the Mutate Transaction callback.
Operations can be added to the
Paper constructor's second argument configuration object, on the
The key provided in the
OperationMap hash is what is made available by destructuring within the Mutate Transaction callback.