README.md in graphql-streaming-0.2.0 vs README.md in graphql-streaming-0.3.0
- old
+ new
@@ -88,11 +88,11 @@
class GraphqlChannel < ApplicationCable::Channel
include GraphQL::Streaming::ActionCableChannel
def fetch(data)
query_string = data["query"]
- variables = ensure_hash(data["variables"] || {})
+ variables = JSON.parse(data["variables"] || "{}")
context = {
# ...
}
# Get the query ID, which is added by the GraphQLChannel client
@@ -103,11 +103,11 @@
# the block provides a subscriber and collector,
# merge them into your context:
merged_ctx = context.merge(stream_ctx)
# don't forget to prevent stale data
merged_ctx[:current_user].reload
- GraphQL.execute(query_string, variables: variables, context: merged_ctx)
+ MySchema.execute(query_string, variables: variables, context: merged_ctx)
end
end
end
```
@@ -189,11 +189,11 @@
Post.find(args[:id])
}
end
end
-MySchema = GraphQL::Schema.new(subscription: SubscriptionType ...)
+MySchema = GraphQL::Schema.define(subscription: SubscriptionType ...)
```
#### Triggers
From your application, you can trigger events on subscription fields. For example, to tell clients that a Post with a given ID changed:
@@ -242,9 +242,10 @@
## TODO
- What happens to subscriptions when you redeploy or ActionCable loses its connection? Need to handle reconnecting in some way.
- Handle errors in subscriber block
+- For a streamed / defered query, we need a way to know when it's done
- Tests for JS?
- Other platforms (Pusher, HTTP/2)?
- Request features from ActionCable
- Public alternative to `@channel.send(:transmit, payload)`?
- Some way to stop certain streams (see monkey patches in action_cable_channel.rb)