graphql 2.0.21 → 2.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/backtrace.rb +0 -4
- data/lib/graphql/execution/interpreter/arguments_cache.rb +31 -30
- data/lib/graphql/execution/interpreter/runtime.rb +101 -83
- data/lib/graphql/execution/interpreter.rb +1 -2
- data/lib/graphql/execution/lookahead.rb +1 -1
- data/lib/graphql/filter.rb +2 -1
- data/lib/graphql/language/document_from_schema_definition.rb +16 -9
- data/lib/graphql/language/lexer.rb +5 -3
- data/lib/graphql/language/printer.rb +28 -14
- data/lib/graphql/query/context.rb +16 -7
- data/lib/graphql/query/null_context.rb +8 -18
- data/lib/graphql/query.rb +21 -11
- data/lib/graphql/schema/always_visible.rb +10 -0
- data/lib/graphql/schema/argument.rb +5 -5
- data/lib/graphql/schema/enum_value.rb +1 -1
- data/lib/graphql/schema/field/connection_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +23 -12
- data/lib/graphql/schema/input_object.rb +1 -1
- data/lib/graphql/schema/member/has_arguments.rb +9 -7
- data/lib/graphql/schema/object.rb +1 -1
- data/lib/graphql/schema/printer.rb +3 -1
- data/lib/graphql/schema/relay_classic_mutation.rb +1 -1
- data/lib/graphql/schema/resolver.rb +4 -4
- data/lib/graphql/schema/timeout.rb +1 -1
- data/lib/graphql/schema/warden.rb +37 -4
- data/lib/graphql/schema.rb +29 -14
- data/lib/graphql/tracing/legacy_trace.rb +5 -1
- data/lib/graphql/tracing/notifications_trace.rb +3 -0
- data/lib/graphql/tracing.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- metadata +4 -3
@@ -38,8 +38,9 @@ module GraphQL
|
|
38
38
|
# @api private
|
39
39
|
class Warden
|
40
40
|
def self.from_context(context)
|
41
|
-
context.warden
|
42
|
-
rescue
|
41
|
+
context.warden || PassThruWarden
|
42
|
+
rescue NoMethodError
|
43
|
+
# this might be a hash which won't respond to #warden
|
43
44
|
PassThruWarden
|
44
45
|
end
|
45
46
|
|
@@ -87,17 +88,49 @@ module GraphQL
|
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
91
|
+
class NullWarden
|
92
|
+
def initialize(_filter = nil, context:, schema:)
|
93
|
+
@schema = schema
|
94
|
+
end
|
95
|
+
|
96
|
+
def visible_field?(field_defn, _ctx = nil, owner = nil); true; end
|
97
|
+
def visible_argument?(arg_defn, _ctx = nil); true; end
|
98
|
+
def visible_type?(type_defn, _ctx = nil); true; end
|
99
|
+
def visible_enum_value?(enum_value, _ctx = nil); true; end
|
100
|
+
def visible_type_membership?(type_membership, _ctx = nil); true; end
|
101
|
+
def interface_type_memberships(obj_type, _ctx = nil); obj_type.interface_type_memberships; end
|
102
|
+
def get_type(type_name); @schema.get_type(type_name); end # rubocop:disable Development/ContextIsPassedCop
|
103
|
+
def arguments(argument_owner, ctx = nil); argument_owner.all_argument_definitions; end
|
104
|
+
def enum_values(enum_defn); enum_defn.enum_values; end # rubocop:disable Development/ContextIsPassedCop
|
105
|
+
def get_argument(parent_type, argument_name); parent_type.get_argument(argument_name); end # rubocop:disable Development/ContextIsPassedCop
|
106
|
+
def types; @schema.types; end # rubocop:disable Development/ContextIsPassedCop
|
107
|
+
def root_type_for_operation(op_name); @schema.root_type_for_operation(op_name); end
|
108
|
+
def directives; @schema.directives.values; end
|
109
|
+
def fields(type_defn); type_defn.all_field_definitions; end # rubocop:disable Development/ContextIsPassedCop
|
110
|
+
def get_field(parent_type, field_name); @schema.get_field(parent_type, field_name); end
|
111
|
+
def reachable_type?(type_name); true; end
|
112
|
+
def reachable_types; @schema.types.values; end # rubocop:disable Development/ContextIsPassedCop
|
113
|
+
def possible_types(type_defn); @schema.possible_types(type_defn); end
|
114
|
+
def interfaces(obj_type); obj_type.interfaces; end
|
115
|
+
end
|
116
|
+
|
90
117
|
# @param filter [<#call(member)>] Objects are hidden when `.call(member, ctx)` returns true
|
91
118
|
# @param context [GraphQL::Query::Context]
|
92
119
|
# @param schema [GraphQL::Schema]
|
93
|
-
def initialize(filter, context:, schema:)
|
120
|
+
def initialize(filter = nil, context:, schema:)
|
94
121
|
@schema = schema
|
95
122
|
# Cache these to avoid repeated hits to the inheritance chain when one isn't present
|
96
123
|
@query = @schema.query
|
97
124
|
@mutation = @schema.mutation
|
98
125
|
@subscription = @schema.subscription
|
99
126
|
@context = context
|
100
|
-
@visibility_cache =
|
127
|
+
@visibility_cache = if filter
|
128
|
+
read_through { |m| filter.call(m, context) }
|
129
|
+
else
|
130
|
+
read_through { |m| schema.visible?(m, context) }
|
131
|
+
end
|
132
|
+
|
133
|
+
@visibility_cache.compare_by_identity
|
101
134
|
# Initialize all ivars to improve object shape consistency:
|
102
135
|
@types = @visible_types = @reachable_types = @visible_parent_fields =
|
103
136
|
@visible_possible_types = @visible_fields = @visible_arguments = @visible_enum_arrays =
|
data/lib/graphql/schema.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "graphql/schema/addition"
|
3
|
+
require "graphql/schema/always_visible"
|
3
4
|
require "graphql/schema/base_64_encoder"
|
4
5
|
require "graphql/schema/find_inherited_value"
|
5
6
|
require "graphql/schema/finder"
|
@@ -157,14 +158,17 @@ module GraphQL
|
|
157
158
|
def trace_class_for(mode)
|
158
159
|
@trace_modes ||= {}
|
159
160
|
@trace_modes[mode] ||= begin
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
161
|
+
if mode == :default_backtrace
|
162
|
+
schema_base_class = trace_class_for(:default)
|
163
|
+
Class.new(schema_base_class) do
|
164
|
+
include(GraphQL::Backtrace::Trace)
|
165
|
+
end
|
166
|
+
elsif superclass.respond_to?(:trace_class_for)
|
167
|
+
superclass_base_class = superclass.trace_class_for(mode)
|
168
|
+
Class.new(superclass_base_class)
|
164
169
|
else
|
165
|
-
GraphQL::Tracing::Trace
|
170
|
+
Class.new(GraphQL::Tracing::Trace)
|
166
171
|
end
|
167
|
-
Class.new(base_class)
|
168
172
|
end
|
169
173
|
end
|
170
174
|
|
@@ -244,11 +248,13 @@ module GraphQL
|
|
244
248
|
end
|
245
249
|
|
246
250
|
def default_filter
|
247
|
-
GraphQL::Filter.new(except: default_mask
|
251
|
+
GraphQL::Filter.new(except: default_mask)
|
248
252
|
end
|
249
253
|
|
250
254
|
def default_mask(new_mask = nil)
|
251
255
|
if new_mask
|
256
|
+
line = caller(2, 10).find { |l| !l.include?("lib/graphql") }
|
257
|
+
GraphQL::Deprecation.warn("GraphQL::Filter and Schema.mask are deprecated and will be removed in v2.1.0. Implement `visible?` on your schema members instead (https://graphql-ruby.org/authorization/visibility.html).\n #{line}")
|
252
258
|
@own_default_mask = new_mask
|
253
259
|
else
|
254
260
|
@own_default_mask || find_inherited_value(:default_mask, Schema::NullMask)
|
@@ -418,6 +424,18 @@ module GraphQL
|
|
418
424
|
@root_types
|
419
425
|
end
|
420
426
|
|
427
|
+
def warden_class
|
428
|
+
if defined?(@warden_class)
|
429
|
+
@warden_class
|
430
|
+
elsif superclass.respond_to?(:warden_class)
|
431
|
+
superclass.warden_class
|
432
|
+
else
|
433
|
+
GraphQL::Schema::Warden
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
attr_writer :warden_class
|
438
|
+
|
421
439
|
# @param type [Module] The type definition whose possible types you want to see
|
422
440
|
# @return [Hash<String, Module>] All possible types, if no `type` is given.
|
423
441
|
# @return [Array<Module>] Possible types for `type`, if it's given.
|
@@ -959,10 +977,8 @@ module GraphQL
|
|
959
977
|
end
|
960
978
|
|
961
979
|
def tracer(new_tracer)
|
962
|
-
if
|
963
|
-
|
964
|
-
else
|
965
|
-
trace_mode(:default, Class.new(GraphQL::Tracing::LegacyTrace))
|
980
|
+
if !(trace_class_for(:default) < GraphQL::Tracing::CallLegacyTracers)
|
981
|
+
trace_with(GraphQL::Tracing::CallLegacyTracers)
|
966
982
|
end
|
967
983
|
|
968
984
|
own_tracers << new_tracer
|
@@ -988,9 +1004,7 @@ module GraphQL
|
|
988
1004
|
end
|
989
1005
|
|
990
1006
|
def new_trace(**options)
|
991
|
-
|
992
|
-
options = trace_options.merge(options)
|
993
|
-
end
|
1007
|
+
options = trace_options.merge(options)
|
994
1008
|
trace_mode = if (target = options[:query] || options[:multiplex]) && target.context[:backtrace]
|
995
1009
|
:default_backtrace
|
996
1010
|
else
|
@@ -1036,6 +1050,7 @@ module GraphQL
|
|
1036
1050
|
{
|
1037
1051
|
backtrace: ctx[:backtrace],
|
1038
1052
|
tracers: ctx[:tracers],
|
1053
|
+
trace: ctx[:trace],
|
1039
1054
|
dataloader: ctx[:dataloader],
|
1040
1055
|
}
|
1041
1056
|
else
|
@@ -4,7 +4,7 @@ module GraphQL
|
|
4
4
|
# This trace class calls legacy-style tracer with payload hashes.
|
5
5
|
# New-style `trace_with` modules significantly reduce the overhead of tracing,
|
6
6
|
# but that advantage is lost when legacy-style tracers are also used (since the payload hashes are still constructed).
|
7
|
-
|
7
|
+
module CallLegacyTracers
|
8
8
|
def lex(query_string:)
|
9
9
|
(@multiplex || @query).trace("lex", { query_string: query_string }) { super }
|
10
10
|
end
|
@@ -61,5 +61,9 @@ module GraphQL
|
|
61
61
|
query.trace("resolve_type_lazy", { context: query.context, type: type, object: object, path: query.context[:current_path] }) { super }
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
class LegacyTrace < Trace
|
66
|
+
include CallLegacyTracers
|
67
|
+
end
|
64
68
|
end
|
65
69
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "graphql/tracing/platform_trace"
|
4
|
+
|
3
5
|
module GraphQL
|
4
6
|
module Tracing
|
5
7
|
# This implementation forwards events to a notification handler (i.e.
|
@@ -20,6 +22,7 @@ module GraphQL
|
|
20
22
|
"validate" => "validate.graphql",
|
21
23
|
"analyze_multiplex" => "analyze_multiplex.graphql",
|
22
24
|
"analyze_query" => "analyze_query.graphql",
|
25
|
+
"execute_multiplex" => "execute_multiplex.graphql",
|
23
26
|
"execute_query" => "execute_query.graphql",
|
24
27
|
"execute_query_lazy" => "execute_query_lazy.graphql",
|
25
28
|
"execute_field" => "execute_field.graphql",
|
data/lib/graphql/tracing.rb
CHANGED
@@ -14,6 +14,7 @@ require "graphql/tracing/statsd_tracing"
|
|
14
14
|
require "graphql/tracing/prometheus_tracing"
|
15
15
|
|
16
16
|
# New Tracing:
|
17
|
+
require "graphql/tracing/active_support_notifications_trace"
|
17
18
|
require "graphql/tracing/platform_trace"
|
18
19
|
require "graphql/tracing/appoptics_trace"
|
19
20
|
require "graphql/tracing/appsignal_trace"
|
data/lib/graphql/version.rb
CHANGED
data/readme.md
CHANGED
@@ -44,6 +44,6 @@ I also sell [GraphQL::Pro](https://graphql.pro) which provides several features
|
|
44
44
|
|
45
45
|
## Getting Involved
|
46
46
|
|
47
|
-
- __Say hi & ask questions__ in the #graphql-ruby channel on [Discord](https://discord.com/invite/xud7bH9)
|
47
|
+
- __Say hi & ask questions__ in the #graphql-ruby channel on [Discord](https://discord.com/invite/xud7bH9).
|
48
48
|
- __Report bugs__ by posting a description, full stack trace, and all relevant code in a [GitHub issue](https://github.com/rmosolgo/graphql-ruby/issues).
|
49
49
|
- __Start hacking__ with the [Development guide](https://graphql-ruby.org/development).
|
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.0.
|
4
|
+
version: 2.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -395,6 +395,7 @@ files:
|
|
395
395
|
- lib/graphql/runtime_type_error.rb
|
396
396
|
- lib/graphql/schema.rb
|
397
397
|
- lib/graphql/schema/addition.rb
|
398
|
+
- lib/graphql/schema/always_visible.rb
|
398
399
|
- lib/graphql/schema/argument.rb
|
399
400
|
- lib/graphql/schema/base_64_bp.rb
|
400
401
|
- lib/graphql/schema/base_64_encoder.rb
|
@@ -622,7 +623,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
622
623
|
- !ruby/object:Gem::Version
|
623
624
|
version: '0'
|
624
625
|
requirements: []
|
625
|
-
rubygems_version: 3.4.
|
626
|
+
rubygems_version: 3.4.13
|
626
627
|
signing_key:
|
627
628
|
specification_version: 4
|
628
629
|
summary: A GraphQL language and runtime for Ruby
|