graphql 1.11.5 → 1.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/install_generator.rb +5 -5
  3. data/lib/generators/graphql/object_generator.rb +2 -0
  4. data/lib/generators/graphql/relay_generator.rb +63 -0
  5. data/lib/generators/graphql/templates/base_connection.erb +8 -0
  6. data/lib/generators/graphql/templates/base_edge.erb +8 -0
  7. data/lib/generators/graphql/templates/node_type.erb +9 -0
  8. data/lib/generators/graphql/templates/object.erb +1 -1
  9. data/lib/generators/graphql/templates/query_type.erb +1 -3
  10. data/lib/generators/graphql/templates/schema.erb +8 -35
  11. data/lib/graphql.rb +39 -4
  12. data/lib/graphql/analysis/analyze_query.rb +7 -0
  13. data/lib/graphql/analysis/ast.rb +11 -2
  14. data/lib/graphql/analysis/ast/visitor.rb +9 -1
  15. data/lib/graphql/backtrace.rb +28 -19
  16. data/lib/graphql/backtrace/legacy_tracer.rb +56 -0
  17. data/lib/graphql/backtrace/table.rb +22 -2
  18. data/lib/graphql/backtrace/tracer.rb +40 -9
  19. data/lib/graphql/backwards_compatibility.rb +2 -1
  20. data/lib/graphql/base_type.rb +1 -1
  21. data/lib/graphql/compatibility/execution_specification.rb +1 -0
  22. data/lib/graphql/compatibility/lazy_execution_specification.rb +2 -0
  23. data/lib/graphql/compatibility/query_parser_specification.rb +2 -0
  24. data/lib/graphql/compatibility/schema_parser_specification.rb +2 -0
  25. data/lib/graphql/dataloader.rb +198 -0
  26. data/lib/graphql/dataloader/null_dataloader.rb +21 -0
  27. data/lib/graphql/dataloader/request.rb +24 -0
  28. data/lib/graphql/dataloader/request_all.rb +22 -0
  29. data/lib/graphql/dataloader/source.rb +93 -0
  30. data/lib/graphql/define/assign_global_id_field.rb +2 -2
  31. data/lib/graphql/define/instance_definable.rb +32 -2
  32. data/lib/graphql/define/type_definer.rb +5 -5
  33. data/lib/graphql/deprecated_dsl.rb +7 -2
  34. data/lib/graphql/deprecation.rb +13 -0
  35. data/lib/graphql/enum_type.rb +2 -0
  36. data/lib/graphql/execution/errors.rb +4 -0
  37. data/lib/graphql/execution/execute.rb +7 -0
  38. data/lib/graphql/execution/interpreter.rb +10 -6
  39. data/lib/graphql/execution/interpreter/arguments.rb +57 -5
  40. data/lib/graphql/execution/interpreter/arguments_cache.rb +8 -0
  41. data/lib/graphql/execution/interpreter/handles_raw_value.rb +0 -7
  42. data/lib/graphql/execution/interpreter/runtime.rb +219 -117
  43. data/lib/graphql/execution/multiplex.rb +20 -6
  44. data/lib/graphql/function.rb +4 -0
  45. data/lib/graphql/input_object_type.rb +2 -0
  46. data/lib/graphql/integer_decoding_error.rb +17 -0
  47. data/lib/graphql/interface_type.rb +3 -1
  48. data/lib/graphql/internal_representation/document.rb +2 -2
  49. data/lib/graphql/internal_representation/rewrite.rb +1 -1
  50. data/lib/graphql/invalid_null_error.rb +1 -1
  51. data/lib/graphql/language/document_from_schema_definition.rb +50 -23
  52. data/lib/graphql/object_type.rb +2 -0
  53. data/lib/graphql/pagination/connection.rb +5 -1
  54. data/lib/graphql/pagination/connections.rb +15 -19
  55. data/lib/graphql/query.rb +6 -1
  56. data/lib/graphql/query/arguments.rb +1 -1
  57. data/lib/graphql/query/context.rb +8 -1
  58. data/lib/graphql/query/serial_execution.rb +1 -0
  59. data/lib/graphql/query/validation_pipeline.rb +1 -1
  60. data/lib/graphql/relay/array_connection.rb +2 -2
  61. data/lib/graphql/relay/base_connection.rb +7 -0
  62. data/lib/graphql/relay/connection_instrumentation.rb +4 -4
  63. data/lib/graphql/relay/connection_type.rb +1 -1
  64. data/lib/graphql/relay/mutation.rb +1 -0
  65. data/lib/graphql/relay/node.rb +3 -0
  66. data/lib/graphql/relay/range_add.rb +14 -5
  67. data/lib/graphql/relay/type_extensions.rb +2 -0
  68. data/lib/graphql/scalar_type.rb +2 -0
  69. data/lib/graphql/schema.rb +80 -29
  70. data/lib/graphql/schema/argument.rb +25 -7
  71. data/lib/graphql/schema/build_from_definition.rb +150 -58
  72. data/lib/graphql/schema/default_type_error.rb +2 -0
  73. data/lib/graphql/schema/directive.rb +76 -0
  74. data/lib/graphql/schema/directive/flagged.rb +57 -0
  75. data/lib/graphql/schema/enum.rb +3 -0
  76. data/lib/graphql/schema/enum_value.rb +12 -6
  77. data/lib/graphql/schema/field.rb +52 -23
  78. data/lib/graphql/schema/field/connection_extension.rb +10 -8
  79. data/lib/graphql/schema/field/scope_extension.rb +1 -1
  80. data/lib/graphql/schema/input_object.rb +33 -22
  81. data/lib/graphql/schema/interface.rb +1 -0
  82. data/lib/graphql/schema/member.rb +4 -0
  83. data/lib/graphql/schema/member/base_dsl_methods.rb +1 -0
  84. data/lib/graphql/schema/member/build_type.rb +3 -3
  85. data/lib/graphql/schema/member/has_arguments.rb +67 -50
  86. data/lib/graphql/schema/member/has_deprecation_reason.rb +25 -0
  87. data/lib/graphql/schema/member/has_directives.rb +98 -0
  88. data/lib/graphql/schema/member/has_fields.rb +2 -2
  89. data/lib/graphql/schema/member/has_validators.rb +31 -0
  90. data/lib/graphql/schema/member/type_system_helpers.rb +1 -1
  91. data/lib/graphql/schema/middleware_chain.rb +1 -1
  92. data/lib/graphql/schema/object.rb +11 -0
  93. data/lib/graphql/schema/printer.rb +5 -4
  94. data/lib/graphql/schema/relay_classic_mutation.rb +1 -1
  95. data/lib/graphql/schema/resolver.rb +7 -0
  96. data/lib/graphql/schema/resolver/has_payload_type.rb +2 -0
  97. data/lib/graphql/schema/subscription.rb +19 -1
  98. data/lib/graphql/schema/timeout_middleware.rb +3 -1
  99. data/lib/graphql/schema/unique_within_type.rb +1 -2
  100. data/lib/graphql/schema/validation.rb +4 -2
  101. data/lib/graphql/schema/validator.rb +163 -0
  102. data/lib/graphql/schema/validator/exclusion_validator.rb +31 -0
  103. data/lib/graphql/schema/validator/format_validator.rb +49 -0
  104. data/lib/graphql/schema/validator/inclusion_validator.rb +33 -0
  105. data/lib/graphql/schema/validator/length_validator.rb +57 -0
  106. data/lib/graphql/schema/validator/numericality_validator.rb +71 -0
  107. data/lib/graphql/schema/validator/required_validator.rb +68 -0
  108. data/lib/graphql/static_validation.rb +1 -0
  109. data/lib/graphql/static_validation/all_rules.rb +1 -0
  110. data/lib/graphql/static_validation/rules/fields_will_merge.rb +25 -17
  111. data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +30 -0
  112. data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +30 -0
  113. data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
  114. data/lib/graphql/static_validation/validator.rb +32 -9
  115. data/lib/graphql/subscriptions.rb +17 -20
  116. data/lib/graphql/subscriptions/subscription_root.rb +1 -1
  117. data/lib/graphql/tracing.rb +2 -2
  118. data/lib/graphql/tracing/appoptics_tracing.rb +3 -1
  119. data/lib/graphql/tracing/platform_tracing.rb +4 -2
  120. data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +4 -1
  121. data/lib/graphql/tracing/skylight_tracing.rb +1 -1
  122. data/lib/graphql/types/int.rb +9 -2
  123. data/lib/graphql/types/relay.rb +11 -3
  124. data/lib/graphql/types/relay/base_connection.rb +2 -91
  125. data/lib/graphql/types/relay/base_edge.rb +2 -34
  126. data/lib/graphql/types/relay/connection_behaviors.rb +123 -0
  127. data/lib/graphql/types/relay/default_relay.rb +27 -0
  128. data/lib/graphql/types/relay/edge_behaviors.rb +42 -0
  129. data/lib/graphql/types/relay/has_node_field.rb +41 -0
  130. data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
  131. data/lib/graphql/types/relay/node.rb +2 -4
  132. data/lib/graphql/types/relay/node_behaviors.rb +15 -0
  133. data/lib/graphql/types/relay/node_field.rb +1 -19
  134. data/lib/graphql/types/relay/nodes_field.rb +1 -19
  135. data/lib/graphql/types/relay/page_info.rb +2 -14
  136. data/lib/graphql/types/relay/page_info_behaviors.rb +25 -0
  137. data/lib/graphql/types/string.rb +7 -1
  138. data/lib/graphql/unauthorized_error.rb +1 -1
  139. data/lib/graphql/union_type.rb +2 -0
  140. data/lib/graphql/upgrader/member.rb +1 -0
  141. data/lib/graphql/upgrader/schema.rb +1 -0
  142. data/lib/graphql/version.rb +1 -1
  143. data/readme.md +1 -1
  144. metadata +50 -6
  145. data/lib/graphql/types/relay/base_field.rb +0 -22
  146. data/lib/graphql/types/relay/base_interface.rb +0 -29
  147. data/lib/graphql/types/relay/base_object.rb +0 -26
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GraphQL
4
+ class Schema
5
+ class Validator
6
+ # Use this validator to require _one_ of the named arguments to be present.
7
+ # Or, use Arrays of symbols to name a valid _set_ of arguments.
8
+ #
9
+ # (This is for specifying mutually exclusive sets of arguments.)
10
+ #
11
+ # @example Require exactly one of these arguments
12
+ #
13
+ # field :update_amount, IngredientAmount, null: false do
14
+ # argument :ingredient_id, ID, required: true
15
+ # argument :cups, Integer, required: false
16
+ # argument :tablespoons, Integer, required: false
17
+ # argument :teaspoons, Integer, required: true
18
+ # validates required: { one_of: [:cups, :tablespoons, :teaspoons] }
19
+ # end
20
+ #
21
+ # @example Require one of these _sets_ of arguments
22
+ #
23
+ # field :find_object, Node, null: true do
24
+ # argument :node_id, ID, required: false
25
+ # argument :object_type, String, required: false
26
+ # argument :object_id, Integer, required: false
27
+ # # either a global `node_id` or an `object_type`/`object_id` pair is required:
28
+ # validates required: { one_of: [:node_id, [:object_type, :object_id]] }
29
+ # end
30
+ #
31
+ class RequiredValidator < Validator
32
+ # @param one_of [Symbol, Array<Symbol>] An argument, or a list of arguments, that represents a valid set of inputs for this field
33
+ # @param message [String]
34
+ def initialize(one_of:, message: "%{validated} has the wrong arguments", **default_options)
35
+ @one_of = one_of
36
+ @message = message
37
+ super(**default_options)
38
+ end
39
+
40
+ def validate(_object, _context, value)
41
+ matched_conditions = 0
42
+
43
+ @one_of.each do |one_of_condition|
44
+ case one_of_condition
45
+ when Symbol
46
+ if value.key?(one_of_condition)
47
+ matched_conditions += 1
48
+ end
49
+ when Array
50
+ if one_of_condition.all? { |k| value.key?(k) }
51
+ matched_conditions += 1
52
+ break
53
+ end
54
+ else
55
+ raise ArgumentError, "Unknown one_of condition: #{one_of_condition.inspect}"
56
+ end
57
+ end
58
+
59
+ if matched_conditions == 1
60
+ nil # OK
61
+ else
62
+ @message
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -4,6 +4,7 @@ require "graphql/static_validation/definition_dependencies"
4
4
  require "graphql/static_validation/type_stack"
5
5
  require "graphql/static_validation/validator"
6
6
  require "graphql/static_validation/validation_context"
7
+ require "graphql/static_validation/validation_timeout_error"
7
8
  require "graphql/static_validation/literal_validator"
8
9
  require "graphql/static_validation/base_visitor"
9
10
  require "graphql/static_validation/no_validate_visitor"
@@ -34,6 +34,7 @@ module GraphQL
34
34
  GraphQL::StaticValidation::VariableUsagesAreAllowed,
35
35
  GraphQL::StaticValidation::MutationRootExists,
36
36
  GraphQL::StaticValidation::SubscriptionRootExists,
37
+ GraphQL::StaticValidation::InputObjectNamesAreUnique,
37
38
  ]
38
39
  end
39
40
  end
@@ -202,15 +202,16 @@ module GraphQL
202
202
  )
203
203
  end
204
204
 
205
- args = possible_arguments(node1, node2)
206
- if args.size > 1
207
- msg = "Field '#{response_key}' has an argument conflict: #{args.map { |arg| GraphQL::Language.serialize(arg) }.join(" or ")}?"
205
+ if !same_arguments?(node1, node2)
206
+ args = [serialize_field_args(node1), serialize_field_args(node2)]
207
+ conflicts = args.map { |arg| GraphQL::Language.serialize(arg) }.join(" or ")
208
+ msg = "Field '#{response_key}' has an argument conflict: #{conflicts}?"
208
209
  context.errors << GraphQL::StaticValidation::FieldsWillMergeError.new(
209
210
  msg,
210
211
  nodes: [node1, node2],
211
212
  path: [],
212
213
  field_name: response_key,
213
- conflicts: args.map { |arg| GraphQL::Language.serialize(arg) }.join(" or ")
214
+ conflicts: conflicts
214
215
  )
215
216
  end
216
217
  end
@@ -326,20 +327,19 @@ module GraphQL
326
327
  [fields, fragment_spreads]
327
328
  end
328
329
 
329
- def possible_arguments(field1, field2)
330
+ def same_arguments?(field1, field2)
330
331
  # Check for incompatible / non-identical arguments on this node:
331
- [field1, field2].map do |n|
332
- if n.arguments.any?
333
- serialized_args = {}
334
- n.arguments.each do |a|
335
- arg_value = a.value
336
- serialized_args[a.name] = serialize_arg(arg_value)
337
- end
338
- serialized_args
339
- else
340
- NO_ARGS
341
- end
342
- end.uniq
332
+ arguments1 = field1.arguments
333
+ arguments2 = field2.arguments
334
+
335
+ return false if arguments1.length != arguments2.length
336
+
337
+ arguments1.all? do |argument1|
338
+ argument2 = arguments2.find { |argument| argument.name == argument1.name }
339
+ return false if argument2.nil?
340
+
341
+ serialize_arg(argument1.value) == serialize_arg(argument2.value)
342
+ end
343
343
  end
344
344
 
345
345
  def serialize_arg(arg_value)
@@ -353,6 +353,14 @@ module GraphQL
353
353
  end
354
354
  end
355
355
 
356
+ def serialize_field_args(field)
357
+ serialized_args = {}
358
+ field.arguments.each do |argument|
359
+ serialized_args[argument.name] = serialize_arg(argument.value)
360
+ end
361
+ serialized_args
362
+ end
363
+
356
364
  def compared_fragments_key(frag1, frag2, exclusive)
357
365
  # Cache key to not compare two fragments more than once.
358
366
  # The key includes both fragment names sorted (this way we
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ module GraphQL
3
+ module StaticValidation
4
+ module InputObjectNamesAreUnique
5
+ def on_input_object(node, parent)
6
+ validate_input_fields(node)
7
+ super
8
+ end
9
+
10
+ private
11
+
12
+ def validate_input_fields(node)
13
+ input_field_defns = node.arguments
14
+ input_fields_by_name = Hash.new { |h, k| h[k] = [] }
15
+ input_field_defns.each { |a| input_fields_by_name[a.name] << a }
16
+
17
+ input_fields_by_name.each do |name, defns|
18
+ if defns.size > 1
19
+ error = GraphQL::StaticValidation::InputObjectNamesAreUniqueError.new(
20
+ "There can be only one input field named \"#{name}\"",
21
+ nodes: defns,
22
+ name: name
23
+ )
24
+ add_error(error)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ module GraphQL
3
+ module StaticValidation
4
+ class InputObjectNamesAreUniqueError < StaticValidation::Error
5
+ attr_reader :name
6
+
7
+ def initialize(message, path: nil, nodes: [], name:)
8
+ super(message, path: path, nodes: nodes)
9
+ @name = name
10
+ end
11
+
12
+ # A hash representation of this Message
13
+ def to_h
14
+ extensions = {
15
+ "code" => code,
16
+ "name" => name
17
+ }
18
+
19
+ super.merge({
20
+ "extensions" => extensions
21
+ })
22
+ end
23
+
24
+ def code
25
+ "inputFieldNotUnique"
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ module GraphQL
3
+ module StaticValidation
4
+ class ValidationTimeoutError < StaticValidation::Error
5
+ def initialize(message, path: nil, nodes: [])
6
+ super(message, path: path, nodes: nodes)
7
+ end
8
+
9
+ # A hash representation of this Message
10
+ def to_h
11
+ extensions = {
12
+ "code" => code
13
+ }
14
+
15
+ super.merge({
16
+ "extensions" => extensions
17
+ })
18
+ end
19
+
20
+ def code
21
+ "validationTimeout"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ require "timeout"
3
+
2
4
  module GraphQL
3
5
  module StaticValidation
4
6
  # Initialized with a {GraphQL::Schema}, then it can validate {GraphQL::Language::Nodes::Documents}s based on that schema.
@@ -20,8 +22,10 @@ module GraphQL
20
22
 
21
23
  # Validate `query` against the schema. Returns an array of message hashes.
22
24
  # @param query [GraphQL::Query]
25
+ # @param validate [Boolean]
26
+ # @param timeout [Float] Number of seconds to wait before aborting validation. Any positive number may be used, including Floats to specify fractional seconds.
23
27
  # @return [Array<Hash>]
24
- def validate(query, validate: true)
28
+ def validate(query, validate: true, timeout: nil)
25
29
  query.trace("validate", { validate: validate, query: query }) do
26
30
  can_skip_rewrite = query.context.interpreter? && query.schema.using_ast_analysis? && query.schema.is_a?(Class)
27
31
  errors = if validate == false && can_skip_rewrite
@@ -32,21 +36,31 @@ module GraphQL
32
36
 
33
37
  context = GraphQL::StaticValidation::ValidationContext.new(query, visitor_class)
34
38
 
35
- # Attach legacy-style rules.
36
- # Only loop through rules if it has legacy-style rules
37
- unless (legacy_rules = rules_to_use - GraphQL::StaticValidation::ALL_RULES).empty?
38
- legacy_rules.each do |rule_class_or_module|
39
- if rule_class_or_module.method_defined?(:validate)
40
- rule_class_or_module.new.validate(context)
39
+ begin
40
+ # CAUTION: Usage of the timeout module makes the assumption that validation rules are stateless Ruby code that requires no cleanup if process was interrupted. This means no blocking IO calls, native gems, locks, or `rescue` clauses that must be reached.
41
+ # A timeout value of 0 or nil will execute the block without any timeout.
42
+ Timeout::timeout(timeout) do
43
+ # Attach legacy-style rules.
44
+ # Only loop through rules if it has legacy-style rules
45
+ unless (legacy_rules = rules_to_use - GraphQL::StaticValidation::ALL_RULES).empty?
46
+ legacy_rules.each do |rule_class_or_module|
47
+ if rule_class_or_module.method_defined?(:validate)
48
+ GraphQL::Deprecation.warn "Legacy validator rules will be removed from GraphQL-Ruby 2.0, use a module instead (see the built-in rules: https://github.com/rmosolgo/graphql-ruby/tree/master/lib/graphql/static_validation/rules)"
49
+ GraphQL::Deprecation.warn " -> Legacy validator: #{rule_class_or_module}"
50
+ rule_class_or_module.new.validate(context)
51
+ end
52
+ end
41
53
  end
54
+
55
+ context.visitor.visit
42
56
  end
57
+ rescue Timeout::Error
58
+ handle_timeout(query, context)
43
59
  end
44
60
 
45
- context.visitor.visit
46
61
  context.errors
47
62
  end
48
63
 
49
-
50
64
  irep = if errors.empty? && context
51
65
  # Only return this if there are no errors and validation was actually run
52
66
  context.visitor.rewrite_document
@@ -60,6 +74,15 @@ module GraphQL
60
74
  }
61
75
  end
62
76
  end
77
+
78
+ # Invoked when static validation times out.
79
+ # @param query [GraphQL::Query]
80
+ # @param context [GraphQL::StaticValidation::ValidationContext]
81
+ def handle_timeout(query, context)
82
+ context.errors << GraphQL::StaticValidation::ValidationTimeoutError.new(
83
+ "Timeout on validation of query"
84
+ )
85
+ end
63
86
  end
64
87
  end
65
88
  end
@@ -26,7 +26,9 @@ module GraphQL
26
26
 
27
27
  instrumentation = Subscriptions::Instrumentation.new(schema: schema)
28
28
  defn.instrument(:query, instrumentation)
29
- defn.instrument(:field, instrumentation)
29
+ if !schema.is_a?(Class)
30
+ defn.instrument(:field, instrumentation)
31
+ end
30
32
  options[:schema] = schema
31
33
  schema.subscriptions = self.new(**options)
32
34
  schema.add_subscription_extension_if_necessary
@@ -107,31 +109,26 @@ module GraphQL
107
109
  variables = query_data.fetch(:variables)
108
110
  context = query_data.fetch(:context)
109
111
  operation_name = query_data.fetch(:operation_name)
110
- result = nil
111
- # this will be set to `false` unless `.execute` is terminated
112
- # with a `throw :graphql_subscription_unsubscribed`
113
- unsubscribed = true
114
- catch(:graphql_subscription_unsubscribed) do
115
- catch(:graphql_no_subscription_update) do
116
- # Re-evaluate the saved query,
117
- # but if it terminates early with a `throw`,
118
- # it will stay `nil`
119
- result = @schema.execute(
120
- query: query_string,
121
- context: context,
122
- subscription_topic: event.topic,
123
- operation_name: operation_name,
124
- variables: variables,
125
- root_value: object,
126
- )
127
- end
128
- unsubscribed = false
112
+ result = @schema.execute(
113
+ query: query_string,
114
+ context: context,
115
+ subscription_topic: event.topic,
116
+ operation_name: operation_name,
117
+ variables: variables,
118
+ root_value: object,
119
+ )
120
+ subscriptions_context = result.context.namespace(:subscriptions)
121
+ if subscriptions_context[:no_update]
122
+ result = nil
129
123
  end
130
124
 
125
+ unsubscribed = subscriptions_context[:unsubscribed]
126
+
131
127
  if unsubscribed
132
128
  # `unsubscribe` was called, clean up on our side
133
129
  # TODO also send `{more: false}` to client?
134
130
  delete_subscription(subscription_id)
131
+ result = nil
135
132
  end
136
133
 
137
134
  result
@@ -6,7 +6,7 @@ module GraphQL
6
6
  # @deprecated This module is no longer needed.
7
7
  module SubscriptionRoot
8
8
  def self.extended(child_cls)
9
- warn "`extend GraphQL::Subscriptions::SubscriptionRoot` is no longer required; you can remove it from your Subscription type (#{child_cls})"
9
+ GraphQL::Deprecation.warn "`extend GraphQL::Subscriptions::SubscriptionRoot` is no longer required; you can remove it from your Subscription type (#{child_cls})"
10
10
  child_cls.include(InstanceMethods)
11
11
  end
12
12
 
@@ -42,8 +42,8 @@ module GraphQL
42
42
  # execute_multiplex | `{ multiplex: GraphQL::Execution::Multiplex }`
43
43
  # execute_query | `{ query: GraphQL::Query }`
44
44
  # execute_query_lazy | `{ query: GraphQL::Query?, multiplex: GraphQL::Execution::Multiplex? }`
45
- # execute_field | `{ context: GraphQL::Query::Context::FieldResolutionContext?, owner: Class?, field: GraphQL::Schema::Field?, query: GraphQL::Query?, path: Array<String, Integer>?}`
46
- # execute_field_lazy | `{ context: GraphQL::Query::Context::FieldResolutionContext?, owner: Class?, field: GraphQL::Schema::Field?, query: GraphQL::Query?, path: Array<String, Integer>?}`
45
+ # execute_field | `{ owner: Class, field: GraphQL::Schema::Field, query: GraphQL::Query, path: Array<String, Integer>, ast_node: GraphQL::Language::Nodes::Field}`
46
+ # execute_field_lazy | `{ owner: Class, field: GraphQL::Schema::Field, query: GraphQL::Query, path: Array<String, Integer>, ast_node: GraphQL::Language::Nodes::Field}`
47
47
  # authorized | `{ context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }`
48
48
  # authorized_lazy | `{ context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }`
49
49
  # resolve_type | `{ context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }`
@@ -57,7 +57,7 @@ module GraphQL
57
57
  def platform_field_key(type, field)
58
58
  "graphql.#{type.graphql_name}.#{field.graphql_name}"
59
59
  end
60
-
60
+
61
61
  def platform_authorized_key(type)
62
62
  "graphql.authorized.#{type.graphql_name}"
63
63
  end
@@ -112,6 +112,8 @@ module GraphQL
112
112
  graphql_query_string(data[key])
113
113
  when :multiplex
114
114
  graphql_multiplex(data[key])
115
+ when :path
116
+ [key, data[key].join(".")]
115
117
  else
116
118
  [key, data[key]]
117
119
  end
@@ -95,8 +95,10 @@ module GraphQL
95
95
  end
96
96
 
97
97
  def self.use(schema_defn, options = {})
98
- tracer = self.new(options)
99
- schema_defn.instrument(:field, tracer)
98
+ tracer = self.new(**options)
99
+ if !schema_defn.is_a?(Class)
100
+ schema_defn.instrument(:field, tracer)
101
+ end
100
102
  schema_defn.tracer(tracer)
101
103
  end
102
104
 
@@ -16,7 +16,10 @@ module GraphQL
16
16
  end
17
17
 
18
18
  def collect(object)
19
- labels = { key: object['key'], platform_key: object['platform_key'] }
19
+ default_labels = { key: object['key'], platform_key: object['platform_key'] }
20
+ custom = object['custom_labels']
21
+ labels = custom.nil? ? default_labels : default_labels.merge(custom)
22
+
20
23
  @graphql_gauge.observe object['duration'], labels
21
24
  end
22
25
 
@@ -18,7 +18,7 @@ module GraphQL
18
18
  # This is not advised if you run more than one query per HTTP request, for example, with `graphql-client` or multiplexing.
19
19
  # It can also be specified per-query with `context[:set_skylight_endpoint_name]`.
20
20
  def initialize(options = {})
21
- warn("GraphQL::Tracing::SkylightTracing is deprecated, please enable Skylight's GraphQL probe instead: https://www.skylight.io/support/getting-more-from-skylight#graphql.")
21
+ GraphQL::Deprecation.warn("GraphQL::Tracing::SkylightTracing is deprecated and will be removed in GraphQL-Ruby 2.0, please enable Skylight's GraphQL probe instead: https://www.skylight.io/support/getting-more-from-skylight#graphql.")
22
22
  @set_endpoint_name = options.fetch(:set_endpoint_name, false)
23
23
  super
24
24
  end