graphql 1.12.14 → 1.12.15

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: 74f73ae15eae0c31b63558b5d038091006422534ebee13cafe25b0fe07d1349a
4
- data.tar.gz: c6f454d12ae887420e98f4e0563d74d7bedfa350d6b6dcd66beedd43e9cd5f5a
3
+ metadata.gz: f858de6eaac686676c159e87ae2f200b6c69b9b6c1da8e7459595b49f4f44e7a
4
+ data.tar.gz: afd8686f7897896919bef91076285f0763e49076759036352bd212d41c1bb47f
5
5
  SHA512:
6
- metadata.gz: 333b8424cc0c6cf3caccf68b27a66bd555311255a83fd336b8ccd569edf6ab4020bb3459b7ce1c0ab26542f003cd12e7c3d312d8ea45c6c2d52fe81a94471536
7
- data.tar.gz: e31d1e33bd7da992d866749f53fe05e417ac27ee6488d0bd7d5cf0e7316e57c6bec6154f496e09eb87eb830b8540eb1ecebde1384f50d7deb41244fdc07dc5b9
6
+ metadata.gz: 6774f423bdf61cf07d842ca00f517068139a86da2d6e0d6b7e15e7970aaf5ce1b07e58d78c0a13a1ccf0a8db87c48d4061e151ca42bc21731e26958ef96ad922
7
+ data.tar.gz: 31ca7b94bacf8df5a8c27c0e3c2f831362970e49c65c8b0a284095c1bd392af26347cecc78e60dc91ff4581a9a3d55dc08204eb0230ed641f2907e009a4f7f3e
@@ -7,6 +7,7 @@ module GraphQL
7
7
  super
8
8
  @used_fields = Set.new
9
9
  @used_deprecated_fields = Set.new
10
+ @used_deprecated_arguments = Set.new
10
11
  end
11
12
 
12
13
  def on_leave_field(node, parent, visitor)
@@ -14,14 +15,36 @@ module GraphQL
14
15
  field = "#{visitor.parent_type_definition.graphql_name}.#{field_defn.graphql_name}"
15
16
  @used_fields << field
16
17
  @used_deprecated_fields << field if field_defn.deprecation_reason
18
+
19
+ extract_deprecated_arguments(visitor.query.arguments_for(node, visitor.field_definition).argument_values)
17
20
  end
18
21
 
19
22
  def result
20
23
  {
21
24
  used_fields: @used_fields.to_a,
22
- used_deprecated_fields: @used_deprecated_fields.to_a
25
+ used_deprecated_fields: @used_deprecated_fields.to_a,
26
+ used_deprecated_arguments: @used_deprecated_arguments.to_a,
23
27
  }
24
28
  end
29
+
30
+ private
31
+
32
+ def extract_deprecated_arguments(argument_values)
33
+ argument_values.each_pair do |_argument_name, argument|
34
+ if argument.definition.deprecation_reason
35
+ @used_deprecated_arguments << argument.definition.path
36
+ end
37
+
38
+ if argument.definition.type.kind.input_object?
39
+ extract_deprecated_arguments(argument.value.arguments.argument_values)
40
+ elsif argument.definition.type.list?
41
+ argument
42
+ .value
43
+ .select { |value| value.respond_to?(:arguments) }
44
+ .each { |value| extract_deprecated_arguments(value.arguments.argument_values) }
45
+ end
46
+ end
47
+ end
25
48
  end
26
49
  end
27
50
  end
@@ -95,6 +95,14 @@ module GraphQL
95
95
  @action_cable = action_cable
96
96
  @action_cable_coder = action_cable_coder
97
97
  @serializer = serializer
98
+ @serialize_with_context = case @serializer.method(:load).arity
99
+ when 1
100
+ false
101
+ when 2
102
+ true
103
+ else
104
+ raise ArgumentError, "#{@serializer} must repond to `.load` accepting one or two arguments"
105
+ end
98
106
  @transmit_ns = namespace
99
107
  super
100
108
  end
@@ -154,7 +162,7 @@ module GraphQL
154
162
  # so just run it once, then deliver the result to every subscriber
155
163
  first_event = events.first
156
164
  first_subscription_id = first_event.context.fetch(:subscription_id)
157
- object ||= @serializer.load(message)
165
+ object ||= load_action_cable_message(message, first_event.context)
158
166
  result = execute_update(first_subscription_id, first_event, object)
159
167
  # Having calculated the result _once_, send the same payload to all subscribers
160
168
  events.each do |event|
@@ -167,6 +175,18 @@ module GraphQL
167
175
  end
168
176
  end
169
177
 
178
+ # This is called to turn an ActionCable-broadcasted string (JSON)
179
+ # into a query-ready application object.
180
+ # @param message [String] n ActionCable-broadcasted string (JSON)
181
+ # @param context [GraphQL::Query::Context] the context of the first event for a given subscription fingerprint
182
+ def load_action_cable_message(message, context)
183
+ if @serialize_with_context
184
+ @serializer.load(message, context)
185
+ else
186
+ @serializer.load(message)
187
+ end
188
+ end
189
+
170
190
  # Return the query from "storage" (in memory)
171
191
  def read_subscription(subscription_id)
172
192
  query = @subscriptions[subscription_id]
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.12.14"
3
+ VERSION = "1.12.15"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.14
4
+ version: 1.12.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-22 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -318,8 +318,6 @@ files:
318
318
  - lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb
319
319
  - lib/graphql/compatibility/query_parser_specification/query_assertions.rb
320
320
  - lib/graphql/compatibility/schema_parser_specification.rb
321
- - lib/graphql/cop/nullability.rb
322
- - lib/graphql/cop/resolve_methods.rb
323
321
  - lib/graphql/dataloader.rb
324
322
  - lib/graphql/dataloader/null_dataloader.rb
325
323
  - lib/graphql/dataloader/request.rb
@@ -1,28 +0,0 @@
1
- require "rubocop"
2
-
3
- module GraphQL
4
- module Cop
5
- class Nullability < RuboCop::Cop::Base
6
- extend AutoCorrector
7
-
8
- NEEDLESS_NULL_FALSE = <<-ERR
9
- `null: false` is the default, it can be removed.
10
- ERR
11
-
12
- NEEDLESS_REQUIRED_TRUE = <<-ERR
13
- `required: true` is the default, it can be removed.
14
- ERR
15
-
16
- def on_send(node)
17
- recv, method_name, args = *node
18
- if recv.nil?
19
- if method_name == :field
20
-
21
- elsif method_name == :argument
22
-
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,28 +0,0 @@
1
- require "rubocop"
2
-
3
- module GraphQL
4
- module Cop
5
- class ResolveMethods < RuboCop::Cop::Base
6
- extend AutoCorrector
7
-
8
- NEEDLESS_NULL_FALSE = <<-ERR
9
- `null: false` is the default, it can be removed.
10
- ERR
11
-
12
- NEEDLESS_REQUIRED_TRUE = <<-ERR
13
- `required: true` is the default, it can be removed.
14
- ERR
15
-
16
- def on_send(node)
17
- recv, method_name, args = *node
18
- if recv.nil?
19
- if method_name == :field
20
-
21
- elsif method_name == :argument
22
-
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end