User objects not exploded in cloud function params
- [x] You've met the prerequisites.
- [x] You're running the latest version of Parse Server.
- [x] You've searched through existing issues. Chances are that your issue has been reported or resolved before.
Environment Setup
localhost node 3.6 mongo 3.0
Steps to reproduce
Parse.User.extend({
method: function() { return 'hello world'; }
});
Parse.Cloud.define('customFunction', function(request, response) {
response.success(request.user.method());
});
When called with a valid session token,
customFunction will return hello world on Parse Cloud Code
customFunction will throw TypeError: request.user.method is not a function on parse-server
Perhaps you need to init a User before calling request.user.method()?
We noticed this too but worked around it by either creating a new User with request.user.id or by querying the request.user. Not sure what the official stance is on this.
We extend as follows:
var User = Parse.Object.extend('_User', {
...
var query = new Parse.Query(User);
I think the official stance should be to match the behavior on hosted Parse Cloud Code.
In that case handleCloudFunction can be updated to user: new Parse.Object('_User', req.auth.user)
I can make a PR if the owners can confirm the expected behavior
I recommend making the PR anyway as it will have higher visibility and get things going
This might we WAI I couldnt get this test to fail: https://github.com/drinklynk/parse-server/commit/136ee6def5f5fff84b1554a307943d54429072c7
Yes, we are trying to match Parse.com behaviour in as many cases as we can. If you can submit a PR that gets us closer to Parse.com behaviour that would be much appreciated :)
So I resolved this one and just wanted to make a note of it in case someone comes looking later.
The issue was that there were TWO instances of Parse that were in my node_modules one under root and one under parse-server/node_modules
might be useful to have a warning when this is happening