graphql 2.4.5 → 2.4.6

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: 576505327425ece2720724b18acb06b712d9574f18bbde7f43242a3288046966
4
- data.tar.gz: 6b67a9aac34abf8e340c8fcdba329ff7e64357f9ade833d909244ec2683c4174
3
+ metadata.gz: 5cd45aa292bddd6fff0d06c9b040cf2f87cf81926a4f8c2e53febf3f434b6dac
4
+ data.tar.gz: 0c736a7432142b948c893a2db5049d97a54660e102ea75c27bd3058680e764f0
5
5
  SHA512:
6
- metadata.gz: 394b8ba06f32a1a983b5cb41cf322c361fb05fe68b9dd5946e5d0eb846923fc03edf9674935767a0a06737ccad300a790439a160e0499f82ed0f6ff5223a675d
7
- data.tar.gz: 0410a99ab8efe22a1d130b93d08a12d2a3e989974a50af65416ea4979023826bd829da64d1eeb6d4b9dd75d552547a80e26f100f14a7c107acc0740339044430
6
+ metadata.gz: '07404039c9ca7c2c78867bba53fd3ed60d89ac48564e909e964bb7e7298e86e2406ccd70113a49b26dc6cfd1f48580e141d1bdc015eb2289718c973c2cc6db6c'
7
+ data.tar.gz: 1826580e9cafcac3dbe46ddf6aeb3451847f390143a68e799633727fa05ad8b4e400b058279887b0ca62fb5b4bc7a4af66ce991a8377f2b3a4ffdda34edbfea6
@@ -10,7 +10,9 @@ module GraphQL
10
10
  class Railtie < Rails::Railtie
11
11
  config.graphql = ActiveSupport::OrderedOptions.new
12
12
  config.graphql.parser_cache = false
13
- config.eager_load_namespaces << GraphQL
13
+ config.before_eager_load do
14
+ GraphQL.eager_load!
15
+ end
14
16
 
15
17
  initializer("graphql.cache") do |app|
16
18
  if config.graphql.parser_cache
@@ -359,7 +359,8 @@ module GraphQL
359
359
  if application_object.nil?
360
360
  nil
361
361
  else
362
- maybe_lazy_resolve_type = context.schema.resolve_type(argument.loads, application_object, context)
362
+ arg_loads_type = argument.loads
363
+ maybe_lazy_resolve_type = context.schema.resolve_type(arg_loads_type, application_object, context)
363
364
  context.query.after_lazy(maybe_lazy_resolve_type) do |resolve_type_result|
364
365
  if resolve_type_result.is_a?(Array) && resolve_type_result.size == 2
365
366
  application_object_type, application_object = resolve_type_result
@@ -368,10 +369,17 @@ module GraphQL
368
369
  # application_object is already assigned
369
370
  end
370
371
 
371
- if !(
372
- context.types.possible_types(argument.loads).include?(application_object_type) ||
373
- context.types.loadable?(argument.loads, context)
374
- )
372
+ passes_possible_types_check = if context.types.loadable?(arg_loads_type, context)
373
+ if arg_loads_type.kind.union?
374
+ # This union is used in `loads:` but not otherwise visible to this query
375
+ context.types.loadable_possible_types(arg_loads_type, context).include?(application_object_type)
376
+ else
377
+ true
378
+ end
379
+ else
380
+ context.types.possible_types(arg_loads_type).include?(application_object_type)
381
+ end
382
+ if !passes_possible_types_check
375
383
  err = GraphQL::LoadApplicationObjectFailedError.new(context: context, argument: argument, id: id, object: application_object)
376
384
  application_object = load_application_object_failed(err)
377
385
  end
@@ -112,6 +112,7 @@ module GraphQL
112
112
  :all_types_h,
113
113
  :fields,
114
114
  :loadable?,
115
+ :loadable_possible_types,
115
116
  :type,
116
117
  :arguments,
117
118
  :argument,
@@ -84,6 +84,8 @@ module GraphQL
84
84
  @cached_arguments = Hash.new do |h, owner|
85
85
  h[owner] = non_duplicate_items(owner.all_argument_definitions, @cached_visible_arguments)
86
86
  end.compare_by_identity
87
+
88
+ @loadable_possible_types = Hash.new { |h, union_type| h[union_type] = union_type.possible_types }.compare_by_identity
87
89
  end
88
90
 
89
91
  def field_on_visible_interface?(field, owner)
