graphql-client 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82a2932b4b6e2c7a9bda10a683f88835c6e21a2c
4
- data.tar.gz: c01bfc95eee130530808e40a3c83b32f2a3dcb0c
3
+ metadata.gz: 5a3719a5d2029f941778b24cd87f72a79fefc1d8
4
+ data.tar.gz: 3698a12695761dba8645fc0d7d9379d46afe3f76
5
5
  SHA512:
6
- metadata.gz: 541ce88dda647e3a7f38240d3f53144a5fd2b0739b70b514016419db8d1edb036dd8e8f3fa431f73943dc309e6c818cd7be6bb0f2182515b98e3cf9201439f27
7
- data.tar.gz: f612df0408bfdfdef608faf5edc01869c8bad3dc05787c6942bf1db7902bdc3f903d4d5cd9b4d7d45499a936a4e43e6aa83c4a1f6e9109b49bad5ff513e46302
6
+ metadata.gz: f37c34289022b6b7e73c5b547a404bed7d02c068e48913abea61021e420311a03ac1ff233fbc01cf0c2d40589d63536091467248b014435ba1f0fa653d4c9438
7
+ data.tar.gz: 18d6685fa2b2e20340d8844dbb6d2e30f6049d4bcc2341561047fbd65749db0143c7e12aec4788b85b91018fba0090e96697b6e91e5987cffa4304f6a27772c7
@@ -1,4 +1,5 @@
1
1
  require "active_support/inflector"
2
+ require "active_support/notifications"
2
3
  require "graphql"
3
4
  require "graphql/client/query_result"
4
5
  require "graphql/language/nodes/deep_freeze_ext"
@@ -226,8 +227,16 @@ module GraphQL
226
227
  raise Error, "client network fetching not configured"
227
228
  end
228
229
 
229
- document = definition.document
230
- result = fetch.call(document, definition.operation_name, variables, context)
230
+ payload = {
231
+ document: definition.document,
232
+ operation_name: definition.operation_name,
233
+ operation_type: definition.definition_node.operation_type,
234
+ variables: variables
235
+ }
236
+ result = ActiveSupport::Notifications.instrument("query.graphql", payload) do
237
+ fetch.call(definition.document, definition.operation_name, variables, context)
238
+ end
239
+
231
240
  data, errors, extensions = result.values_at("data", "errors", "extensions")
232
241
 
233
242
  if data && errors
@@ -0,0 +1,14 @@
1
+ require "active_support/log_subscriber"
2
+
3
+ module GraphQL
4
+ class Client
5
+ class LogSubscriber < ActiveSupport::LogSubscriber
6
+ def query(event)
7
+ info { "#{event.payload[:name]} (#{event.duration.round(1)}ms) #{event.payload[:operation_name].gsub("__", "::")}" }
8
+ debug { event.payload[:document].to_query_string }
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ GraphQL::Client::LogSubscriber.attach_to :graphql
@@ -0,0 +1,33 @@
1
+ require "graphql"
2
+ require "graphql/client"
3
+ require "rails/railtie"
4
+
5
+ module GraphQL
6
+ class Client
7
+ class Railtie < Rails::Railtie
8
+ config.graphql = ActiveSupport::OrderedOptions.new
9
+ config.graphql.client = GraphQL::Client.new
10
+
11
+ # Eager load leaky dependency to workaround AS::Dependencies unloading issues
12
+ # https://github.com/rmosolgo/graphql-ruby/pull/240
13
+ initializer "graphql.eager_load_hack" do |app|
14
+ require "graphql"
15
+ GraphQL::BOOLEAN_TYPE.name
16
+ end
17
+
18
+ initializer "graphql.configure_erb_implementation" do |app|
19
+ require "graphql/client/erubis"
20
+ ActionView::Template::Handlers::ERB.erb_implementation = GraphQL::Client::Erubis
21
+ end
22
+
23
+ initializer "graphql.configure_views_namespace" do |app|
24
+ require "graphql/client/view_module"
25
+ Object.const_set(:Views, Module.new {
26
+ extend GraphQL::Client::ViewModule
27
+ self.path = "#{app.root}/app/views"
28
+ self.client = config.graphql.client
29
+ })
30
+ end
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
@@ -101,7 +101,9 @@ files:
101
101
  - LICENSE
102
102
  - lib/graphql/client.rb
103
103
  - lib/graphql/client/erubis.rb
104
+ - lib/graphql/client/log_subscriber.rb
104
105
  - lib/graphql/client/query_result.rb
106
+ - lib/graphql/client/railtie.rb
105
107
  - lib/graphql/client/view_module.rb
106
108
  - lib/graphql/language/nodes/deep_freeze_ext.rb
107
109
  - lib/graphql/language/operation_slice.rb