feat: add Cloud Code context to ParseObject.fetch (#7779)

This commit is contained in:
yog27ray
2022-01-25 17:10:22 +05:30
committed by GitHub
parent 433e82f1df
commit 315290d161
2 changed files with 17 additions and 1 deletions

View File

@@ -3224,6 +3224,21 @@ describe('afterLogin hook', () => {
const query = new Parse.Query(TestObject); const query = new Parse.Query(TestObject);
await query.find({ context: { a: 'a' } }); await query.find({ context: { a: 'a' } });
}); });
it('beforeFind and afterFind should have access to context while making fetch call', async () => {
Parse.Cloud.beforeFind('TestObject', req => {
expect(req.context.a).toEqual('a');
expect(req.context.b).toBeUndefined();
req.context.b = 'b';
});
Parse.Cloud.afterFind('TestObject', req => {
expect(req.context.a).toEqual('a');
expect(req.context.b).toEqual('b');
});
const obj = new TestObject();
await obj.save();
await obj.fetch({ context: { a: 'a' } });
});
}); });
describe('saveFile hooks', () => { describe('saveFile hooks', () => {

View File

@@ -83,7 +83,8 @@ export class ClassesRouter extends PromiseRouter {
this.className(req), this.className(req),
req.params.objectId, req.params.objectId,
options, options,
req.info.clientSDK req.info.clientSDK,
req.info.context
) )
.then(response => { .then(response => {
if (!response.results || response.results.length == 0) { if (!response.results || response.results.length == 0) {