Skip to content

Make it possible to skip triggers #7059

Open
@AurelienVasseur

Description

@AurelienVasseur

Is your feature request related to a problem? Please describe.
When I'm writing tests I would like to be able to skip triggers.
For example, if I do some security check on my triggers I need to match with that on my test, and sometime it's very annoying because the objective is not to test the trigger, but something else. So it will be very useful to skip them.

Describe the solution you'd like
I see 2 major possibilities:

  1. Add an option which can be pass (as a context) on actions
object.save( { skip_before_save: true, skip_after_save: true } );
  1. Use the context to simulate the skipping
object.save( { context: { skip_before_save: true, skip_after_save: true } } );

Parse.Cloud.beforeSave("myClass", async (request) => {
   if request.context.skip_before_save == false {
      // do some work
   }
});

Parse.Cloud.afterSave("myClass", async (request) => {
   if request.context.skip_after_save == false {
      // do some work
   }
});

The second solution only required that the context can be used on every triggers - #7058 - but it don't really skip the trigger.
So I definitely think that the first one can be the best option (or something else in the same spirit).

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