Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass request.query to afterFind #6960

Merged
merged 2 commits into from
Oct 22, 2020

Conversation

dblythy
Copy link
Member

@dblythy dblythy commented Oct 22, 2020

Not sure if this should be an issue or expected behaviour, but one that I quickly created a test case for and provided a fix for.

Issue

req.query is undefined on afterFind.

Considering afterFind is directly related to the Parse.Query that called it, shouldn't req.query be defined?

Test case:
(Fails on Parse Server 4.3.0)

it('should add afterFind trigger', done => {
    Parse.Cloud.afterFind('MyObject', req => {
      const q = req.query;
      expect(q instanceof Parse.Query).toBe(true);
    });

    const query = new Parse.Query('MyObject');
    query.find().then(() => {
      done();
    });

});

In my use, I wanted to handle req.objects differently depending on whether the query was an include from another object, or whether the query was an or query on the class.

@ghost
Copy link

ghost commented Oct 22, 2020

Danger run resulted in 1 fail and 1 markdown; to find out more, see the checks page.

Generated by 🚫 dangerJS

@codecov
Copy link

codecov bot commented Oct 22, 2020

Codecov Report

Merging #6960 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6960      +/-   ##
==========================================
+ Coverage   93.77%   93.80%   +0.02%     
==========================================
  Files         169      169              
  Lines       12261    12269       +8     
==========================================
+ Hits        11498    11509      +11     
+ Misses        763      760       -3     
Impacted Files Coverage Δ
src/RestQuery.js 95.51% <100.00%> (+0.04%) ⬆️
src/triggers.js 92.48% <100.00%> (+0.04%) ⬆️
src/RestWrite.js 93.65% <0.00%> (-0.17%) ⬇️
src/ParseServer.js 89.47% <0.00%> (ø)
src/LiveQuery/ParseLiveQueryServer.js 94.94% <0.00%> (+0.31%) ⬆️
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 93.58% <0.00%> (+0.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef2e54c...7c87d12. Read the comment docs.

src/triggers.js Outdated Show resolved Hide resolved
@dplewis dplewis merged commit c68d055 into parse-community:master Oct 22, 2020
@dblythy
Copy link
Member Author

dblythy commented Oct 22, 2020

Thanks again @dplewis!

@dblythy dblythy deleted the afterFindRequest branch October 22, 2020 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants