diff --git a/spec/CloudCode.spec.js b/spec/CloudCode.spec.js index c185eac53e..4b8df9f9c9 100644 --- a/spec/CloudCode.spec.js +++ b/spec/CloudCode.spec.js @@ -3224,6 +3224,21 @@ describe('afterLogin hook', () => { const query = new Parse.Query(TestObject); 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', () => { diff --git a/src/Routers/ClassesRouter.js b/src/Routers/ClassesRouter.js index 6788d93e5f..7f3e0a84f3 100644 --- a/src/Routers/ClassesRouter.js +++ b/src/Routers/ClassesRouter.js @@ -83,7 +83,8 @@ export class ClassesRouter extends PromiseRouter { this.className(req), req.params.objectId, options, - req.info.clientSDK + req.info.clientSDK, + req.info.context ) .then(response => { if (!response.results || response.results.length == 0) {