Skip to content

Make trigger context accessible in all triggers #7058

Open
@AurelienVasseur

Description

@AurelienVasseur

Is your feature request related to a problem? Please describe.
Sometime we need to pass some context to adapt the behavior / action of a trigger.
Currently context is only available on these triggers: beforeSave - afterSave - beforeDelete - afterDelete - beforeFind
See #6459 #6626 #6666

Describe the solution you'd like
It should be possible to pass arguments from all 'actions' (e.g. find, login, liveQuery, etc...) to the triggers.
As I said the logic is already implemented for some of them and the concept seems to have been accepted.
I make sense to be able to use context in all triggers.

query.find( { context: {example: "abc"} } )

// currently we can use context with beforeFind :)
Parse.Cloud.beforeFind("myClass", async (request) => {
    if request.context.example == "abc" {
      // To some particular actions
    }
})

// currently we can't use context with afterFind :(
Parse.Cloud.afterFind("myClass", async (request) => {
    if request.context.example == "abc" {
      // To some particular actions
    }
})

I hope this feature will help a lot of devs ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions