-
-
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
GraphQL Subscriptions #7227
base: alpha
Are you sure you want to change the base?
GraphQL Subscriptions #7227
Conversation
Danger run resulted in 1 warning; to find out more, see the checks page. Generated by 🚫 dangerJS |
Codecov Report
@@ Coverage Diff @@
## master #7227 +/- ##
==========================================
- Coverage 94.01% 93.38% -0.64%
==========================================
Files 172 173 +1
Lines 12873 13047 +174
==========================================
+ Hits 12103 12184 +81
- Misses 770 863 +93
Continue to review full report at Codecov.
|
connectReject = reject; | ||
}); | ||
|
||
const liveQuery = { |
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.
This is really clever!
@@ -242,6 +242,11 @@ function matchesKeyConstraints(object, key, constraints) { | |||
return false; | |||
} | |||
break; | |||
case '$eq': |
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.
Isn't this case already handled?
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.
Yes. Currently, { "field": "value" }
works but { "field": { "$eq": "value" } }
does not work for live query. It could actually even be a separate PR.
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.
Just supporting what @davimacedo mentioned about $eq
not working for LiveQuery is true. @dplewis if you recall, I was using $eq
in ParseSwift and asked you about it here #7113 (comment). I then made a change to ParseSwift to not use $eq
anymore here parse-community/Parse-Swift#49
|
It seems here that we need to move from subscriptions-transport-ws (not maintained) to https://github.com/enisdenjo/graphql-ws |
I don't know enough about websocket systems to give useful feedback: My questions would be more generalized:
As i understand the main goal is to reuse the livequery server, we internally forward subscriptions to the Livequery server and then the LivequeryServer will "push" updates through the GraphQL subscriptionServer. Also as you said we need to create a dedicated MyClassSubscriptionWhereInput to cover usable subscriptions. |
New Pull Request Checklist
Issue Description
This PR add subscription support to the GraphQL API.
Related issue: #6617
Approach
We are basically taking a ride with the existing Live Query implementation. In order to use subscriptions, the allowed class names needs to be listed in the liveQuery configuration. A Live Query server is not needed though. We are simulating a ws adapter in order to connect directly to the live query implementation without actually creating sockets (which would not make sense).
With something like the following, the GraphQL API, Subscriptions, and Playground will be mounted and can be tested via this PR:
./bin/parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --liveQuery '{"classNames": ["MyClass"]}' --mountGraphQL --mountSubscriptions --mountPlayground
It is still a work in progress. We need to improve the where input (since most of operations are not available at Live Query), and test/improve the node/originalNode output. We still need to create/fix test-cases.
But overall it is working and can be tested.
@Moumouls any feedback?
TODOs before merging