Skip to content

Commit c9f46e8

Browse files
committed
fix: Pass context to afterFind hook while making object.fetch call.
1 parent 826aa79 commit c9f46e8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

spec/CloudCode.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3224,6 +3224,15 @@ describe('afterLogin hook', () => {
32243224
const query = new Parse.Query(TestObject);
32253225
await query.find({ context: { a: 'a' } });
32263226
});
3227+
3228+
it('afterFind should have access to context while making fetch call', async () => {
3229+
Parse.Cloud.afterFind('TestObject', req => {
3230+
expect(req.context.a).toEqual('a');
3231+
});
3232+
const obj = new TestObject();
3233+
await obj.save();
3234+
await obj.fetch({ context: { a: 'a' } });
3235+
});
32273236
});
32283237

32293238
describe('saveFile hooks', () => {

src/Routers/ClassesRouter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export class ClassesRouter extends PromiseRouter {
8383
this.className(req),
8484
req.params.objectId,
8585
options,
86-
req.info.clientSDK
86+
req.info.clientSDK,
87+
req.info.context
8788
)
8889
.then(response => {
8990
if (!response.results || response.results.length == 0) {

0 commit comments

Comments
 (0)