graphql 2.3.10 → 2.3.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,6 +46,7 @@ require "graphql/schema/has_single_input_argument"
46
46
  require "graphql/schema/relay_classic_mutation"
47
47
  require "graphql/schema/subscription"
48
48
  require "graphql/schema/subset"
49
+ require "graphql/schema/types_migration"
49
50
 
50
51
  module GraphQL
51
52
  # A GraphQL schema which may be queried with {GraphQL::Query}.
@@ -338,6 +339,9 @@ module GraphQL
338
339
  # @return [Hash<String => Class>] A dictionary of type classes by their GraphQL name
339
340
  # @see get_type Which is more efficient for finding _one type_ by name, because it doesn't merge hashes.
340
341
  def types(context = GraphQL::Query::NullContext.instance)
342
+ if use_schema_subset?
343
+ return Subset.from_context(context, self).all_types_h
344
+ end
341
345
  all_types = non_introspection_types.merge(introspection_system.types)
342
346
  visible_types = {}
343
347
  all_types.each do |k, v|
@@ -365,6 +369,9 @@ module GraphQL
365
369
  # @param type_name [String]
366
370
  # @return [Module, nil] A type, or nil if there's no type called `type_name`
367
371
  def get_type(type_name, context = GraphQL::Query::NullContext.instance)
372
+ if use_schema_subset?
373
+ return Subset.from_context(context, self).type(type_name)
374
+ end
368
375
  local_entry = own_types[type_name]
369
376
  type_defn = case local_entry
370
377
  when nil
@@ -423,17 +430,13 @@ module GraphQL
423
430
  end
424
431
  end
425
432
 
426
- def new_connections?
427
- !!connections
428
- end
429
-
430
433
  def query(new_query_object = nil)
431
434
  if new_query_object
432
435
  if @query_object
433
436
  raise GraphQL::Error, "Second definition of `query(...)` (#{new_query_object.inspect}) is invalid, already configured with #{@query_object.inspect}"
434
437
  else
435
438
  @query_object = new_query_object
436
- add_type_and_traverse(new_query_object, root: true)
439
+ add_type_and_traverse(new_query_object, root: true) unless use_schema_subset?
437
440
  nil
438
441
  end
439
442
  else
@@ -447,7 +450,7 @@ module GraphQL
447
450
  raise GraphQL::Error, "Second definition of `mutation(...)` (#{new_mutation_object.inspect}) is invalid, already configured with #{@mutation_object.inspect}"
448
451
  else
449
452
  @mutation_object = new_mutation_object
450
- add_type_and_traverse(new_mutation_object, root: true)
453
+ add_type_and_traverse(new_mutation_object, root: true) unless use_schema_subset?
451
454
  nil
452
455
  end
453
456
  else
@@ -462,7 +465,7 @@ module GraphQL
462
465
  else
463
466
  @subscription_object = new_subscription_object
464
467
  add_subscription_extension_if_necessary
465
- add_type_and_traverse(new_subscription_object, root: true)
468
+ add_type_and_traverse(new_subscription_object, root: true) unless use_schema_subset?
466
469
  nil
467
470
  end
468
471
  else
@@ -486,7 +489,11 @@ module GraphQL
486
489
  end
487
490
 
488
491
  def root_types
489
- @root_types
492
+ if use_schema_subset?
493
+ [query, mutation, subscription].compact
494
+ else
495
+ @root_types
496
+ end
490
497
  end
491
498
 
492
499
  def warden_class
@@ -527,6 +534,13 @@ module GraphQL
527
534
  # @return [Hash<String, Module>] All possible types, if no `type` is given.
528
535
  # @return [Array<Module>] Possible types for `type`, if it's given.
529
536
  def possible_types(type = nil, context = GraphQL::Query::NullContext.instance)
537
+ if use_schema_subset?
538
+ if type
539
+ return Subset.from_context(context, self).possible_types(type)
540
+ else
541
+ raise "Schema.possible_types is not implemented for `use_schema_subset?`"
542
+ end
543
+ end
530
544
  if type
531
545
  # TODO duck-typing `.possible_types` would probably be nicer here
532
546
  if type.kind.union?
@@ -794,16 +808,6 @@ module GraphQL
794
808
  @analysis_engine || find_inherited_value(:analysis_engine, self.default_analysis_engine)
795
809
  end
796
810
 
797
- def using_ast_analysis?
798
- true
799
- end
800
-
801
- def interpreter?
802
- true
803
- end
804
-
805
- attr_writer :interpreter
806
-
807
811
  def error_bubbling(new_error_bubbling = nil)
808
812
  if !new_error_bubbling.nil?
