-
Notifications
You must be signed in to change notification settings - Fork 73
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
Feature/subscription support #173
Feature/subscription support #173
Conversation
d119860
to
600c9ab
Compare
600c9ab
to
0f70ffb
Compare
7dff8a2
to
83074c5
Compare
@bgentry would love your thoughts on a few things, in particular here:
Thanks! |
Hey! This PR solves the problem I'm having with this library. Is there any timeline on when this will be looked at, or should I use a fork? @bgentry |
Hey @coladarci, thank you for the work on this! I tried this PR and I am running in to the issue that apparently Am I missing something? |
Thanks for taking a look! Eek - my Readme was wrong! My "real life" example looks like this:
I will update the docs.... Appears the tests were also doing it but because of the heavy stubbing it wasn't causing any problems. I will update those as well! |
What's the status of this PR? Would love to see subscriptions land soon! 🤞 |
@ynnoj biggest help would be probably to point to my fork, follow the readme and see if there’s anything that be improved.. if it works out of the box and you’re thrilled, it’ll probably help push this through. |
I'm trying to use your example but I'm getting an error about markSubscriptionsStale not being a function. |
@ekristen thanks for giving it a try - can you provide a little more? Stacktrace? A little more about your implementation? |
Ember is still pretty new to me, I tried implementing as little as possible. I have it working sans subscriptions. I just tried copying what was in the readme into a route for the most part.
|
Can you try removing For more context, what this library does is a little confusing to be honest - the base query manager MIXIN that you add to your route adds the following for you:
Notice how SO, you going in and overriding |
Removed the service, I'm really new to ember, if there's a full simple working example that would be best. I just started looking at the docs and what examples I could find to piece things together. I don't get the error anymore, but I don't see any subscriptions happening. I'll dig a bit more and see what I am doing wrong. |
My assumption is you never called the setup function you defined above.. can add this.setupSubscription() into your model hook? |
This?
|
Yup provided you imported that subscription you are using at the top of your file |
I did, but I get an error.
|
OK - I think I know what's going on, and I think it's an issue w/ the docs - thanks for your patience.. I've updated the docs accordingly. The issue is:
While ember provides a ton of ways to do that, the simplest is to probably invoke the
If you want your model to return multiple things, ember helps w/ that:
|
Is it always on event? I have everything working rendering now, but I'm not getting any events, so just trying to troubleshoot. |
Assuming your server is publishing them - did you do all the channel stuff in the readme to setup your websockets? |
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.
Looks great overall! 👏
Main issues are some syntax/styling things to stay consistent. Other than that, if folks can confirm this is working well, I'd love to get this merged and released ASAP!
README.md
Outdated
|
||
`my-app/gql/subscription/new-human` | ||
|
||
``` |
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.
can you add gql
after the triple backticks so this gets syntax highlighting?
@coladarci I got further but now event is being reported as |
@ekristen can you clarify what you mean by "reported"? can you paste the code that is reading out the event? |
nevermind, I found the problem. |
nevermind I didn't but I'm giving up, it's taking too much time to figure out why this lib isn't working. @bgentry did you get it working? |
@ekristen I am very interested in understanding why you aren't getting what you are expecting. This is working quite well for us and it'd be a shame to not get you over the finish line given how much time we've spent |
I'm determined to make this work. QQ, is there a way to use this outside a model? Like application controller to listen to a specific subscription all the time? |
I'm assuming you mean "Outside the model hook of a route?". In which case, yes, absolutely. The reason I suggested the As far as specifically putting this in a Does this help? |
Any plans on merging this PR soon? I have tested subscriptions inside a service and it works like a charm. However, I have noticed some issues with the documentation:
Btw, we are using a backend with apollo server. It maybe would seem more natural to have such an example within the section "Enabling Websockets" than the provided "Phoenix + Absinthe" example. |
Thank you @ChristianEllerbrock ! So glad to hear it worked for you. I've updated the docs as per your feedback. Elixir has sufficiently trained me to never use single quotes :) As far as your |
I was partly waiting for a 2nd user to confirm that this was working well for them, thanks @ChristianEllerbrock ! Merging now, will release once CI completes. Thanks @coladarci ! ✌️ |
Built-in support for subscriptions.
#4
init
chainAllow clients to submit subscription requests and get, in response, a
EmberApolloSubscription
which the client can use in a few ways:subscription.on('event', data => do_something(data))
<-- act on this event in some waysubscription.lastEvent
<-- this will be the most recently received event payload