graphql 2.4.3 → 2.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/visitor.rb +1 -1
  3. data/lib/graphql/analysis.rb +3 -3
  4. data/lib/graphql/autoload.rb +37 -0
  5. data/lib/graphql/current.rb +1 -1
  6. data/lib/graphql/dataloader/async_dataloader.rb +4 -4
  7. data/lib/graphql/dataloader/source.rb +1 -1
  8. data/lib/graphql/dataloader.rb +6 -9
  9. data/lib/graphql/execution/interpreter/resolve.rb +3 -3
  10. data/lib/graphql/execution/interpreter/runtime.rb +7 -7
  11. data/lib/graphql/execution/interpreter.rb +4 -4
  12. data/lib/graphql/language/cache.rb +13 -0
  13. data/lib/graphql/language/document_from_schema_definition.rb +8 -7
  14. data/lib/graphql/language/lexer.rb +4 -1
  15. data/lib/graphql/language/printer.rb +8 -8
  16. data/lib/graphql/pagination/connection.rb +1 -1
  17. data/lib/graphql/query/context/scoped_context.rb +1 -1
  18. data/lib/graphql/query/context.rb +6 -5
  19. data/lib/graphql/query/variable_validation_error.rb +1 -1
  20. data/lib/graphql/query.rb +12 -10
  21. data/lib/graphql/railtie.rb +7 -0
  22. data/lib/graphql/schema/addition.rb +1 -1
  23. data/lib/graphql/schema/directive/flagged.rb +1 -1
  24. data/lib/graphql/schema/directive.rb +1 -1
  25. data/lib/graphql/schema/field/scope_extension.rb +1 -1
  26. data/lib/graphql/schema/field.rb +10 -10
  27. data/lib/graphql/schema/field_extension.rb +1 -1
  28. data/lib/graphql/schema/has_single_input_argument.rb +3 -1
  29. data/lib/graphql/schema/input_object.rb +64 -27
  30. data/lib/graphql/schema/interface.rb +1 -1
  31. data/lib/graphql/schema/loader.rb +1 -1
  32. data/lib/graphql/schema/member/has_arguments.rb +12 -12
  33. data/lib/graphql/schema/member/has_directives.rb +3 -3
  34. data/lib/graphql/schema/member/has_fields.rb +18 -0
  35. data/lib/graphql/schema/member/has_interfaces.rb +4 -4
  36. data/lib/graphql/schema/member/has_validators.rb +1 -1
  37. data/lib/graphql/schema/object.rb +8 -0
  38. data/lib/graphql/schema/relay_classic_mutation.rb +0 -1
  39. data/lib/graphql/schema/resolver.rb +5 -5
  40. data/lib/graphql/schema/subscription.rb +2 -2
  41. data/lib/graphql/schema/union.rb +1 -1
  42. data/lib/graphql/schema/validator.rb +1 -1
  43. data/lib/graphql/schema/visibility/profile.rb +61 -235
  44. data/lib/graphql/schema/visibility/visit.rb +190 -0
  45. data/lib/graphql/schema/visibility.rb +162 -26
  46. data/lib/graphql/schema/warden.rb +4 -4
  47. data/lib/graphql/schema.rb +33 -12
  48. data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +1 -1
  49. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -1
  50. data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +1 -1
  51. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
  52. data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +1 -1
  53. data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +1 -1
  54. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +1 -1
  55. data/lib/graphql/static_validation/validation_context.rb +1 -0
  56. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +1 -1
  57. data/lib/graphql/subscriptions.rb +1 -1
  58. data/lib/graphql/testing/helpers.rb +2 -2
  59. data/lib/graphql/types/relay/connection_behaviors.rb +2 -2
  60. data/lib/graphql/types/relay/edge_behaviors.rb +1 -1
  61. data/lib/graphql/types.rb +18 -11
  62. data/lib/graphql/version.rb +1 -1
  63. data/lib/graphql.rb +80 -47
  64. metadata +4 -2
data/lib/graphql.rb CHANGED
@@ -5,8 +5,18 @@ require "set"
5
5
  require "singleton"
6
6
  require "forwardable"
7
7
  require "fiber/storage"
8
+ require "graphql/autoload"
8
9
 
9
10
  module GraphQL
11
+ extend Autoload
12
+
13
+ # Load all `autoload`-configured classes, and also eager-load dependents who have autoloads of their own.
14
+ def self.eager_load!
15
+ super
16
+ Query.eager_load!
17
+ Types.eager_load!
18
+ end
19
+
10
20
  class Error < StandardError
11
21
  end
12
22
 
@@ -71,56 +81,79 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
71
81
  class << self
72
82
  # If true, the parser should raise when an integer or float is followed immediately by an identifier (instead of a space or punctuation)
73
83
  attr_accessor :reject_numbers_followed_by_names
84
+
85
+ # If `production?` is detected but `eager_load!` wasn't called, emit a warning.
86
+ # @return [void]
87
+ def ensure_eager_load!
88
+ if production? && !eager_loading?
89
+ warn <<~WARNING
90
+ GraphQL-Ruby thinks this is a production deployment but didn't eager-load its constants. Address this by:
91
+
92
+ - Calling `GraphQL.eager_load!` in a production-only initializer or setup hook
93
+ - Assign `GraphQL.env = "..."` to something _other_ than `"production"` (for example, `GraphQL.env = "development"`)
94
+
95
+ More details: https://graphql-ruby.org/schema/definition#production-considerations
96
+ WARNING
97
+ end
98
+ end
99
+
100
+ attr_accessor :env
101
+
102
+ private
103
+
104
+ # Detect whether this is a production deployment or not
105
+ def production?
106
+ if env
107
+ # Manually assigned to production?
108
+ env == "production"
109
+ else
110
+ (detected_env = ENV["RACK_ENV"] || ENV["RAILS_ENV"] || ENV["HANAMI_ENV"] || ENV["APP_ENV"]) && detected_env.to_s.downcase == "production"
111
+ end
112
+ end
74
113
  end
75
114
 
76
115
  self.reject_numbers_followed_by_names = false
77
- end
78
116
 
79
- # Order matters for these:
80
-
81
- require "graphql/execution_error"
82
- require "graphql/runtime_type_error"
83
- require "graphql/unresolved_type_error"
84
- require "graphql/invalid_null_error"
85
- require "graphql/analysis_error"
86
- require "graphql/coercion_error"
87
- require "graphql/invalid_name_error"
88
- require "graphql/integer_decoding_error"
89
- require "graphql/integer_encoding_error"
90
- require "graphql/string_encoding_error"
91
- require "graphql/date_encoding_error"
92
- require "graphql/duration_encoding_error"
93
- require "graphql/type_kinds"
94
- require "graphql/name_validator"
95
- require "graphql/language"
96
-
97
- require_relative "./graphql/railtie" if defined? Rails::Railtie
98
-
99
- require "graphql/analysis"
100
- require "graphql/tracing"
101
- require "graphql/dig"
102
- require "graphql/execution"
103
- require "graphql/pagination"
104
- require "graphql/schema"
105
- require "graphql/query"
106
- require "graphql/dataloader"
107
- require "graphql/types"
108
- require "graphql/static_validation"
109
- require "graphql/execution"
110
- require "graphql/schema/built_in_types"
111
- require "graphql/schema/loader"
112
- require "graphql/schema/printer"
113
- require "graphql/introspection"
114
- require "graphql/relay"
117
+ autoload :ExecutionError, "graphql/execution_error"
118
+ autoload :RuntimeTypeError, "graphql/runtime_type_error"
119
+ autoload :UnresolvedTypeError, "graphql/unresolved_type_error"
120
+ autoload :InvalidNullError, "graphql/invalid_null_error"
121
+ autoload :AnalysisError, "graphql/analysis_error"
122
+ autoload :CoercionError, "graphql/coercion_error"
123
+ autoload :InvalidNameError, "graphql/invalid_name_error"
124
+ autoload :IntegerDecodingError, "graphql/integer_decoding_error"
125
+ autoload :IntegerEncodingError, "graphql/integer_encoding_error"
126
+ autoload :StringEncodingError, "graphql/string_encoding_error"
127
+ autoload :DateEncodingError, "graphql/date_encoding_error"
128
+ autoload :DurationEncodingError, "graphql/duration_encoding_error"
129
+ autoload :TypeKinds, "graphql/type_kinds"
130
+ autoload :NameValidator, "graphql/name_validator"
131
+ autoload :Language, "graphql/language"
132
+
133
+ autoload :Analysis, "graphql/analysis"
134
+ autoload :Tracing, "graphql/tracing"
135
+ autoload :Dig, "graphql/dig"
136
+ autoload :Execution, "graphql/execution"
137
+ autoload :Pagination, "graphql/pagination"
138
+ autoload :Schema, "graphql/schema"
139
+ autoload :Query, "graphql/query"
140
+ autoload :Dataloader, "graphql/dataloader"
141
+ autoload :Types, "graphql/types"
142
+ autoload :StaticValidation, "graphql/static_validation"
143
+ autoload :Execution, "graphql/execution"
144
+ autoload :Introspection, "graphql/introspection"
145
+ autoload :Relay, "graphql/relay"
146
+ autoload :Subscriptions, "graphql/subscriptions"
147
+ autoload :ParseError, "graphql/parse_error"
148
+ autoload :Backtrace, "graphql/backtrace"
149
+
150
+ autoload :UnauthorizedError, "graphql/unauthorized_error"
151
+ autoload :UnauthorizedEnumValueError, "graphql/unauthorized_enum_value_error"
152
+ autoload :UnauthorizedFieldError, "graphql/unauthorized_field_error"
153
+ autoload :LoadApplicationObjectFailedError, "graphql/load_application_object_failed_error"
154
+ autoload :Testing, "graphql/testing"
155
+ autoload :Current, "graphql/current"
156
+ end
115
157
 
116
158
  require "graphql/version"
117
- require "graphql/subscriptions"
118
- require "graphql/parse_error"
119
- require "graphql/backtrace"
120
-
121
- require "graphql/unauthorized_error"
122
- require "graphql/unauthorized_enum_value_error"
123
- require "graphql/unauthorized_field_error"
124
- require "graphql/load_application_object_failed_error"
125
- require "graphql/testing"
126
- require "graphql/current"
159
+ require "graphql/railtie" if defined? Rails::Railtie
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.3
4
+ version: 2.4.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: 2024-11-11 00:00:00.000000000 Z
11
+ date: 2024-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -328,6 +328,7 @@ files:
328
328
  - lib/graphql/analysis/query_depth.rb
329
329
  - lib/graphql/analysis/visitor.rb
330
330
  - lib/graphql/analysis_error.rb
331
+ - lib/graphql/autoload.rb
331
332
  - lib/graphql/backtrace.rb
332
333
  - lib/graphql/backtrace/inspect_result.rb
333
334
  - lib/graphql/backtrace/table.rb
@@ -504,6 +505,7 @@ files:
504
505
  - lib/graphql/schema/visibility.rb
505
506
  - lib/graphql/schema/visibility/migration.rb
506
507
  - lib/graphql/schema/visibility/profile.rb
508
+ - lib/graphql/schema/visibility/visit.rb
507
509
  - lib/graphql/schema/warden.rb
508
510
  - lib/graphql/schema/wrapper.rb
509
511
  - lib/graphql/static_validation.rb