parse-community / parse-community/parse-server

Make trigger context accessible in all triggers

Open
#7,058 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:feature
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

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 ;)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing context handling for beforeSave, afterSave, beforeDelete, afterDelete, and beforeFind, then compare how actions such as find, login, and liveQuery invoke triggers. Done means context passed by an action is available consistently in all relevant trigger callbacks, including afterFind, with coverage for the supported actions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.