Skip to content

Commit

Permalink
feat: add Cloud Code context to ParseObject.fetch (#7779)
Browse files Browse the repository at this point in the history
  • Loading branch information
yog27ray authored Jan 25, 2022
1 parent 433e82f commit 315290d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/Routers/ClassesRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 315290d

Please sign in to comment.