Skip to content

Commit 315290d

Browse files
authored
feat: add Cloud Code context to ParseObject.fetch (#7779)
1 parent 433e82f commit 315290d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Diff for: spec/CloudCode.spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -3224,6 +3224,21 @@ describe('afterLogin hook', () => {
32243224
const query = new Parse.Query(TestObject);
32253225
await query.find({ context: { a: 'a' } });
32263226
});
3227+
3228+
it('beforeFind and afterFind should have access to context while making fetch call', async () => {
3229+
Parse.Cloud.beforeFind('TestObject', req => {
3230+
expect(req.context.a).toEqual('a');
3231+
expect(req.context.b).toBeUndefined();
3232+
req.context.b = 'b';
3233+
});
3234+
Parse.Cloud.afterFind('TestObject', req => {
3235+
expect(req.context.a).toEqual('a');
3236+
expect(req.context.b).toEqual('b');
3237+
});
3238+
const obj = new TestObject();
3239+
await obj.save();
3240+
await obj.fetch({ context: { a: 'a' } });
3241+
});
32273242
});
32283243

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

Diff for: src/Routers/ClassesRouter.js

+2-1
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)