graphql 2.5.12 → 2.5.14

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
  SHA256:
3
- metadata.gz: 1e59a0d63055f40c6802e504d0a0b12fa4a0b36d73caba86f2879966d13fc31e
4
- data.tar.gz: 38416d067f73335742755e9fe11825e591d6ecd999360074e469f8b6ceea0908
3
+ metadata.gz: deb0ac3bea401c53909c6880f133ee810f3e0882c7a023ed33b27f7b12a4c82b
4
+ data.tar.gz: be2d8e55d131a62863d4ecf6665c22c9ba6c9ba467bdd205ec83d96f9b952098
5
5
  SHA512:
6
- metadata.gz: af2f66ced060a82f5869586c41917a7dfd12d44478f63f48b80b96fef563b0f3c0294e1aa5d16256740362474f70523f983a6bec47d400408392dce46ab62445
7
- data.tar.gz: cf1361a8d27f9ec47de57aa76f58f33757652a4765d8e887cf13079b8e0873a7d983dc94d1022cda045d56e6c3e6f39e2ce966685681da98084179e604883bb1
6
+ metadata.gz: 494296336070a677965ceaaad1e14412f1b8a6589ab3ae3466c5c00071a59f763f2af2df8aacd394c9fd912afd0a5f9df988991411213dbfab285d762d1a6e75
7
+ data.tar.gz: 8d65056236ddb32eabe498d93bb026f8d7ea145b627d6a4554b2add2d8c00db202f9bbe16cae816e58aeb6dd77f3e8aed99dcaa802af2643f73b03a5d10b0b63
@@ -42,6 +42,14 @@ module GraphQL
42
42
  end
43
43
  end
44
44
 
45
+ def depth
46
+ @depth ||= if @graphql_parent
47
+ @graphql_parent.depth + 1
48
+ else
49
+ 1
50
+ end
51
+ end
52
+
45
53
  attr_accessor :graphql_dead
46
54
  attr_reader :graphql_parent, :graphql_result_name, :graphql_is_non_null_in_parent,
47
55
  :graphql_application_value, :graphql_result_type, :graphql_selections, :graphql_is_eager, :ast_node, :graphql_arguments, :graphql_field
@@ -890,7 +890,6 @@ module GraphQL
890
890
  # @return [GraphQL::Execution::Lazy, Object] If loading `object` will be deferred, it's a wrapper over it.
891
891
  def after_lazy(lazy_obj, field:, owner_object:, arguments:, ast_node:, result:, result_name:, eager: false, runtime_state:, trace: true, &block)
892
892
  if lazy?(lazy_obj)
893
- orig_result = result
894
893
  was_authorized_by_scope_items = runtime_state.was_authorized_by_scope_items
895
894
  lazy = GraphQL::Execution::Lazy.new(field: field) do
896
895
  # This block might be called in a new fiber;
@@ -900,13 +899,13 @@ module GraphQL
900
899
  runtime_state.current_field = field
901
900
  runtime_state.current_arguments = arguments
902
901
  runtime_state.current_result_name = result_name
903
- runtime_state.current_result = orig_result
902
+ runtime_state.current_result = result
904
903
  runtime_state.was_authorized_by_scope_items = was_authorized_by_scope_items
905
904
  # Wrap the execution of _this_ method with tracing,
906
905
  # but don't wrap the continuation below
907
- result = nil
906
+ sync_result = nil
908
907
  inner_obj = begin
909
- result = if trace
908
+ sync_result = if trace
910
909
  @current_trace.begin_execute_field(field, owner_object, arguments, query)
911
910
  @current_trace.execute_field_lazy(field: field, query: query, object: owner_object, arguments: arguments, ast_node: ast_node) do
912
911
  schema.sync_lazy(lazy_obj)
@@ -924,7 +923,7 @@ module GraphQL
924
923
  end
925
924
  ensure
926
925
  if trace
927
- @current_trace.end_execute_field(field, owner_object, arguments, query, result)
926
+ @current_trace.end_execute_field(field, owner_object, arguments, query, sync_result)
928
927
  end
929
928
  end
930
929
  yield(inner_obj, runtime_state)
@@ -934,12 +933,7 @@ module GraphQL
934
933
  lazy.value
935
934
  else
936
935
  set_result(result, result_name, lazy, false, false) # is_non_null is irrelevant here
937
- current_depth = 0
938
- while result
939
- current_depth += 1
940
- result = result.graphql_parent
941
- end
942
- @dataloader.lazy_at_depth(current_depth, lazy)
936
+ @dataloader.lazy_at_depth(result.depth, lazy)
943
937
  lazy
944
938
  end
945
939
  else
@@ -129,11 +129,22 @@ module GraphQL
129
129
  # not runtime arguments.
130
130
  context = Query::NullContext.instance
131
131
  self.class.all_argument_definitions.each do |arg_defn|
132
- if arguments.key?(arg_defn.keyword)
133
- value = arguments[arg_defn.keyword]
132
+ keyword = arg_defn.keyword
133
+ arg_type = arg_defn.type
134
+ if arguments.key?(keyword)
135
+ value = arguments[keyword]
134
136
  # This is a Ruby-land value; convert it to graphql for validation
135
137
  graphql_value = begin
136
- arg_defn.type.unwrap.coerce_isolated_result(value)
138
+ coerce_value = value
139
+ if arg_type.list? && (!coerce_value.nil?) && (!coerce_value.is_a?(Array))
140
+ # When validating inputs, GraphQL accepts a single item
141
+ # and implicitly converts it to a one-item list.
142
+ # However, we're using result coercion here to go from Ruby value
143
+ # to GraphQL value, so it doesn't have that feature.
144
+ # Keep the GraphQL-type behavior but implement it manually:
145
+ coerce_value = [coerce_value]
146
+ end
147
+ arg_type.coerce_isolated_result(coerce_value)
137
148
  rescue GraphQL::Schema::Enum::UnresolvedValueError
138
149
  # Let validation handle this
139
150
  value
@@ -142,7 +153,7 @@ module GraphQL
142
153
  value = graphql_value = nil
143
154
  end
144
155
 
145
- result = arg_defn.type.validate_input(graphql_value, context)
156
+ result = arg_type.validate_input(graphql_value, context)
146
157
  if !result.valid?
147
158
  raise InvalidArgumentError, "@#{graphql_name}.#{arg_defn.graphql_name} on #{owner.path} is invalid (#{value.inspect}): #{result.problems.first["explanation"]}"
148
159
  end
@@ -39,9 +39,9 @@ module GraphQL
39
39
  end
40
40
  end
41
41
 
42
- def run_graphql_field(schema, field_path, object, arguments: {}, context: {}, ast_node: nil, lookahead: nil)
42
+ def run_graphql_field(schema, field_path, object, arguments: {}, context: {}, ast_node: nil, lookahead: nil, visibility_profile: nil)
43
43
  type_name, *field_names = field_path.split(".")
44
- dummy_query = GraphQL::Query.new(schema, "{ __typename }", context: context)
44
+ dummy_query = GraphQL::Query.new(schema, "{ __typename }", context: context, visibility_profile: visibility_profile)
45
45
  query_context = dummy_query.context
46
46
  dataloader = query_context.dataloader
47
47
  object_type = dummy_query.types.type(type_name) # rubocop:disable Development/ContextIsPassedCop
@@ -104,32 +104,35 @@ module GraphQL
104
104
  end
105
105
  end
106
106
 
107
- def with_resolution_context(schema, type:, object:, context:{})
107
+ def with_resolution_context(schema, type:, object:, context:{}, visibility_profile: nil)
108
108
  resolution_context = ResolutionAssertionContext.new(
109
109
  self,
110
110
  schema: schema,
111
111
  type_name: type,
112
112
  object: object,
113
- context: context
113
+ context: context,
114
+ visibility_profile: visibility_profile,
114
115
  )
115
116
  yield(resolution_context)
116
117
  end
117
118
 
118
119
  class ResolutionAssertionContext
119
- def initialize(test, type_name:, object:, schema:, context:)
120
+ def initialize(test, type_name:, object:, schema:, context:, visibility_profile:)
120
121
  @test = test
121
122
  @type_name = type_name
122
123
  @object = object
123
124
  @schema = schema
124
125
  @context = context
126
+ @visibility_profile = visibility_profile
125
127
  end
126
128
 
129
+ attr_reader :visibility_profile
127
130
 
128
131
  def run_graphql_field(field_name, arguments: {})
129
132
  if @schema
130
- @test.run_graphql_field(@schema, "#{@type_name}.#{field_name}", @object, arguments: arguments, context: @context)
133
+ @test.run_graphql_field(@schema, "#{@type_name}.#{field_name}", @object, arguments: arguments, context: @context, visibility_profile: @visibility_profile)
131
134
  else
132
- @test.run_graphql_field("#{@type_name}.#{field_name}", @object, arguments: arguments, context: @context)
135
+ @test.run_graphql_field("#{@type_name}.#{field_name}", @object, arguments: arguments, context: @context, visibility_profile: @visibility_profile)
133
136
  end
134
137
  end
135
138
  end
@@ -137,8 +140,8 @@ module GraphQL
137
140
  module SchemaHelpers
138
141
  include Helpers
139
142
 
140
- def run_graphql_field(field_path, object, arguments: {}, context: {})
141
- super(@@schema_class_for_helpers, field_path, object, arguments: arguments, context: context)
143
+ def run_graphql_field(field_path, object, arguments: {}, context: {}, visibility_profile: nil)
144
+ super(@@schema_class_for_helpers, field_path, object, arguments: arguments, context: context, visibility_profile: visibility_profile)
142
145
  end
143
146
 
144
147
  def with_resolution_context(*args, **kwargs, &block)
@@ -41,7 +41,9 @@ module GraphQL
41
41
  if query.selected_operation_name
42
42
  span.set_data('graphql.operation.name', query.selected_operation_name)
43
43
  end
44
- span.set_data('graphql.operation.type', query.selected_operation.operation_type)
44
+ if query.selected_operation
45
+ span.set_data('graphql.operation.type', query.selected_operation.operation_type)
46
+ end
45
47
  end
46
48
  end
47
49
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.5.12"
3
+ VERSION = "2.5.14"
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.12
4
+ version: 2.5.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-09-15 00:00:00.000000000 Z
10
+ date: 2025-10-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: base64