-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Create Cloud function afterLiveQueryEvent #6859
Conversation
This reverts commit 828c678.
This is a branch that I am using myself nonetheless. I'd be curious to see if this is something that we could possibly add to the master. Failing tests are not related to this PR. |
* Remove Facebook AccountKit auth Account Kit services are no longer available. https://developers.facebook.com/blog/post/2019/09/09/account-kit-services-no-longer-available-starting-march/ https://www.sinch.com/blog/facebook-account-kit-is-closing-down-are-your-apps-covered/ * remove flaky test
Snyk has created this PR to upgrade uuid from 8.2.0 to 8.3.0. See this package in npm: https://www.npmjs.com/package/uuid See this project in Snyk: https://app.snyk.io/org/acinader/project/8c1a9edb-c8f5-4dc1-b221-4d6030a323eb?utm_source=github&utm_medium=upgrade-pr Co-authored-by: Diamond Lewis <findlewis@gmail.com>
…e-community#6864) The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-LODASH-590103 Co-authored-by: Diamond Lewis <findlewis@gmail.com>
Snyk has created this PR to upgrade ldapjs from 2.0.0 to 2.1.0. See this package in npm: https://www.npmjs.com/package/ldapjs See this project in Snyk: https://app.snyk.io/org/acinader/project/8c1a9edb-c8f5-4dc1-b221-4d6030a323eb?utm_source=github&utm_medium=upgrade-pr Co-authored-by: Diamond Lewis <findlewis@gmail.com>
…nity#6851) Snyk has created this PR to upgrade apollo-server-express from 2.15.1 to 2.16.0. See this package in npm: https://www.npmjs.com/package/apollo-server-express See this project in Snyk: https://app.snyk.io/org/acinader/project/8c1a9edb-c8f5-4dc1-b221-4d6030a323eb?utm_source=github&utm_medium=upgrade-pr Co-authored-by: Diamond Lewis <findlewis@gmail.com>
…nity#6845) Snyk has created this PR to upgrade @graphql-tools/stitch from 6.0.12 to 6.0.13. See this package in npm: https://www.npmjs.com/package/@graphql-tools/stitch See this project in Snyk: https://app.snyk.io/org/acinader/project/8c1a9edb-c8f5-4dc1-b221-4d6030a323eb?utm_source=github&utm_medium=upgrade-pr Co-authored-by: Diamond Lewis <findlewis@gmail.com>
…ity#6846) Snyk has created this PR to upgrade @graphql-tools/utils from 6.0.12 to 6.0.13. See this package in npm: https://www.npmjs.com/package/@graphql-tools/utils See this project in Snyk: https://app.snyk.io/org/acinader/project/8c1a9edb-c8f5-4dc1-b221-4d6030a323eb?utm_source=github&utm_medium=upgrade-pr Co-authored-by: Diamond Lewis <findlewis@gmail.com>
* fix: upgrade winston from 3.2.1 to 3.3.2 Snyk has created this PR to upgrade winston from 3.2.1 to 3.3.2. See this package in NPM: https://www.npmjs.com/package/winston See this project in Snyk: https://app.snyk.io/org/acinader/project/8c1a9edb-c8f5-4dc1-b221-4d6030a323eb?utm_source=github&utm_medium=upgrade-pr * fix tests Co-authored-by: Diamond Lewis <findlewis@gmail.com>
This reverts commit 828c678.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forked it because I needed it in my project. From what I tested, everything works perfectly. Also, thanks @dblythy, because LiveQuery MatchesQuery is working like a charm.
…e-server into afterLiveQueryEvent
Thank you @FNPCMDs! I would say be careful performance-wise as every LiveQuery event will trigger the secondary query unless the cloud function is restrictive. Also make sure you have your secondary query indexed and efficient as possible 😊 |
Codecov Report
@@ Coverage Diff @@
## master #6859 +/- ##
==========================================
- Coverage 93.92% 93.78% -0.14%
==========================================
Files 169 169
Lines 12210 12252 +42
==========================================
+ Hits 11468 11491 +23
- Misses 742 761 +19
Continue to review full report at Codecov.
|
@dblythy Sorry for the late reply. The PR looks good. My question is should this hook return an object? Similar logic to beforeSubscribe that you wrote #6868 (comment) |
Thanks for the feedback @dplewis. I've removed the option to return an object, and also made sure that mutating req.object / req.original changes the class name 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I look forward to using this in production
Let me know if I've made a mistake in the docs formatting @dplewis. I've also added masterKey, installationId, clients, and subscription to the cloud function request for completeness. Thank you 🙏 |
Danger run resulted in 1 fail and 1 markdown; to find out more, see the checks page. Generated by 🚫 dangerJS |
This is a new Cloud function that allows mutation of the
original
andcurrent
objects that get sent to the LiveQuery client. This is a LiveQuery equivalent ofafterFind
.Implementation:
This could also be a solution to #2946, by allowing secondary querying in the afterLiveQueryEvent block.
Using async will obviously slow down the speed of LiveQuery events, and will require proper indexing / query design. It will also increase the required resources.
I've added a number of test cases to ensure it works as expected for "Create", "Update", "Enter", "Leave", and "Delete" events.
This feature is inspired by a few different threads.
#1686 - include in LiveQuery. This is not a direct solution, however it allows custom mutations and that could emulate .include functionality.
And this issue in the JS SDK, which restricts LiveQuery events to specific events.
Let me know what you think!