@@ -249,6 +251,10 @@ module GraphQL
249
251
  !@all_types[t.graphql_name] && @cached_visible[t]
250
252
  end
251
253
 
254
+ def loadable_possible_types(t, _ctx)
255
+ @loadable_possible_types[t]
256
+ end
257
+
252
258
  def loaded_types
253
259
  @all_types.values
254
260
  end
@@ -72,6 +72,7 @@ module GraphQL
72
72
  def interface_type_memberships(obj_t, ctx); obj_t.interface_type_memberships; end
73
73
  def arguments(owner, ctx); owner.arguments(ctx); end
74
74
  def loadable?(type, ctx); type.visible?(ctx); end
75
+ def loadable_possible_types(type, ctx); type.possible_types(ctx); end
75
76
  def visibility_profile
76
77
  @visibility_profile ||= Warden::VisibilityProfile.new(self)
77
78
  end
@@ -106,6 +107,7 @@ module GraphQL
106
107
  def get_field(parent_type, field_name); @schema.get_field(parent_type, field_name); end
107
108
  def reachable_type?(type_name); true; end
108
109
  def loadable?(type, _ctx); true; end
110
+ def loadable_possible_types(union_type, _ctx); union_type.possible_types; end
109
111
  def reachable_types; @schema.types.values; end # rubocop:disable Development/ContextIsPassedCop
110
112
  def possible_types(type_defn); @schema.possible_types(type_defn, Query::NullContext.instance, false); end
111
113
  def interfaces(obj_type); obj_type.interfaces; end
@@ -180,6 +182,10 @@ module GraphQL
180
182
  @warden.loadable?(t, ctx)
181
183
  end
182
184
 
185
+ def loadable_possible_types(t, ctx)
186
+ @warden.loadable_possible_types(t, ctx)
187
+ end
188
+
183
189
  def reachable_type?(type_name)
184
190
  !!@warden.reachable_type?(type_name)
185
191
  end
@@ -204,7 +210,7 @@ module GraphQL
204
210
  @visible_possible_types = @visible_fields = @visible_arguments = @visible_enum_arrays =
205
211
  @visible_enum_values = @visible_interfaces = @type_visibility = @type_memberships =
206
212
  @visible_and_reachable_type = @unions = @unfiltered_interfaces =
207
- @reachable_type_set = @visibility_profile =
213
+ @reachable_type_set = @visibility_profile = @loadable_possible_types =
208
214
  nil
209
215
  @skip_warning = schema.plugins.any? { |(plugin, _opts)| plugin == GraphQL::Schema::Warden }
210
216
  end
@@ -229,6 +235,13 @@ module GraphQL
229
235
  !reachable_type_set.include?(type) && visible_type?(type)
230
236
  end
231
237
 
238
+ def loadable_possible_types(union_type, _ctx)
239
+ @loadable_possible_types ||= read_through do |t|
240
+ t.possible_types # unfiltered
241
+ end
242
+ @loadable_possible_types[union_type]
243
+ end
244
+
232
245
  # @return [GraphQL::BaseType, nil] The type named `type_name`, if it exists (else `nil`)
233
246
  def get_type(type_name)
234
247
  @visible_types ||= read_through do |name|
@@ -75,6 +75,9 @@ module GraphQL
75
75
  class Schema
76
76
  extend GraphQL::Schema::Member::HasAstNode
77
77
  extend GraphQL::Schema::FindInheritedValue
78
+ extend Autoload
79
+
80
+ autoload :BUILT_IN_TYPES, "graphql/schema/built_in_types"
78
81
 
79
82
  class DuplicateNamesError < GraphQL::Error
80
83
  attr_reader :duplicated_name
@@ -1805,6 +1808,5 @@ module GraphQL
1805
1808
  end
1806
1809
  end
1807
1810
 
1808
- require "graphql/schema/built_in_types"
1809
1811
  require "graphql/schema/loader"
1810
1812
  require "graphql/schema/printer"
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.4.5"
3
+ VERSION = "2.4.6"
4
4
  end
data/lib/graphql.rb CHANGED
@@ -15,6 +15,7 @@ module GraphQL
15
15
  super
16
16
  Query.eager_load!
17
17
  Types.eager_load!
18
+ Schema.eager_load!
18
19
  end
19
20
 
20
21
  class Error < StandardError
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: 2.4.5
4
+ version: 2.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-02 00:00:00.000000000 Z
11
+ date: 2024-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64