809
813
  warn("error_bubbling(#{new_error_bubbling.inspect}) is deprecated; the default value of `false` will be the only option in GraphQL-Ruby 3.0")
@@ -912,7 +916,7 @@ module GraphQL
912
916
  To add other types to your schema, you might want `extra_types`: https://graphql-ruby.org/schema/definition.html#extra-types
913
917
  ERR
914
918
  end
915
- add_type_and_traverse(new_orphan_types, root: false)
919
+ add_type_and_traverse(new_orphan_types, root: false) unless use_schema_subset?
916
920
  own_orphan_types.concat(new_orphan_types.flatten)
917
921
  end
918
922
 
@@ -1171,7 +1175,11 @@ module GraphQL
1171
1175
  # @param new_directive [Class]
1172
1176
  # @return void
1173
1177
  def directive(new_directive)
1174
- add_type_and_traverse(new_directive, root: false)
1178
+ if use_schema_subset?
1179
+ own_directives[new_directive.graphql_name] = new_directive
1180
+ else
1181
+ add_type_and_traverse(new_directive, root: false)
1182
+ end
1175
1183
  end
1176
1184
 
1177
1185
  def default_directives
@@ -1514,7 +1522,7 @@ module GraphQL
1514
1522
  end
1515
1523
 
1516
1524
  def own_references_to
1517
- @own_references_to ||= {}.tap(&:compare_by_identity)
1525
+ @own_references_to ||= {}.compare_by_identity
1518
1526
  end
1519
1527
 
1520
1528
  def non_introspection_types
@@ -1530,7 +1538,7 @@ module GraphQL
1530
1538
  end
1531
1539
 
1532
1540
  def own_possible_types
1533
- @own_possible_types ||= {}.tap(&:compare_by_identity)
1541
+ @own_possible_types ||= {}.compare_by_identity
1534
1542
  end
1535
1543
 
1536
1544
  def own_union_memberships
@@ -90,10 +90,13 @@ module GraphQL
90
90
  end
91
91
  end
92
92
  graphql_result
93
- elsif schema.has_defined_type?(type_name)
94
- raise TypeNotVisibleError.new(type_name: type_name)
95
93
  else
96
- raise TypeNotDefinedError.new(type_name: type_name)
94
+ unfiltered_type = Schema::Subset.pass_thru(schema: schema, context: context).type(type_name)
95
+ if unfiltered_type
96
+ raise TypeNotVisibleError.new(type_name: type_name)
97
+ else
98
+ raise TypeNotDefinedError.new(type_name: type_name)
99
+ end
97
100
  end
98
101
  end
99
102
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.3.10"
3
+ VERSION = "2.3.12"
4
4
  end
data/lib/graphql.rb CHANGED
@@ -4,6 +4,7 @@ require "json"
4
4
  require "set"
5
5
  require "singleton"
6
6
  require "forwardable"
7
+ require "fiber/storage"
7
8
 
8
9
  module GraphQL
9
10
  class Error < StandardError
@@ -121,3 +122,4 @@ require "graphql/unauthorized_error"
121
122
  require "graphql/unauthorized_field_error"
122
123
  require "graphql/load_application_object_failed_error"
123
124
  require "graphql/testing"
125
+ require "graphql/current"
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.3.10
4
+ version: 2.3.12
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-07-19 00:00:00.000000000 Z
11
+ date: 2024-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fiber-storage
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: benchmark-ips
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -321,6 +335,7 @@ files:
321
335
  - lib/graphql/backtrace/traced_error.rb
322
336
  - lib/graphql/backtrace/tracer.rb
323
337
  - lib/graphql/coercion_error.rb
338
+ - lib/graphql/current.rb
324
339
  - lib/graphql/dataloader.rb
325
340
  - lib/graphql/dataloader/async_dataloader.rb
326
341
  - lib/graphql/dataloader/null_dataloader.rb
@@ -472,6 +487,7 @@ files:
472
487
  - lib/graphql/schema/timeout.rb
473
488
  - lib/graphql/schema/type_expression.rb
474
489
  - lib/graphql/schema/type_membership.rb
490
+ - lib/graphql/schema/types_migration.rb
475
491
  - lib/graphql/schema/union.rb
476
492
  - lib/graphql/schema/unique_within_type.rb
477
493
  - lib/graphql/schema/validator.rb
@@ -644,7 +660,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
644
660
  - !ruby/object:Gem::Version
645
661
  version: '0'
646
662
  requirements: []
647
- rubygems_version: 3.5.12
663
+ rubygems_version: 3.3.7
648
664
  signing_key:
649
665
  specification_version: 4
650
666
  summary: A GraphQL language and runtime for Ruby