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

feat(Subscriptions) add subscriptions #672

Merged
merged 35 commits into from
Sep 14, 2017
Merged

feat(Subscriptions) add subscriptions #672

merged 35 commits into from
Sep 14, 2017

Conversation

rmosolgo
Copy link
Owner

@rmosolgo rmosolgo commented Apr 11, 2017

Let's support GraphQL Subscriptions in Ruby!

Some library changes are required:

  • Special behavior for executing subscriptions:
    • On the first execution, no fields are executed. Instead, each root field + arguments pair is registered with the subscription backend.
    • On later executions, only root field + argument pairs which match the triggered event are executed. The root value for that execution is an application-provided object. (eg, if commentAdded is triggered, the root object is the Comment provided by the application.)
    • Add Query::Result to simplify re-evaluation feat(Query::Result) add a first-class result object #898

My implementation has made an assumption about how root fields map to application events:

event_key = "#{field.name}(#{JSON.dump(args.to_h)})"
# commentAdded({"postId":1})

Is this sufficient for capturing the "unit of subscription"? Or does it miss some cases?

See the guides in this PR for documentation.


Working demo: https://gist.github.com/rmosolgo/ba31acf93f07f8007d99ba365a662d8f

@rmosolgo rmosolgo mentioned this pull request Apr 17, 2017
@rmosolgo rmosolgo changed the title feat(Subscriptions) add subscription convention feat(Subscriptions) add subscriptions Apr 21, 2017
@rmosolgo rmosolgo changed the base branch from master to 1.6.x April 22, 2017 14:12
@rmosolgo rmosolgo added this to the 1.6.0 milestone Apr 27, 2017
@rmosolgo rmosolgo modified the milestones: 1.7.0, 1.6.0 May 17, 2017
@rmosolgo rmosolgo force-pushed the 1.6.x branch 2 times, most recently from 25b3a75 to f27cf09 Compare May 27, 2017 12:02
@rmosolgo rmosolgo changed the base branch from 1.6.x to 1.7.dev June 10, 2017 19:00
@rmosolgo rmosolgo force-pushed the subscriptions branch 2 times, most recently from 37120e8 to 41f96e5 Compare August 5, 2017 19:14
@rmosolgo
Copy link
Owner Author

rmosolgo commented Aug 8, 2017

Feature-wise I think this is ready, but as I write the docs, I think the API can be better. Something more ... object-oriented 🙀

@rmosolgo rmosolgo closed this Aug 10, 2017
@rmosolgo rmosolgo changed the base branch from 1.7.dev to 1.7.x August 10, 2017 01:45
@rmosolgo rmosolgo reopened this Aug 10, 2017
@rmosolgo
Copy link
Owner Author

Working on an ActionCable client rmosolgo/graphql-ruby-client#2

@blevine
Copy link

blevine commented Sep 11, 2017

@rmosolgo Not quite sure what the status of subscription support is at this point. Would I be able to pull the 1.7.0 branch to start implementing subscriptions now?

@rmosolgo
Copy link
Owner Author

@blevine not yet, i'm hoping to merge this into 1.7 today

@rmosolgo rmosolgo merged commit d938acf into 1.7.x Sep 14, 2017
@rmosolgo
Copy link
Owner Author

Here goes nothin! Feel free to take the 1.7 branch for a spin.

@rmosolgo rmosolgo deleted the subscriptions branch September 14, 2017 13:49
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