graphql-streaming 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2997980ed238638983e004e2291f16a5c5b4539c
4
- data.tar.gz: 6f8e53cc1153a79f6560fc60a266b12f04e6d52e
3
+ metadata.gz: 8470b0d8e856800e46762341df29cc293dd3b90b
4
+ data.tar.gz: 7937410284b81b2ed5309fecf96c01565b8fc6b2
5
5
  SHA512:
6
- metadata.gz: 4f020c2238d33f5fb86ef144b14630baad9ea458535eb40465a0b7839c08b5fa68962e4097fc0e70efef18f1e79d1effab0e31ef58852092d133f411acec6b30
7
- data.tar.gz: 98bc9d602d0cd84fa266f1e844e8840abdff20ed133c58c8a2a71c2af16fdacf215beb01300f4a18cbf4e5333d45cf4a4469f9e9e589fce9ce8d3d08dac62a47
6
+ metadata.gz: 4b3c2d045fef16543b027093fb0b3457a9e5316b9c0ffd75fca8130a1edcf519349d3fcd8d8e8ecdf2fd73c53c007c3c72a08d04e3d717b3320e5bb18850d8de
7
+ data.tar.gz: 6fec853215152b4218adb7dc58056fb3fad25eff4e4065cd7a0314ca9f65d856e4a81c103b236255bf88690871766c189813d2dd1d9fbd9c425558e8eae392fe
data/README.md CHANGED
@@ -90,7 +90,7 @@ class GraphqlChannel < ApplicationCable::Channel
90
90
 
91
91
  def fetch(data)
92
92
  query_string = data["query"]
93
- variables = ensure_hash(data["variables"] || {})
93
+ variables = JSON.parse(data["variables"] || "{}")
94
94
  context = {
95
95
  # ...
96
96
  }
@@ -105,7 +105,7 @@ class GraphqlChannel < ApplicationCable::Channel
105
105
  merged_ctx = context.merge(stream_ctx)
106
106
  # don't forget to prevent stale data
107
107
  merged_ctx[:current_user].reload
108
- GraphQL.execute(query_string, variables: variables, context: merged_ctx)
108
+ MySchema.execute(query_string, variables: variables, context: merged_ctx)
109
109
  end
110
110
  end
111
111
  end
@@ -191,7 +191,7 @@ SubscriptionType = GraphQL::ObjectType.define do
191
191
  end
192
192
  end
193
193
 
194
- MySchema = GraphQL::Schema.new(subscription: SubscriptionType ...)
194
+ MySchema = GraphQL::Schema.define(subscription: SubscriptionType ...)
195
195
  ```
196
196
 
197
197
  #### Triggers
@@ -244,6 +244,7 @@ No further patches will be sent to the client.
244
244
 
245
245
  - What happens to subscriptions when you redeploy or ActionCable loses its connection? Need to handle reconnecting in some way.
246
246
  - Handle errors in subscriber block
247
+ - For a streamed / defered query, we need a way to know when it's done
247
248
  - Tests for JS?
248
249
  - Other platforms (Pusher, HTTP/2)?
249
250
  - Request features from ActionCable
@@ -11,6 +11,7 @@ module GraphQL
11
11
 
12
12
  # Stop streams which were captured from stream_from
13
13
  def stop_specific_streams(streams_to_stop)
14
+ @_streams ||= []
14
15
  @_streams -= streams_to_stop
15
16
  streams_to_stop.each do |broadcasting, callback|
16
17
  pubsub.unsubscribe broadcasting, callback
@@ -11,6 +11,17 @@ var GraphQLChannel = {
11
11
  },
12
12
 
13
13
  subscription: {
14
+ _backlog: [],
15
+
16
+ // Handle any queries set up before the channel was ready
17
+ connected: function() {
18
+ this._graphQLReady = true
19
+ var _this = this
20
+ this._backlog.forEach(function(req) {
21
+ _this.logOrPerform(req[0], req[1])
22
+ })
23
+ },
24
+
14
25
  // Called by server-sent events
15
26
  received: function(data) {
16
27
  GraphQLChannel.log("[GraphQLChannel received]", data)
@@ -36,7 +47,7 @@ var GraphQLChannel = {
36
47
  GraphQLChannel.registry.set(queryId, onResponse)
37
48
 
38
49
  GraphQLChannel.log("[GraphQLChannel sending]", queryString, variables, queryId)
39
- this.perform("fetch", {
50
+ this.logOrPerform("fetch", {
40
51
  query: queryString,
41
52
  variables: JSON.stringify(variables),
42
53
  query_id: queryId,
@@ -55,8 +66,16 @@ var GraphQLChannel = {
55
66
  clear: function(queryId) {
56
67
  GraphQLChannel.log("[GraphQLChannel clearing]", queryId)
57
68
  GraphQLChannel.registry.unset(queryId)
58
- this.perform("clear", {query_id: queryId})
59
- }
69
+ this.logOrPerform("clear", {query_id: queryId})
70
+ },
71
+
72
+ logOrPerform(operation, params) {
73
+ if (this._graphQLReady) {
74
+ this.perform(operation, params)
75
+ } else {
76
+ this._backlog.push([operation, params])
77
+ }
78
+ },
60
79
  },
61
80
 
62
81
  // This registry keeps track of outstanding requests
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Streaming
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-streaming
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-17 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql