graphql 2.0.30 → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/install/mutation_root_generator.rb +2 -2
- data/lib/generators/graphql/install/templates/base_mutation.erb +2 -0
- data/lib/generators/graphql/install/templates/mutation_type.erb +2 -0
- data/lib/generators/graphql/install_generator.rb +3 -0
- data/lib/generators/graphql/templates/base_argument.erb +2 -0
- data/lib/generators/graphql/templates/base_connection.erb +2 -0
- data/lib/generators/graphql/templates/base_edge.erb +2 -0
- data/lib/generators/graphql/templates/base_enum.erb +2 -0
- data/lib/generators/graphql/templates/base_field.erb +2 -0
- data/lib/generators/graphql/templates/base_input_object.erb +2 -0
- data/lib/generators/graphql/templates/base_interface.erb +2 -0
- data/lib/generators/graphql/templates/base_object.erb +2 -0
- data/lib/generators/graphql/templates/base_resolver.erb +6 -0
- data/lib/generators/graphql/templates/base_scalar.erb +2 -0
- data/lib/generators/graphql/templates/base_union.erb +2 -0
- data/lib/generators/graphql/templates/graphql_controller.erb +2 -0
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +2 -0
- data/lib/generators/graphql/templates/node_type.erb +2 -0
- data/lib/generators/graphql/templates/query_type.erb +2 -0
- data/lib/generators/graphql/templates/schema.erb +5 -0
- data/lib/graphql/analysis/analyzer.rb +89 -0
- data/lib/graphql/analysis/field_usage.rb +82 -0
- data/lib/graphql/analysis/max_query_complexity.rb +20 -0
- data/lib/graphql/analysis/max_query_depth.rb +20 -0
- data/lib/graphql/analysis/query_complexity.rb +183 -0
- data/lib/graphql/analysis/query_depth.rb +58 -0
- data/lib/graphql/analysis/visitor.rb +282 -0
- data/lib/graphql/analysis.rb +92 -1
- data/lib/graphql/backtrace/inspect_result.rb +0 -12
- data/lib/graphql/backtrace/trace.rb +12 -15
- data/lib/graphql/coercion_error.rb +1 -9
- data/lib/graphql/dataloader/async_dataloader.rb +88 -0
- data/lib/graphql/dataloader/null_dataloader.rb +1 -1
- data/lib/graphql/dataloader/request.rb +5 -0
- data/lib/graphql/dataloader/source.rb +11 -3
- data/lib/graphql/dataloader.rb +112 -142
- data/lib/graphql/duration_encoding_error.rb +16 -0
- data/lib/graphql/execution/interpreter/argument_value.rb +5 -1
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +175 -0
- data/lib/graphql/execution/interpreter/runtime.rb +163 -365
- data/lib/graphql/execution/interpreter.rb +92 -158
- data/lib/graphql/execution/lookahead.rb +88 -21
- data/lib/graphql/introspection/dynamic_fields.rb +1 -1
- data/lib/graphql/introspection/entry_points.rb +11 -5
- data/lib/graphql/introspection/schema_type.rb +3 -1
- data/lib/graphql/language/block_string.rb +34 -18
- data/lib/graphql/language/definition_slice.rb +1 -1
- data/lib/graphql/language/document_from_schema_definition.rb +38 -38
- data/lib/graphql/language/lexer.rb +305 -193
- data/lib/graphql/language/nodes.rb +113 -66
- data/lib/graphql/language/parser.rb +787 -1986
- data/lib/graphql/language/printer.rb +303 -146
- data/lib/graphql/language/sanitized_printer.rb +20 -22
- data/lib/graphql/language/static_visitor.rb +167 -0
- data/lib/graphql/language/visitor.rb +20 -81
- data/lib/graphql/language.rb +61 -0
- data/lib/graphql/load_application_object_failed_error.rb +5 -1
- data/lib/graphql/pagination/array_connection.rb +6 -6
- data/lib/graphql/pagination/connection.rb +28 -1
- data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -2
- data/lib/graphql/query/context/scoped_context.rb +101 -0
- data/lib/graphql/query/context.rb +66 -131
- data/lib/graphql/query/null_context.rb +4 -11
- data/lib/graphql/query/validation_pipeline.rb +4 -4
- data/lib/graphql/query/variables.rb +3 -3
- data/lib/graphql/query.rb +17 -26
- data/lib/graphql/railtie.rb +9 -6
- data/lib/graphql/rake_task.rb +3 -12
- data/lib/graphql/rubocop/graphql/base_cop.rb +1 -1
- data/lib/graphql/schema/addition.rb +21 -11
- data/lib/graphql/schema/argument.rb +43 -8
- data/lib/graphql/schema/base_64_encoder.rb +3 -5
- data/lib/graphql/schema/build_from_definition.rb +9 -12
- data/lib/graphql/schema/directive/one_of.rb +12 -0
- data/lib/graphql/schema/directive/specified_by.rb +14 -0
- data/lib/graphql/schema/directive.rb +3 -1
- data/lib/graphql/schema/enum.rb +3 -3
- data/lib/graphql/schema/field/connection_extension.rb +1 -15
- data/lib/graphql/schema/field/scope_extension.rb +8 -1
- data/lib/graphql/schema/field.rb +49 -35
- data/lib/graphql/schema/has_single_input_argument.rb +157 -0
- data/lib/graphql/schema/input_object.rb +4 -4
- data/lib/graphql/schema/interface.rb +10 -10
- data/lib/graphql/schema/introspection_system.rb +4 -2
- data/lib/graphql/schema/late_bound_type.rb +4 -0
- data/lib/graphql/schema/list.rb +2 -2
- data/lib/graphql/schema/loader.rb +2 -3
- data/lib/graphql/schema/member/base_dsl_methods.rb +2 -1
- data/lib/graphql/schema/member/has_arguments.rb +63 -73
- data/lib/graphql/schema/member/has_directives.rb +1 -1
- data/lib/graphql/schema/member/has_fields.rb +8 -5
- data/lib/graphql/schema/member/has_interfaces.rb +23 -9
- data/lib/graphql/schema/member/relay_shortcuts.rb +1 -1
- data/lib/graphql/schema/member/scoped.rb +19 -0
- data/lib/graphql/schema/member/type_system_helpers.rb +1 -2
- data/lib/graphql/schema/member/validates_input.rb +3 -3
- data/lib/graphql/schema/mutation.rb +7 -0
- data/lib/graphql/schema/object.rb +8 -0
- data/lib/graphql/schema/printer.rb +8 -7
- data/lib/graphql/schema/relay_classic_mutation.rb +6 -128
- data/lib/graphql/schema/resolver.rb +27 -13
- data/lib/graphql/schema/scalar.rb +3 -3
- data/lib/graphql/schema/subscription.rb +11 -4
- data/lib/graphql/schema/union.rb +1 -1
- data/lib/graphql/schema/unique_within_type.rb +1 -1
- data/lib/graphql/schema/warden.rb +96 -95
- data/lib/graphql/schema.rb +323 -102
- data/lib/graphql/static_validation/all_rules.rb +1 -1
- data/lib/graphql/static_validation/base_visitor.rb +1 -1
- data/lib/graphql/static_validation/literal_validator.rb +2 -3
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +2 -2
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +2 -2
- data/lib/graphql/static_validation/validation_context.rb +5 -5
- data/lib/graphql/static_validation/validator.rb +3 -0
- data/lib/graphql/static_validation.rb +0 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +4 -3
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +1 -1
- data/lib/graphql/subscriptions/event.rb +8 -2
- data/lib/graphql/subscriptions/serialize.rb +2 -0
- data/lib/graphql/subscriptions.rb +15 -13
- data/lib/graphql/testing/helpers.rb +151 -0
- data/lib/graphql/testing.rb +2 -0
- data/lib/graphql/tracing/appoptics_trace.rb +2 -2
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -2
- data/lib/graphql/tracing/legacy_hooks_trace.rb +74 -0
- data/lib/graphql/tracing/platform_tracing.rb +3 -1
- data/lib/graphql/tracing/{prometheus_tracing → prometheus_trace}/graphql_collector.rb +3 -1
- data/lib/graphql/tracing/prometheus_trace.rb +9 -9
- data/lib/graphql/tracing/sentry_trace.rb +112 -0
- data/lib/graphql/tracing/trace.rb +1 -0
- data/lib/graphql/tracing.rb +3 -1
- data/lib/graphql/type_kinds.rb +1 -1
- data/lib/graphql/types/iso_8601_duration.rb +77 -0
- data/lib/graphql/types/relay/connection_behaviors.rb +32 -2
- data/lib/graphql/types/relay/edge_behaviors.rb +7 -0
- data/lib/graphql/types.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +13 -13
- data/readme.md +12 -2
- metadata +33 -26
- data/lib/graphql/analysis/ast/analyzer.rb +0 -84
- data/lib/graphql/analysis/ast/field_usage.rb +0 -57
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -22
- data/lib/graphql/analysis/ast/max_query_depth.rb +0 -22
- data/lib/graphql/analysis/ast/query_complexity.rb +0 -230
- data/lib/graphql/analysis/ast/query_depth.rb +0 -55
- data/lib/graphql/analysis/ast/visitor.rb +0 -276
- data/lib/graphql/analysis/ast.rb +0 -81
- data/lib/graphql/deprecation.rb +0 -9
- data/lib/graphql/filter.rb +0 -59
- data/lib/graphql/language/parser.y +0 -560
- data/lib/graphql/schema/base_64_bp.rb +0 -26
- data/lib/graphql/static_validation/type_stack.rb +0 -216
- data/lib/graphql/subscriptions/instrumentation.rb +0 -28
@@ -0,0 +1,112 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Tracing
|
5
|
+
module SentryTrace
|
6
|
+
include PlatformTrace
|
7
|
+
|
8
|
+
# @param set_transaction_name [Boolean] If true, the GraphQL operation name will be used as the transaction name.
|
9
|
+
# This is not advised if you run more than one query per HTTP request, for example, with `graphql-client` or multiplexing.
|
10
|
+
# It can also be specified per-query with `context[:set_sentry_transaction_name]`.
|
11
|
+
def initialize(set_transaction_name: false, **_rest)
|
12
|
+
@set_transaction_name = set_transaction_name
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute_query(**data)
|
17
|
+
set_this_txn_name = data[:query].context[:set_sentry_transaction_name]
|
18
|
+
if set_this_txn_name == true || (set_this_txn_name.nil? && @set_transaction_name)
|
19
|
+
Sentry.configure_scope do |scope|
|
20
|
+
scope.set_transaction_name(transaction_name(data[:query]))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
instrument_sentry_execution("graphql.execute", "execute_query", data) { super }
|
24
|
+
end
|
25
|
+
|
26
|
+
{
|
27
|
+
"lex" => "graphql.lex",
|
28
|
+
"parse" => "graphql.parse",
|
29
|
+
"validate" => "graphql.validate",
|
30
|
+
"analyze_query" => "graphql.analyze",
|
31
|
+
"analyze_multiplex" => "graphql.analyze_multiplex",
|
32
|
+
"execute_multiplex" => "graphql.execute_multiplex",
|
33
|
+
"execute_query_lazy" => "graphql.execute"
|
34
|
+
}.each do |trace_method, platform_key|
|
35
|
+
module_eval <<-RUBY, __FILE__, __LINE__
|
36
|
+
def #{trace_method}(**data)
|
37
|
+
instrument_sentry_execution("#{platform_key}", "#{trace_method}", data) { super }
|
38
|
+
end
|
39
|
+
RUBY
|
40
|
+
end
|
41
|
+
|
42
|
+
def platform_execute_field(platform_key, &block)
|
43
|
+
instrument_sentry_execution(platform_key, "execute_field", &block)
|
44
|
+
end
|
45
|
+
|
46
|
+
def platform_execute_field_lazy(platform_key, &block)
|
47
|
+
instrument_sentry_execution(platform_key, "execute_field_lazy", &block)
|
48
|
+
end
|
49
|
+
|
50
|
+
def platform_authorized(platform_key, &block)
|
51
|
+
instrument_sentry_execution(platform_key, "authorized", &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
def platform_authorized_lazy(platform_key, &block)
|
55
|
+
instrument_sentry_execution(platform_key, "authorized_lazy", &block)
|
56
|
+
end
|
57
|
+
|
58
|
+
def platform_resolve_type(platform_key, &block)
|
59
|
+
instrument_sentry_execution(platform_key, "resolve_type", &block)
|
60
|
+
end
|
61
|
+
|
62
|
+
def platform_resolve_type_lazy(platform_key, &block)
|
63
|
+
instrument_sentry_execution(platform_key, "resolve_type_lazy", &block)
|
64
|
+
end
|
65
|
+
|
66
|
+
def platform_field_key(field)
|
67
|
+
"graphql.field.#{field.path}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def platform_authorized_key(type)
|
71
|
+
"graphql.authorized.#{type.graphql_name}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def platform_resolve_type_key(type)
|
75
|
+
"graphql.resolve_type.#{type.graphql_name}"
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def instrument_sentry_execution(platform_key, trace_method, data=nil, &block)
|
81
|
+
return yield unless Sentry.initialized?
|
82
|
+
|
83
|
+
Sentry.with_child_span(op: platform_key, start_timestamp: Sentry.utc_now.to_f) do |span|
|
84
|
+
result = yield
|
85
|
+
return result unless span
|
86
|
+
|
87
|
+
span.finish
|
88
|
+
if trace_method == "execute_multiplex" && data.key?(:multiplex)
|
89
|
+
operation_names = data[:multiplex].queries.map{|q| operation_name(q) }
|
90
|
+
span.set_description(operation_names.join(", "))
|
91
|
+
elsif trace_method == "execute_query" && data.key?(:query)
|
92
|
+
span.set_description(operation_name(data[:query]))
|
93
|
+
span.set_data('graphql.document', data[:query].query_string)
|
94
|
+
span.set_data('graphql.operation.name', data[:query].selected_operation_name) if data[:query].selected_operation_name
|
95
|
+
span.set_data('graphql.operation.type', data[:query].selected_operation.operation_type)
|
96
|
+
end
|
97
|
+
|
98
|
+
result
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def operation_name(query)
|
103
|
+
selected_op = query.selected_operation
|
104
|
+
if selected_op
|
105
|
+
[selected_op.operation_type, selected_op.name].compact.join(' ')
|
106
|
+
else
|
107
|
+
'GraphQL Operation'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/graphql/tracing.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "graphql/tracing/trace"
|
3
3
|
require "graphql/tracing/legacy_trace"
|
4
|
+
require "graphql/tracing/legacy_hooks_trace"
|
4
5
|
|
5
6
|
# Legacy tracing:
|
6
7
|
require "graphql/tracing/active_support_notifications_tracing"
|
@@ -21,11 +22,12 @@ require "graphql/tracing/appsignal_trace"
|
|
21
22
|
require "graphql/tracing/data_dog_trace"
|
22
23
|
require "graphql/tracing/new_relic_trace"
|
23
24
|
require "graphql/tracing/notifications_trace"
|
25
|
+
require "graphql/tracing/sentry_trace"
|
24
26
|
require "graphql/tracing/scout_trace"
|
25
27
|
require "graphql/tracing/statsd_trace"
|
26
28
|
require "graphql/tracing/prometheus_trace"
|
27
29
|
if defined?(PrometheusExporter::Server)
|
28
|
-
require "graphql/tracing/
|
30
|
+
require "graphql/tracing/prometheus_trace/graphql_collector"
|
29
31
|
end
|
30
32
|
|
31
33
|
module GraphQL
|
data/lib/graphql/type_kinds.rb
CHANGED
@@ -16,7 +16,7 @@ module GraphQL
|
|
16
16
|
@description = description
|
17
17
|
end
|
18
18
|
|
19
|
-
# Does this TypeKind have multiple possible
|
19
|
+
# Does this TypeKind have multiple possible implementers?
|
20
20
|
# @deprecated Use `abstract?` instead of `resolves?`.
|
21
21
|
def resolves?; @abstract; end
|
22
22
|
# Is this TypeKind abstract?
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module Types
|
4
|
+
# This scalar takes `Duration`s and transmits them as strings,
|
5
|
+
# using ISO 8601 format. ActiveSupport >= 5.0 must be loaded to use
|
6
|
+
# this scalar.
|
7
|
+
#
|
8
|
+
# Use it for fields or arguments as follows:
|
9
|
+
#
|
10
|
+
# field :age, GraphQL::Types::ISO8601Duration, null: false
|
11
|
+
#
|
12
|
+
# argument :interval, GraphQL::Types::ISO8601Duration, null: false
|
13
|
+
#
|
14
|
+
# Alternatively, use this built-in scalar as inspiration for your
|
15
|
+
# own Duration type.
|
16
|
+
class ISO8601Duration < GraphQL::Schema::Scalar
|
17
|
+
description "An ISO 8601-encoded duration"
|
18
|
+
|
19
|
+
# @return [Integer, nil]
|
20
|
+
def self.seconds_precision
|
21
|
+
# ActiveSupport::Duration precision defaults to whatever input was given
|
22
|
+
@seconds_precision
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param [Integer, nil] value
|
26
|
+
def self.seconds_precision=(value)
|
27
|
+
@seconds_precision = value
|
28
|
+
end
|
29
|
+
|
30
|
+
# @param value [ActiveSupport::Duration, String]
|
31
|
+
# @return [String]
|
32
|
+
# @raise [GraphQL::Error] if ActiveSupport::Duration is not defined or if an incompatible object is passed
|
33
|
+
def self.coerce_result(value, _ctx)
|
34
|
+
unless defined?(ActiveSupport::Duration)
|
35
|
+
raise GraphQL::Error, "ActiveSupport >= 5.0 must be loaded to use the built-in ISO8601Duration type."
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
case value
|
40
|
+
when ActiveSupport::Duration
|
41
|
+
value.iso8601(precision: seconds_precision)
|
42
|
+
when ::String
|
43
|
+
ActiveSupport::Duration.parse(value).iso8601(precision: seconds_precision)
|
44
|
+
else
|
45
|
+
# Try calling as ActiveSupport::Duration compatible as a fallback
|
46
|
+
value.iso8601(precision: seconds_precision)
|
47
|
+
end
|
48
|
+
rescue StandardError => error
|
49
|
+
raise GraphQL::Error, "An incompatible object (#{value.class}) was given to #{self}. Make sure that only ActiveSupport::Durations and well-formatted Strings are used with this type. (#{error.message})"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param value [String, ActiveSupport::Duration]
|
54
|
+
# @return [ActiveSupport::Duration, nil]
|
55
|
+
# @raise [GraphQL::Error] if ActiveSupport::Duration is not defined
|
56
|
+
# @raise [GraphQL::DurationEncodingError] if duration cannot be parsed
|
57
|
+
def self.coerce_input(value, ctx)
|
58
|
+
unless defined?(ActiveSupport::Duration)
|
59
|
+
raise GraphQL::Error, "ActiveSupport >= 5.0 must be loaded to use the built-in ISO8601Duration type."
|
60
|
+
end
|
61
|
+
|
62
|
+
begin
|
63
|
+
if value.is_a?(ActiveSupport::Duration)
|
64
|
+
value
|
65
|
+
elsif value.nil?
|
66
|
+
nil
|
67
|
+
else
|
68
|
+
ActiveSupport::Duration.parse(value)
|
69
|
+
end
|
70
|
+
rescue ArgumentError, TypeError
|
71
|
+
err = GraphQL::DurationEncodingError.new(value)
|
72
|
+
ctx.schema.type_error(err, ctx)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -67,9 +67,8 @@ module GraphQL
|
|
67
67
|
type: [edge_type_class, null: edge_nullable],
|
68
68
|
null: edges_nullable,
|
69
69
|
description: "A list of edges.",
|
70
|
+
scope: false, # Assume that the connection was already scoped.
|
70
71
|
connection: false,
|
71
|
-
# Assume that the connection was scoped before this step:
|
72
|
-
scope: false,
|
73
72
|
}
|
74
73
|
|
75
74
|
if field_options
|
@@ -88,6 +87,19 @@ module GraphQL
|
|
88
87
|
node_type.scope_items(items, context)
|
89
88
|
end
|
90
89
|
|
90
|
+
# The connection will skip auth on its nodes if the node_type is configured for that
|
91
|
+
def reauthorize_scoped_objects(new_value = nil)
|
92
|
+
if new_value.nil?
|
93
|
+
if @reauthorize_scoped_objects != nil
|
94
|
+
@reauthorize_scoped_objects
|
95
|
+
else
|
96
|
+
node_type.reauthorize_scoped_objects
|
97
|
+
end
|
98
|
+
else
|
99
|
+
@reauthorize_scoped_objects = new_value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
91
103
|
# Add the shortcut `nodes` field to this connection and its subclasses
|
92
104
|
def nodes_field(node_nullable: self.node_nullable, field_options: nil)
|
93
105
|
define_nodes_field(node_nullable, field_options: field_options)
|
@@ -170,6 +182,24 @@ module GraphQL
|
|
170
182
|
obj_type.field :page_info, GraphQL::Types::Relay::PageInfo, null: false, description: "Information to aid in pagination."
|
171
183
|
end
|
172
184
|
end
|
185
|
+
|
186
|
+
def edges
|
187
|
+
# Assume that whatever authorization needed to happen
|
188
|
+
# already happened at the connection level.
|
189
|
+
current_runtime_state = Thread.current[:__graphql_runtime_info]
|
190
|
+
query_runtime_state = current_runtime_state[context.query]
|
191
|
+
query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
|
192
|
+
@object.edges
|
193
|
+
end
|
194
|
+
|
195
|
+
def nodes
|
196
|
+
# Assume that whatever authorization needed to happen
|
197
|
+
# already happened at the connection level.
|
198
|
+
current_runtime_state = Thread.current[:__graphql_runtime_info]
|
199
|
+
query_runtime_state = current_runtime_state[context.query]
|
200
|
+
query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
|
201
|
+
@object.nodes
|
202
|
+
end
|
173
203
|
end
|
174
204
|
end
|
175
205
|
end
|
@@ -12,6 +12,13 @@ module GraphQL
|
|
12
12
|
child_class.node_nullable(true)
|
13
13
|
end
|
14
14
|
|
15
|
+
def node
|
16
|
+
current_runtime_state = Thread.current[:__graphql_runtime_info]
|
17
|
+
query_runtime_state = current_runtime_state[context.query]
|
18
|
+
query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
|
19
|
+
@object.node
|
20
|
+
end
|
21
|
+
|
15
22
|
module ClassMethods
|
16
23
|
def inherited(child_class)
|
17
24
|
super
|
data/lib/graphql/types.rb
CHANGED
@@ -6,6 +6,7 @@ require "graphql/types/id"
|
|
6
6
|
require "graphql/types/int"
|
7
7
|
require "graphql/types/iso_8601_date"
|
8
8
|
require "graphql/types/iso_8601_date_time"
|
9
|
+
require "graphql/types/iso_8601_duration"
|
9
10
|
require "graphql/types/json"
|
10
11
|
require "graphql/types/string"
|
11
12
|
require "graphql/types/relay"
|
data/lib/graphql/version.rb
CHANGED
data/lib/graphql.rb
CHANGED
@@ -6,14 +6,6 @@ require "singleton"
|
|
6
6
|
require "forwardable"
|
7
7
|
|
8
8
|
module GraphQL
|
9
|
-
# forwards-compat for argument handling
|
10
|
-
module Ruby2Keywords
|
11
|
-
if RUBY_VERSION < "2.7"
|
12
|
-
def ruby2_keywords(*)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
9
|
class Error < StandardError
|
18
10
|
end
|
19
11
|
|
@@ -42,8 +34,8 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
|
|
42
34
|
# Turn a query string or schema definition into an AST
|
43
35
|
# @param graphql_string [String] a GraphQL query string or schema definition
|
44
36
|
# @return [GraphQL::Language::Nodes::Document]
|
45
|
-
def self.parse(graphql_string, trace: GraphQL::Tracing::NullTrace)
|
46
|
-
default_parser.parse(graphql_string, trace: trace)
|
37
|
+
def self.parse(graphql_string, trace: GraphQL::Tracing::NullTrace, filename: nil, max_tokens: nil)
|
38
|
+
default_parser.parse(graphql_string, trace: trace, filename: filename, max_tokens: max_tokens)
|
47
39
|
end
|
48
40
|
|
49
41
|
# Read the contents of `filename` and parse them as GraphQL
|
@@ -60,6 +52,7 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
|
|
60
52
|
end
|
61
53
|
|
62
54
|
def self.parse_with_racc(string, filename: nil, trace: GraphQL::Tracing::NullTrace)
|
55
|
+
warn "`GraphQL.parse_with_racc` is deprecated; GraphQL-Ruby no longer uses racc for parsing. Call `GraphQL.parse` or `GraphQL::Language::Parser.parse` instead."
|
63
56
|
GraphQL::Language::Parser.parse(string, filename: filename, trace: trace)
|
64
57
|
end
|
65
58
|
|
@@ -73,6 +66,13 @@ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: http
|
|
73
66
|
EMPTY_HASH = {}.freeze
|
74
67
|
EMPTY_ARRAY = [].freeze
|
75
68
|
end
|
69
|
+
|
70
|
+
class << self
|
71
|
+
# If true, the parser should raise when an integer or float is followed immediately by an identifier (instead of a space or punctuation)
|
72
|
+
attr_accessor :reject_numbers_followed_by_names
|
73
|
+
end
|
74
|
+
|
75
|
+
self.reject_numbers_followed_by_names = false
|
76
76
|
end
|
77
77
|
|
78
78
|
# Order matters for these:
|
@@ -88,6 +88,7 @@ require "graphql/integer_decoding_error"
|
|
88
88
|
require "graphql/integer_encoding_error"
|
89
89
|
require "graphql/string_encoding_error"
|
90
90
|
require "graphql/date_encoding_error"
|
91
|
+
require "graphql/duration_encoding_error"
|
91
92
|
require "graphql/type_kinds"
|
92
93
|
require "graphql/name_validator"
|
93
94
|
require "graphql/language"
|
@@ -101,9 +102,8 @@ require "graphql/execution"
|
|
101
102
|
require "graphql/pagination"
|
102
103
|
require "graphql/schema"
|
103
104
|
require "graphql/query"
|
104
|
-
require "graphql/types"
|
105
105
|
require "graphql/dataloader"
|
106
|
-
require "graphql/
|
106
|
+
require "graphql/types"
|
107
107
|
require "graphql/static_validation"
|
108
108
|
require "graphql/execution"
|
109
109
|
require "graphql/schema/built_in_types"
|
@@ -120,4 +120,4 @@ require "graphql/backtrace"
|
|
120
120
|
require "graphql/unauthorized_error"
|
121
121
|
require "graphql/unauthorized_field_error"
|
122
122
|
require "graphql/load_application_object_failed_error"
|
123
|
-
require "graphql/
|
123
|
+
require "graphql/testing"
|
data/readme.md
CHANGED
@@ -7,7 +7,7 @@ A Ruby implementation of [GraphQL](https://graphql.org/).
|
|
7
7
|
|
8
8
|
- [Website](https://graphql-ruby.org/)
|
9
9
|
- [API Documentation](https://www.rubydoc.info/github/rmosolgo/graphql-ruby)
|
10
|
-
- [Newsletter](https://
|
10
|
+
- [Newsletter](https://buttondown.email/graphql-ruby)
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -34,7 +34,17 @@ Or, see ["Getting Started"](https://graphql-ruby.org/getting_started.html).
|
|
34
34
|
|
35
35
|
## Upgrade
|
36
36
|
|
37
|
-
I also sell [GraphQL::Pro](https://graphql.pro) which provides several features on top of the GraphQL runtime, including
|
37
|
+
I also sell [GraphQL::Pro](https://graphql.pro) which provides several features on top of the GraphQL runtime, including:
|
38
|
+
|
39
|
+
- [Persisted queries](https://graphql-ruby.org/operation_store/overview)
|
40
|
+
- [API versioning](https://graphql-ruby.org/changesets/overview)
|
41
|
+
- [Streaming payloads](https://graphql-ruby.org/defer/overview)
|
42
|
+
- [Server-side caching](https://graphql-ruby.org/object_cache/overview)
|
43
|
+
- [Rate limiters](https://graphql-ruby.org/limiters/overview)
|
44
|
+
- Subscriptions backends for [Pusher](https://graphql-ruby.org/subscriptions/pusher_implementation) and [Ably](https://graphql-ruby.org/subscriptions/ably_implementation)
|
45
|
+
- Authorization plugins for [Pundit](https://graphql-ruby.org/authorization/pundit_integration) and [CanCan](https://graphql-ruby.org/authorization/can_can_integration)
|
46
|
+
|
47
|
+
Besides that, Pro customers get email support and an opportunity to support graphql-ruby's development!
|
38
48
|
|
39
49
|
## Goals
|
40
50
|
|
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
|
+
version: 2.3.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-
|
11
|
+
date: 2024-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: graphql-batch
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: memory_profiler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: minitest
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -284,6 +284,7 @@ files:
|
|
284
284
|
- lib/generators/graphql/templates/base_input_object.erb
|
285
285
|
- lib/generators/graphql/templates/base_interface.erb
|
286
286
|
- lib/generators/graphql/templates/base_object.erb
|
287
|
+
- lib/generators/graphql/templates/base_resolver.erb
|
287
288
|
- lib/generators/graphql/templates/base_scalar.erb
|
288
289
|
- lib/generators/graphql/templates/base_union.erb
|
289
290
|
- lib/generators/graphql/templates/enum.erb
|
@@ -305,14 +306,13 @@ files:
|
|
305
306
|
- lib/generators/graphql/union_generator.rb
|
306
307
|
- lib/graphql.rb
|
307
308
|
- lib/graphql/analysis.rb
|
308
|
-
- lib/graphql/analysis/
|
309
|
-
- lib/graphql/analysis/
|
310
|
-
- lib/graphql/analysis/
|
311
|
-
- lib/graphql/analysis/
|
312
|
-
- lib/graphql/analysis/
|
313
|
-
- lib/graphql/analysis/
|
314
|
-
- lib/graphql/analysis/
|
315
|
-
- lib/graphql/analysis/ast/visitor.rb
|
309
|
+
- lib/graphql/analysis/analyzer.rb
|
310
|
+
- lib/graphql/analysis/field_usage.rb
|
311
|
+
- lib/graphql/analysis/max_query_complexity.rb
|
312
|
+
- lib/graphql/analysis/max_query_depth.rb
|
313
|
+
- lib/graphql/analysis/query_complexity.rb
|
314
|
+
- lib/graphql/analysis/query_depth.rb
|
315
|
+
- lib/graphql/analysis/visitor.rb
|
316
316
|
- lib/graphql/analysis_error.rb
|
317
317
|
- lib/graphql/backtrace.rb
|
318
318
|
- lib/graphql/backtrace/inspect_result.rb
|
@@ -322,13 +322,14 @@ files:
|
|
322
322
|
- lib/graphql/backtrace/tracer.rb
|
323
323
|
- lib/graphql/coercion_error.rb
|
324
324
|
- lib/graphql/dataloader.rb
|
325
|
+
- lib/graphql/dataloader/async_dataloader.rb
|
325
326
|
- lib/graphql/dataloader/null_dataloader.rb
|
326
327
|
- lib/graphql/dataloader/request.rb
|
327
328
|
- lib/graphql/dataloader/request_all.rb
|
328
329
|
- lib/graphql/dataloader/source.rb
|
329
330
|
- lib/graphql/date_encoding_error.rb
|
330
|
-
- lib/graphql/deprecation.rb
|
331
331
|
- lib/graphql/dig.rb
|
332
|
+
- lib/graphql/duration_encoding_error.rb
|
332
333
|
- lib/graphql/execution.rb
|
333
334
|
- lib/graphql/execution/directive_checks.rb
|
334
335
|
- lib/graphql/execution/errors.rb
|
@@ -340,12 +341,12 @@ files:
|
|
340
341
|
- lib/graphql/execution/interpreter/handles_raw_value.rb
|
341
342
|
- lib/graphql/execution/interpreter/resolve.rb
|
342
343
|
- lib/graphql/execution/interpreter/runtime.rb
|
344
|
+
- lib/graphql/execution/interpreter/runtime/graphql_result.rb
|
343
345
|
- lib/graphql/execution/lazy.rb
|
344
346
|
- lib/graphql/execution/lazy/lazy_method_map.rb
|
345
347
|
- lib/graphql/execution/lookahead.rb
|
346
348
|
- lib/graphql/execution/multiplex.rb
|
347
349
|
- lib/graphql/execution_error.rb
|
348
|
-
- lib/graphql/filter.rb
|
349
350
|
- lib/graphql/integer_decoding_error.rb
|
350
351
|
- lib/graphql/integer_encoding_error.rb
|
351
352
|
- lib/graphql/introspection.rb
|
@@ -372,9 +373,9 @@ files:
|
|
372
373
|
- lib/graphql/language/lexer.rb
|
373
374
|
- lib/graphql/language/nodes.rb
|
374
375
|
- lib/graphql/language/parser.rb
|
375
|
-
- lib/graphql/language/parser.y
|
376
376
|
- lib/graphql/language/printer.rb
|
377
377
|
- lib/graphql/language/sanitized_printer.rb
|
378
|
+
- lib/graphql/language/static_visitor.rb
|
378
379
|
- lib/graphql/language/token.rb
|
379
380
|
- lib/graphql/language/visitor.rb
|
380
381
|
- lib/graphql/load_application_object_failed_error.rb
|
@@ -390,6 +391,7 @@ files:
|
|
390
391
|
- lib/graphql/parse_error.rb
|
391
392
|
- lib/graphql/query.rb
|
392
393
|
- lib/graphql/query/context.rb
|
394
|
+
- lib/graphql/query/context/scoped_context.rb
|
393
395
|
- lib/graphql/query/fingerprint.rb
|
394
396
|
- lib/graphql/query/input_validation_result.rb
|
395
397
|
- lib/graphql/query/null_context.rb
|
@@ -411,7 +413,6 @@ files:
|
|
411
413
|
- lib/graphql/schema/addition.rb
|
412
414
|
- lib/graphql/schema/always_visible.rb
|
413
415
|
- lib/graphql/schema/argument.rb
|
414
|
-
- lib/graphql/schema/base_64_bp.rb
|
415
416
|
- lib/graphql/schema/base_64_encoder.rb
|
416
417
|
- lib/graphql/schema/build_from_definition.rb
|
417
418
|
- lib/graphql/schema/build_from_definition/resolve_map.rb
|
@@ -424,6 +425,7 @@ files:
|
|
424
425
|
- lib/graphql/schema/directive/include.rb
|
425
426
|
- lib/graphql/schema/directive/one_of.rb
|
426
427
|
- lib/graphql/schema/directive/skip.rb
|
428
|
+
- lib/graphql/schema/directive/specified_by.rb
|
427
429
|
- lib/graphql/schema/directive/transform.rb
|
428
430
|
- lib/graphql/schema/enum.rb
|
429
431
|
- lib/graphql/schema/enum_value.rb
|
@@ -433,6 +435,7 @@ files:
|
|
433
435
|
- lib/graphql/schema/field_extension.rb
|
434
436
|
- lib/graphql/schema/find_inherited_value.rb
|
435
437
|
- lib/graphql/schema/finder.rb
|
438
|
+
- lib/graphql/schema/has_single_input_argument.rb
|
436
439
|
- lib/graphql/schema/input_object.rb
|
437
440
|
- lib/graphql/schema/interface.rb
|
438
441
|
- lib/graphql/schema/introspection_system.rb
|
@@ -550,7 +553,6 @@ files:
|
|
550
553
|
- lib/graphql/static_validation/rules/variables_are_input_types_error.rb
|
551
554
|
- lib/graphql/static_validation/rules/variables_are_used_and_defined.rb
|
552
555
|
- lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb
|
553
|
-
- lib/graphql/static_validation/type_stack.rb
|
554
556
|
- lib/graphql/static_validation/validation_context.rb
|
555
557
|
- lib/graphql/static_validation/validation_timeout_error.rb
|
556
558
|
- lib/graphql/static_validation/validator.rb
|
@@ -560,8 +562,9 @@ files:
|
|
560
562
|
- lib/graphql/subscriptions/broadcast_analyzer.rb
|
561
563
|
- lib/graphql/subscriptions/default_subscription_resolve_extension.rb
|
562
564
|
- lib/graphql/subscriptions/event.rb
|
563
|
-
- lib/graphql/subscriptions/instrumentation.rb
|
564
565
|
- lib/graphql/subscriptions/serialize.rb
|
566
|
+
- lib/graphql/testing.rb
|
567
|
+
- lib/graphql/testing/helpers.rb
|
565
568
|
- lib/graphql/tracing.rb
|
566
569
|
- lib/graphql/tracing/active_support_notifications_trace.rb
|
567
570
|
- lib/graphql/tracing/active_support_notifications_tracing.rb
|
@@ -571,6 +574,7 @@ files:
|
|
571
574
|
- lib/graphql/tracing/appsignal_tracing.rb
|
572
575
|
- lib/graphql/tracing/data_dog_trace.rb
|
573
576
|
- lib/graphql/tracing/data_dog_tracing.rb
|
577
|
+
- lib/graphql/tracing/legacy_hooks_trace.rb
|
574
578
|
- lib/graphql/tracing/legacy_trace.rb
|
575
579
|
- lib/graphql/tracing/new_relic_trace.rb
|
576
580
|
- lib/graphql/tracing/new_relic_tracing.rb
|
@@ -579,10 +583,11 @@ files:
|
|
579
583
|
- lib/graphql/tracing/platform_trace.rb
|
580
584
|
- lib/graphql/tracing/platform_tracing.rb
|
581
585
|
- lib/graphql/tracing/prometheus_trace.rb
|
586
|
+
- lib/graphql/tracing/prometheus_trace/graphql_collector.rb
|
582
587
|
- lib/graphql/tracing/prometheus_tracing.rb
|
583
|
-
- lib/graphql/tracing/prometheus_tracing/graphql_collector.rb
|
584
588
|
- lib/graphql/tracing/scout_trace.rb
|
585
589
|
- lib/graphql/tracing/scout_tracing.rb
|
590
|
+
- lib/graphql/tracing/sentry_trace.rb
|
586
591
|
- lib/graphql/tracing/statsd_trace.rb
|
587
592
|
- lib/graphql/tracing/statsd_tracing.rb
|
588
593
|
- lib/graphql/tracing/trace.rb
|
@@ -595,6 +600,7 @@ files:
|
|
595
600
|
- lib/graphql/types/int.rb
|
596
601
|
- lib/graphql/types/iso_8601_date.rb
|
597
602
|
- lib/graphql/types/iso_8601_date_time.rb
|
603
|
+
- lib/graphql/types/iso_8601_duration.rb
|
598
604
|
- lib/graphql/types/json.rb
|
599
605
|
- lib/graphql/types/relay.rb
|
600
606
|
- lib/graphql/types/relay/base_connection.rb
|
@@ -621,7 +627,8 @@ metadata:
|
|
621
627
|
changelog_uri: https://github.com/rmosolgo/graphql-ruby/blob/master/CHANGELOG.md
|
622
628
|
source_code_uri: https://github.com/rmosolgo/graphql-ruby
|
623
629
|
bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
|
624
|
-
mailing_list_uri: https://
|
630
|
+
mailing_list_uri: https://buttondown.email/graphql-ruby
|
631
|
+
rubygems_mfa_required: 'true'
|
625
632
|
post_install_message:
|
626
633
|
rdoc_options: []
|
627
634
|
require_paths:
|
@@ -630,14 +637,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
630
637
|
requirements:
|
631
638
|
- - ">="
|
632
639
|
- !ruby/object:Gem::Version
|
633
|
-
version: 2.
|
640
|
+
version: 2.7.0
|
634
641
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
635
642
|
requirements:
|
636
643
|
- - ">="
|
637
644
|
- !ruby/object:Gem::Version
|
638
645
|
version: '0'
|
639
646
|
requirements: []
|
640
|
-
rubygems_version: 3.5.
|
647
|
+
rubygems_version: 3.5.12
|
641
648
|
signing_key:
|
642
649
|
specification_version: 4
|
643
650
|
summary: A GraphQL language and runtime for Ruby
|