rack-graphql 0.5.2 → 0.6.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
  SHA256:
3
- metadata.gz: 989cdc3ccedf81d8514c8ed22a67b0fab40a7fa19d36d07b1d5509ee219eb1c4
4
- data.tar.gz: 603d79522b37fcbda3e688e973d825be1aad1123ee56ad28debaef75f4ae3634
3
+ metadata.gz: eb088c288a3e2fda3f114d31b769a48869e2acb81822ca68b916a46e7702d6f6
4
+ data.tar.gz: 4e24c3b8d96246abe38b41ac773dac0ca5f2a29e4fb01edb65f87364056f47ad
5
5
  SHA512:
6
- metadata.gz: 40453f254444b0fd15e88d37449f7b6d9cf213cf977738acbe1192b117980e3ba7ec60c270b30983c2f79b239cacd722cf327d63bd2db6695f93fc60f3b75e3e
7
- data.tar.gz: 906335f3a297b4d0ef5052b5dfc9ad58c90d4e2639c50ee9a4d238e0ac9815922d7d46b3c255bc7f1e9f1790d4596fb5ecf07d4482c428978841550f825d7752
6
+ metadata.gz: 8f2ae69e4e062ecc073c26e6602c146d0a2ecc1421a4a13efc2cbd2704f29faede0c19437a4a8caf43b7f442accc2deb29823c2ca5c53e7ce8f70f53ed06954e
7
+ data.tar.gz: 99f0ca2ba3a3c441475902ac41c02ff5a822e3355d0d7386b535277a5d44f7882f9979b7fb18f8adaaa57fced2c958db60110945375d0b05b80a72ffd5b2b3e4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-graphql (0.5.2)
4
+ rack-graphql (0.6.0)
5
5
  graphql (>= 1.9.0)
6
6
  multi_json
7
7
  rack (>= 2.0.0)
@@ -12,7 +12,7 @@ GEM
12
12
  ast (2.4.0)
13
13
  coderay (1.1.2)
14
14
  diff-lcs (1.3)
15
- graphql (1.9.7)
15
+ graphql (1.9.8)
16
16
  jaro_winkler (1.5.3)
17
17
  method_source (0.9.2)
18
18
  multi_json (1.13.1)
@@ -15,7 +15,7 @@ module RackGraphql
15
15
 
16
16
  result = execute(params: params, operation_name: operation_name, variables: variables, context: context)
17
17
 
18
- [200, response_headers(result), [MultiJson.dump(result)]]
18
+ [200, response_headers(result), [response_body(result)]]
19
19
  rescue ArgumentError
20
20
  [400, { 'Content-Type' => 'application/json' }, [MultiJson.dump({})]]
21
21
  ensure
@@ -94,6 +94,18 @@ module RackGraphql
94
94
  end
95
95
  end
96
96
 
97
+ def response_body(result = nil)
98
+ if result_subscription?(result)
99
+ body = result.to_h
100
+ body["data"] ||= {}
101
+ body["data"][result.query.operation_name] ||= nil
102
+ body["data"]["subscriptionId"] = result.context[:subscription_id]
103
+ else
104
+ body = result
105
+ end
106
+ MultiJson.dump(body)
107
+ end
108
+
97
109
  def result_subscription?(result)
98
110
  return false unless result.is_a?(GraphQL::Query::Result)
99
111
 
@@ -1,3 +1,3 @@
1
1
  module RackGraphql
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-07-23 00:00:00.000000000 Z
12
+ date: 2019-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql