graphql 1.13.4 → 1.13.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -147,6 +147,7 @@ rule
147
147
  name_without_on:
148
148
  IDENTIFIER
149
149
  | FRAGMENT
150
+ | REPEATABLE
150
151
  | TRUE
151
152
  | FALSE
152
153
  | operation_type
@@ -155,6 +156,7 @@ rule
155
156
  enum_name: /* any identifier, but not "true", "false" or "null" */
156
157
  IDENTIFIER
157
158
  | FRAGMENT
159
+ | REPEATABLE
158
160
  | ON
159
161
  | operation_type
160
162
  | schema_keyword
@@ -422,10 +424,14 @@ rule
422
424
  }
423
425
 
424
426
  directive_definition:
425
- description_opt DIRECTIVE DIR_SIGN name arguments_definitions_opt ON directive_locations {
426
- result = make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[6], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
427
+ description_opt DIRECTIVE DIR_SIGN name arguments_definitions_opt directive_repeatable_opt ON directive_locations {
428
+ result = make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[7], repeatable: !!val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
427
429
  }
428
430
 
431
+ directive_repeatable_opt:
432
+ /* nothing */
433
+ | REPEATABLE
434
+
429
435
  directive_locations:
430
436
  name { result = [make_node(:DirectiveLocation, name: val[0].to_s, position_source: val[0])] }
431
437
  | directive_locations PIPE name { val[0] << make_node(:DirectiveLocation, name: val[2].to_s, position_source: val[2]) }
@@ -252,6 +252,10 @@ module GraphQL
252
252
  out << print_arguments(directive.arguments)
253
253
  end
254
254
 
255
+ if directive.repeatable
256
+ out << " repeatable"
257
+ end
258
+
255
259
  out << " on #{directive.locations.map(&:name).join(' | ')}"
256
260
  end
257
261
 
@@ -377,6 +377,7 @@ module GraphQL
377
377
  Class.new(GraphQL::Schema::Directive) do
378
378
  graphql_name(directive_definition.name)
379
379
  description(directive_definition.description)
380
+ repeatable(directive_definition.repeatable)
380
381
  locations(*directive_definition.locations.map { |location| location.name.to_sym })
381
382
  ast_node(directive_definition)
382
383
  builder.build_arguments(self, directive_definition.arguments, type_resolver)
@@ -101,6 +101,14 @@ module GraphQL
101
101
  def on_operation?
102
102
  locations.include?(QUERY) && locations.include?(MUTATION) && locations.include?(SUBSCRIPTION)
103
103
  end
104
+
105
+ def repeatable?
106
+ !!@repeatable
107
+ end
108
+
109
+ def repeatable(new_value)
110
+ @repeatable = new_value
111
+ end
104
112
  end
105
113
 
106
114
  # @return [GraphQL::Schema::Field, GraphQL::Schema::Argument, Class, Module]
@@ -110,7 +110,7 @@ module GraphQL
110
110
  end
111
111
 
112
112
  def on_directive(node, parent)
113
- directive_defn = @schema.directives[node.name]
113
+ directive_defn = @context.schema_directives[node.name]
114
114
  @directive_definitions.push(directive_defn)
115
115
  super
116
116
  @directive_definitions.pop
@@ -59,7 +59,7 @@ module GraphQL
59
59
  end
60
60
  end
61
61
  when GraphQL::Language::Nodes::Directive
62
- context.schema.directives[parent.name]
62
+ context.schema_directives[parent.name]
63
63
  when GraphQL::Language::Nodes::Field
64
64
  context.field_definition
65
65
  else
@@ -5,7 +5,7 @@ module GraphQL
5
5
  include GraphQL::Language
6
6
 
7
7
  def on_directive(node, parent)
8
- validate_location(node, parent, context.schema.directives)
8
+ validate_location(node, parent, context.schema_directives)
9
9
  super
10
10
  end
11
11
 
@@ -8,7 +8,7 @@ module GraphQL
8
8
  end
9
9
 
10
10
  def on_directive(node, _parent)
11
- directive_defn = context.schema.directives[node.name]
11
+ directive_defn = context.schema_directives[node.name]
12
12
  assert_required_args(node, directive_defn)
13
13
  super
14
14
  end
@@ -40,7 +40,7 @@ module GraphQL
40
40
  nodes: [used_directives[directive_name], ast_directive],
41
41
  directive: directive_name,
42
42
  ))
43
- else
43
+ elsif !((dir_defn = context.schema_directives[directive_name]) && dir_defn.repeatable?)
44
44
  used_directives[directive_name] = ast_directive
45
45
  end
46
46
  end
@@ -44,6 +44,10 @@ module GraphQL
44
44
  def too_many_errors?
45
45
  @errors.length >= @max_errors
46
46
  end
47
+
48
+ def schema_directives
49
+ @schema_directives ||= schema.directives
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -11,7 +11,7 @@ module GraphQL
11
11
  module ActiveSupportNotificationsTracing
12
12
  # A cache of frequently-used keys to avoid needless string allocations
13
13
  KEYS = NotificationsTracing::KEYS
14
- NOTIFICATIONS_ENGINE = NotificationsTracing.new(ActiveSupport::Notifications) if defined?(ActiveSupport)
14
+ NOTIFICATIONS_ENGINE = NotificationsTracing.new(ActiveSupport::Notifications) if defined?(ActiveSupport::Notifications)
15
15
 
16
16
  def self.trace(key, metadata, &blk)
17
17
  NOTIFICATIONS_ENGINE.trace(key, metadata, &blk)
@@ -20,7 +20,12 @@ module GraphQL
20
20
 
21
21
  if key == 'execute_multiplex'
22
22
  operations = data[:multiplex].queries.map(&:selected_operation_name).join(', ')
23
- span.resource = operations unless operations.empty?
23
+ span.resource = if operations.empty?
24
+ first_query = data[:multiplex].queries.first
25
+ fallback_transaction_name(first_query && first_query.context)
26
+ else
27
+ operations
28
+ end
24
29
 
25
30
  # For top span of query, set the analytics sample rate tag, if available.
26
31
  if analytics_enabled?
@@ -104,17 +104,22 @@ module GraphQL
104
104
 
105
105
  private
106
106
 
107
- # Get the transaction name based on the operation type and name
107
+ # Get the transaction name based on the operation type and name if possible, or fall back to a user provided
108
+ # one. Useful for anonymous queries.
108
109
  def transaction_name(query)
109
110
  selected_op = query.selected_operation
110
- if selected_op
111
+ txn_name = if selected_op
111
112
  op_type = selected_op.operation_type
112
- op_name = selected_op.name || "anonymous"
113
+ op_name = selected_op.name || fallback_transaction_name(query.context) || "anonymous"
114
+ "#{op_type}.#{op_name}"
113
115
  else
114
- op_type = "query"
115
- op_name = "anonymous"
116
+ "query.anonymous"
116
117
  end
117
- "GraphQL/#{op_type}.#{op_name}"
118
+ "GraphQL/#{txn_name}"
119
+ end
120
+
121
+ def fallback_transaction_name(context)
122
+ context[:tracing_fallback_transaction_name]
118
123
  end
119
124
 
120
125
  attr_reader :options
@@ -18,18 +18,6 @@ module GraphQL
18
18
  # context.schema.object_from_id(id, context)
19
19
  # end
20
20
  #
21
- def self.const_missing(const_name)
22
- if const_name == :NodeField
23
- message = "NodeField is deprecated, use `include GraphQL::Types::Relay::HasNodeField` instead."
24
- message += "\n(referenced from #{caller(1, 1).first})"
25
- GraphQL::Deprecation.warn(message)
26
-
27
- DeprecatedNodeField
28
- else
29
- super
30
- end
31
- end
32
-
33
21
  DeprecatedNodeField = GraphQL::Schema::Field.new(owner: nil, **HasNodeField.field_options, &HasNodeField.field_block)
34
22
  end
35
23
  end
@@ -27,6 +27,12 @@ module GraphQL
27
27
  GraphQL::Deprecation.warn(message)
28
28
 
29
29
  DeprecatedNodesField
30
+ elsif const_name == :NodeField
31
+ message = "NodeField is deprecated, use `include GraphQL::Types::Relay::HasNodeField` instead."
32
+ message += "\n(referenced from #{caller(1, 1).first})"
33
+ GraphQL::Deprecation.warn(message)
34
+
35
+ DeprecatedNodeField
30
36
  else
31
37
  super
32
38
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.13.4"
3
+ VERSION = "1.13.5"
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.13.4
4
+ version: 1.13.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-07 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -710,7 +710,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
710
710
  - !ruby/object:Gem::Version
711
711
  version: '0'
712
712
  requirements: []
713
- rubygems_version: 3.2.22
713
+ rubygems_version: 3.3.3
714
714
  signing_key:
715
715
  specification_version: 4
716
716
  summary: A GraphQL language and runtime for Ruby