graphql 1.9.21 → 1.10.0.pre1
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/core.rb +0 -1
- data/lib/generators/graphql/install_generator.rb +0 -1
- data/lib/generators/graphql/mutation_generator.rb +1 -1
- data/lib/generators/graphql/templates/base_field.erb +4 -0
- data/lib/generators/graphql/templates/graphql_controller.erb +0 -5
- data/lib/generators/graphql/templates/mutation.erb +1 -1
- data/lib/generators/graphql/templates/schema.erb +1 -1
- data/lib/graphql.rb +1 -11
- data/lib/graphql/analysis/ast.rb +2 -2
- data/lib/graphql/analysis/ast/analyzer.rb +4 -23
- data/lib/graphql/analysis/ast/max_query_complexity.rb +3 -3
- data/lib/graphql/analysis/ast/max_query_depth.rb +3 -7
- data/lib/graphql/analysis/ast/query_complexity.rb +2 -2
- data/lib/graphql/argument.rb +6 -2
- data/lib/graphql/backtrace/table.rb +10 -2
- data/lib/graphql/base_type.rb +5 -1
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +5 -9
- data/lib/graphql/define/assign_object_field.rb +2 -2
- data/lib/graphql/define/defined_object_proxy.rb +0 -3
- data/lib/graphql/define/instance_definable.rb +3 -14
- data/lib/graphql/enum_type.rb +4 -0
- data/lib/graphql/execution/directive_checks.rb +2 -2
- data/lib/graphql/execution/errors.rb +14 -15
- data/lib/graphql/execution/execute.rb +1 -1
- data/lib/graphql/execution/interpreter/runtime.rb +17 -39
- data/lib/graphql/execution/multiplex.rb +3 -3
- data/lib/graphql/field.rb +8 -0
- data/lib/graphql/filter.rb +1 -1
- data/lib/graphql/function.rb +1 -1
- data/lib/graphql/input_object_type.rb +1 -2
- data/lib/graphql/introspection/entry_points.rb +1 -2
- data/lib/graphql/introspection/input_value_type.rb +27 -9
- data/lib/graphql/introspection/schema_type.rb +1 -2
- data/lib/graphql/language/block_string.rb +2 -2
- data/lib/graphql/language/document_from_schema_definition.rb +5 -11
- data/lib/graphql/language/lexer.rb +48 -49
- data/lib/graphql/language/lexer.rl +48 -49
- data/lib/graphql/language/nodes.rb +11 -14
- data/lib/graphql/language/parser.rb +645 -650
- data/lib/graphql/language/parser.y +7 -8
- data/lib/graphql/language/token.rb +1 -1
- data/lib/graphql/non_null_type.rb +0 -10
- data/lib/graphql/pagination.rb +6 -0
- data/lib/graphql/pagination/active_record_relation_connection.rb +35 -0
- data/lib/graphql/pagination/array_connection.rb +78 -0
- data/lib/graphql/pagination/connection.rb +150 -0
- data/lib/graphql/pagination/connections.rb +103 -0
- data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
- data/lib/graphql/pagination/relation_connection.rb +157 -0
- data/lib/graphql/pagination/sequel_dataset_connection.rb +28 -0
- data/lib/graphql/query.rb +1 -7
- data/lib/graphql/query/arguments.rb +3 -9
- data/lib/graphql/query/context.rb +9 -31
- data/lib/graphql/query/literal_input.rb +29 -10
- data/lib/graphql/query/null_context.rb +0 -4
- data/lib/graphql/query/variable_validation_error.rb +1 -1
- data/lib/graphql/query/variables.rb +2 -4
- data/lib/graphql/relay/base_connection.rb +7 -3
- data/lib/graphql/relay/edges_instrumentation.rb +1 -1
- data/lib/graphql/relay/node.rb +2 -2
- data/lib/graphql/relay/relation_connection.rb +5 -9
- data/lib/graphql/schema.rb +27 -68
- data/lib/graphql/schema/argument.rb +31 -5
- data/lib/graphql/schema/base_64_bp.rb +2 -3
- data/lib/graphql/schema/build_from_definition.rb +113 -179
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +10 -4
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -1
- data/lib/graphql/schema/directive.rb +6 -7
- data/lib/graphql/schema/directive/feature.rb +1 -1
- data/lib/graphql/schema/enum.rb +1 -0
- data/lib/graphql/schema/enum_value.rb +4 -1
- data/lib/graphql/schema/field.rb +37 -39
- data/lib/graphql/schema/field/connection_extension.rb +11 -1
- data/lib/graphql/schema/input_object.rb +2 -5
- data/lib/graphql/schema/interface.rb +2 -0
- data/lib/graphql/schema/introspection_system.rb +1 -4
- data/lib/graphql/schema/loader.rb +6 -12
- data/lib/graphql/schema/member.rb +2 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +2 -2
- data/lib/graphql/schema/member/build_type.rb +4 -0
- data/lib/graphql/schema/member/cached_graphql_definition.rb +5 -0
- data/lib/graphql/schema/member/has_ast_node.rb +17 -0
- data/lib/graphql/schema/member/has_fields.rb +10 -16
- data/lib/graphql/schema/member/instrumentation.rb +1 -6
- data/lib/graphql/schema/member/type_system_helpers.rb +1 -1
- data/lib/graphql/schema/mutation.rb +1 -1
- data/lib/graphql/schema/object.rb +5 -6
- data/lib/graphql/schema/possible_types.rb +3 -3
- data/lib/graphql/schema/printer.rb +1 -3
- data/lib/graphql/schema/relay_classic_mutation.rb +2 -6
- data/lib/graphql/schema/resolver.rb +5 -35
- data/lib/graphql/schema/scalar.rb +1 -0
- data/lib/graphql/schema/subscription.rb +6 -6
- data/lib/graphql/schema/timeout_middleware.rb +2 -3
- data/lib/graphql/schema/type_expression.rb +27 -17
- data/lib/graphql/schema/union.rb +7 -26
- data/lib/graphql/schema/validation.rb +1 -17
- data/lib/graphql/schema/warden.rb +3 -77
- data/lib/graphql/schema/wrapper.rb +1 -1
- data/lib/graphql/static_validation/definition_dependencies.rb +12 -21
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +9 -4
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +10 -7
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +1 -1
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +5 -5
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +4 -4
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +3 -3
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +3 -3
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +5 -6
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +1 -1
- data/lib/graphql/subscriptions.rb +7 -7
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +2 -2
- data/lib/graphql/subscriptions/event.rb +5 -19
- data/lib/graphql/subscriptions/instrumentation.rb +9 -4
- data/lib/graphql/subscriptions/subscription_root.rb +2 -10
- data/lib/graphql/tracing/skylight_tracing.rb +0 -1
- data/lib/graphql/types/int.rb +1 -1
- data/lib/graphql/types/relay/base_connection.rb +3 -1
- data/lib/graphql/union_type.rb +23 -58
- data/lib/graphql/upgrader/member.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- metadata +20 -13
- data/lib/generators/graphql/templates/base_mutation.erb +0 -8
- data/lib/graphql/schema/type_membership.rb +0 -34
@@ -8,7 +8,7 @@ module GraphQL
|
|
8
8
|
@value = value
|
9
9
|
@validation_result = validation_result
|
10
10
|
|
11
|
-
msg = "Variable
|
11
|
+
msg = "Variable $#{variable_ast.name} of type #{type.to_type_signature} was provided invalid value"
|
12
12
|
|
13
13
|
if problem_fields.any?
|
14
14
|
msg += " for #{problem_fields.join(", ")}"
|
@@ -21,7 +21,7 @@ module GraphQL
|
|
21
21
|
# - First, use the value provided at runtime
|
22
22
|
# - Then, fall back to the default value from the query string
|
23
23
|
# If it's still nil, raise an error if it's required.
|
24
|
-
variable_type = schema.type_from_ast(ast_variable.type)
|
24
|
+
variable_type = schema.type_from_ast(ast_variable.type, context: ctx)
|
25
25
|
if variable_type.nil?
|
26
26
|
# Pass -- it will get handled by a validator
|
27
27
|
else
|
@@ -35,9 +35,7 @@ module GraphQL
|
|
35
35
|
if validation_result.valid?
|
36
36
|
if value_was_provided
|
37
37
|
# Add the variable if a value was provided
|
38
|
-
memo[variable_name] =
|
39
|
-
variable_type.coerce_input(provided_value, ctx)
|
40
|
-
end
|
38
|
+
memo[variable_name] = variable_type.coerce_input(provided_value, ctx)
|
41
39
|
elsif default_value != nil
|
42
40
|
# Add the variable if it wasn't provided but it has a default value (including `null`)
|
43
41
|
memo[variable_name] = GraphQL::Query::LiteralInput.coerce(variable_type, default_value, self)
|
@@ -25,6 +25,10 @@ module GraphQL
|
|
25
25
|
# @param nodes [Object] A collection of nodes (eg, Array, AR::Relation)
|
26
26
|
# @return [subclass of BaseConnection] a connection Class for wrapping `nodes`
|
27
27
|
def connection_for_nodes(nodes)
|
28
|
+
# If it's a new-style connection object, it's already ready to go
|
29
|
+
if nodes.is_a?(GraphQL::Pagination::Connection)
|
30
|
+
return nodes
|
31
|
+
end
|
28
32
|
# Check for class _names_ because classes can be redefined in Rails development
|
29
33
|
nodes.class.ancestors.each do |ancestor|
|
30
34
|
conn_impl = CONNECTION_IMPLEMENTATIONS[ancestor.name]
|
@@ -139,7 +143,7 @@ module GraphQL
|
|
139
143
|
|
140
144
|
# An opaque operation which returns a connection-specific cursor.
|
141
145
|
def cursor_from_node(object)
|
142
|
-
raise
|
146
|
+
raise NotImplementedError, "must return a cursor for this object/connection pair"
|
143
147
|
end
|
144
148
|
|
145
149
|
def inspect
|
@@ -161,11 +165,11 @@ module GraphQL
|
|
161
165
|
end
|
162
166
|
|
163
167
|
def paged_nodes
|
164
|
-
raise
|
168
|
+
raise NotImplementedError, "must return nodes for this connection after paging"
|
165
169
|
end
|
166
170
|
|
167
171
|
def sliced_nodes
|
168
|
-
raise
|
172
|
+
raise NotImplementedError, "must return all nodes for this connection after chopping off first and last"
|
169
173
|
end
|
170
174
|
end
|
171
175
|
end
|
data/lib/graphql/relay/node.rb
CHANGED
@@ -11,7 +11,7 @@ module GraphQL
|
|
11
11
|
field = GraphQL::Types::Relay::NodeField.graphql_definition
|
12
12
|
|
13
13
|
if kwargs.any? || block
|
14
|
-
field = field.redefine(
|
14
|
+
field = field.redefine(kwargs, &block)
|
15
15
|
end
|
16
16
|
|
17
17
|
field
|
@@ -21,7 +21,7 @@ module GraphQL
|
|
21
21
|
field = GraphQL::Types::Relay::NodesField.graphql_definition
|
22
22
|
|
23
23
|
if kwargs.any? || block
|
24
|
-
field = field.redefine(
|
24
|
+
field = field.redefine(kwargs, &block)
|
25
25
|
end
|
26
26
|
|
27
27
|
field
|
@@ -25,16 +25,12 @@ module GraphQL
|
|
25
25
|
|
26
26
|
def has_next_page
|
27
27
|
if first
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
if GraphQL::Relay::ConnectionType.bidirectional_pagination && last
|
35
|
-
return sliced_nodes_count >= last
|
28
|
+
paged_nodes.length >= first && sliced_nodes_count > first
|
29
|
+
elsif GraphQL::Relay::ConnectionType.bidirectional_pagination && last
|
30
|
+
sliced_nodes_count >= last
|
31
|
+
else
|
32
|
+
false
|
36
33
|
end
|
37
|
-
false
|
38
34
|
end
|
39
35
|
|
40
36
|
def has_previous_page
|
data/lib/graphql/schema.rb
CHANGED
@@ -40,7 +40,6 @@ require "graphql/schema/directive/include"
|
|
40
40
|
require "graphql/schema/directive/skip"
|
41
41
|
require "graphql/schema/directive/feature"
|
42
42
|
require "graphql/schema/directive/transform"
|
43
|
-
require "graphql/schema/type_membership"
|
44
43
|
|
45
44
|
require "graphql/schema/resolver"
|
46
45
|
require "graphql/schema/mutation"
|
@@ -82,6 +81,7 @@ module GraphQL
|
|
82
81
|
class Schema
|
83
82
|
extend Forwardable
|
84
83
|
extend GraphQL::Schema::Member::AcceptsDefinition
|
84
|
+
extend GraphQL::Schema::Member::HasAstNode
|
85
85
|
include GraphQL::Define::InstanceDefinable
|
86
86
|
extend GraphQL::Schema::FindInheritedValue
|
87
87
|
|
@@ -99,8 +99,6 @@ module GraphQL
|
|
99
99
|
mutation: ->(schema, t) { schema.mutation = t.respond_to?(:graphql_definition) ? t.graphql_definition : t },
|
100
100
|
subscription: ->(schema, t) { schema.subscription = t.respond_to?(:graphql_definition) ? t.graphql_definition : t },
|
101
101
|
disable_introspection_entry_points: ->(schema) { schema.disable_introspection_entry_points = true },
|
102
|
-
disable_schema_introspection_entry_point: ->(schema) { schema.disable_schema_introspection_entry_point = true },
|
103
|
-
disable_type_introspection_entry_point: ->(schema) { schema.disable_type_introspection_entry_point = true },
|
104
102
|
directives: ->(schema, directives) { schema.directives = directives.reduce({}) { |m, d| m[d.name] = d; m } },
|
105
103
|
directive: ->(schema, directive) { schema.directives[directive.graphql_name] = directive },
|
106
104
|
instrument: ->(schema, type, instrumenter, after_built_ins: false) {
|
@@ -156,12 +154,6 @@ module GraphQL
|
|
156
154
|
# [Boolean] True if this object disables the introspection entry point fields
|
157
155
|
attr_accessor :disable_introspection_entry_points
|
158
156
|
|
159
|
-
# [Boolean] True if this object disables the __schema introspection entry point field
|
160
|
-
attr_accessor :disable_schema_introspection_entry_point
|
161
|
-
|
162
|
-
# [Boolean] True if this object disables the __type introspection entry point field
|
163
|
-
attr_accessor :disable_type_introspection_entry_point
|
164
|
-
|
165
157
|
class << self
|
166
158
|
attr_writer :default_execution_strategy
|
167
159
|
end
|
@@ -211,8 +203,6 @@ module GraphQL
|
|
211
203
|
@interpreter = false
|
212
204
|
@error_bubbling = false
|
213
205
|
@disable_introspection_entry_points = false
|
214
|
-
@disable_schema_introspection_entry_point = false
|
215
|
-
@disable_type_introspection_entry_point = false
|
216
206
|
end
|
217
207
|
|
218
208
|
# @return [Boolean] True if using the new {GraphQL::Execution::Interpreter}
|
@@ -282,7 +272,7 @@ module GraphQL
|
|
282
272
|
query = GraphQL::Query.new(self, document: doc, context: context)
|
283
273
|
validator_opts = { schema: self }
|
284
274
|
rules && (validator_opts[:rules] = rules)
|
285
|
-
validator = GraphQL::StaticValidation::Validator.new(
|
275
|
+
validator = GraphQL::StaticValidation::Validator.new(validator_opts)
|
286
276
|
res = validator.validate(query)
|
287
277
|
res[:errors]
|
288
278
|
end
|
@@ -292,13 +282,13 @@ module GraphQL
|
|
292
282
|
ensure_defined
|
293
283
|
# Assert that all necessary configs are present:
|
294
284
|
validation_error = Validation.validate(self)
|
295
|
-
validation_error && raise(
|
285
|
+
validation_error && raise(NotImplementedError, validation_error)
|
296
286
|
rebuild_artifacts
|
297
287
|
|
298
288
|
@definition_error = nil
|
299
289
|
nil
|
300
290
|
rescue StandardError => err
|
301
|
-
if @raise_definition_error || err.is_a?(CyclicalDefinitionError)
|
291
|
+
if @raise_definition_error || err.is_a?(CyclicalDefinitionError)
|
302
292
|
raise
|
303
293
|
else
|
304
294
|
# Raise this error _later_ to avoid messing with Rails constant loading
|
@@ -453,17 +443,16 @@ module GraphQL
|
|
453
443
|
@instrumented_field_map[type.graphql_name]
|
454
444
|
end
|
455
445
|
|
456
|
-
def type_from_ast(ast_node)
|
446
|
+
def type_from_ast(ast_node, context:)
|
457
447
|
GraphQL::Schema::TypeExpression.build_type(self.types, ast_node)
|
458
448
|
end
|
459
449
|
|
460
450
|
# @see [GraphQL::Schema::Warden] Restricted access to members of a schema
|
461
451
|
# @param type_defn [GraphQL::InterfaceType, GraphQL::UnionType] the type whose members you want to retrieve
|
462
|
-
# @param context [GraphQL::Query::Context] The context for the current query
|
463
452
|
# @return [Array<GraphQL::ObjectType>] types which belong to `type_defn` in this schema
|
464
|
-
def possible_types(type_defn
|
453
|
+
def possible_types(type_defn)
|
465
454
|
@possible_types ||= GraphQL::Schema::PossibleTypes.new(self)
|
466
|
-
@possible_types.possible_types(type_defn
|
455
|
+
@possible_types.possible_types(type_defn)
|
467
456
|
end
|
468
457
|
|
469
458
|
# @see [GraphQL::Schema::Warden] Resticted access to root types
|
@@ -504,7 +493,7 @@ module GraphQL
|
|
504
493
|
def resolve_type(type, object, ctx = :__undefined__)
|
505
494
|
check_resolved_type(type, object, ctx) do |ok_type, ok_object, ok_ctx|
|
506
495
|
if @resolve_type_proc.nil?
|
507
|
-
raise(
|
496
|
+
raise(NotImplementedError, "Can't determine GraphQL type for: #{ok_object.inspect}, define `resolve_type (type, obj, ctx) -> { ... }` inside `Schema.define`.")
|
508
497
|
end
|
509
498
|
@resolve_type_proc.call(ok_type, ok_object, ok_ctx)
|
510
499
|
end
|
@@ -565,7 +554,7 @@ module GraphQL
|
|
565
554
|
# @return [Any] The application object identified by `id`
|
566
555
|
def object_from_id(id, ctx)
|
567
556
|
if @object_from_id_proc.nil?
|
568
|
-
raise(
|
557
|
+
raise(NotImplementedError, "Can't fetch an object for id \"#{id}\" because the schema's `object_from_id (id, ctx) -> { ... }` function is not defined")
|
569
558
|
else
|
570
559
|
@object_from_id_proc.call(id, ctx)
|
571
560
|
end
|
@@ -609,7 +598,6 @@ module GraphQL
|
|
609
598
|
alias :_schema_class :class
|
610
599
|
def_delegators :_schema_class, :visible?, :accessible?, :authorized?, :unauthorized_object, :unauthorized_field, :inaccessible_fields
|
611
600
|
def_delegators :_schema_class, :directive
|
612
|
-
def_delegators :_schema_class, :error_handler
|
613
601
|
|
614
602
|
# A function to call when {#execute} receives an invalid query string
|
615
603
|
#
|
@@ -633,7 +621,7 @@ module GraphQL
|
|
633
621
|
# @return [String] a unique identifier for `object` which clients can use to refetch it
|
634
622
|
def id_from_object(object, type, ctx)
|
635
623
|
if @id_from_object_proc.nil?
|
636
|
-
raise(
|
624
|
+
raise(NotImplementedError, "Can't generate an ID for #{object.inspect} of type #{type}, schema's `id_from_object` must be defined")
|
637
625
|
else
|
638
626
|
@id_from_object_proc.call(object, type, ctx)
|
639
627
|
end
|
@@ -689,12 +677,9 @@ module GraphQL
|
|
689
677
|
end
|
690
678
|
|
691
679
|
# Return the GraphQL::Language::Document IDL AST for the schema
|
692
|
-
# @param context [Hash]
|
693
|
-
# @param only [<#call(member, ctx)>]
|
694
|
-
# @param except [<#call(member, ctx)>]
|
695
680
|
# @return [GraphQL::Language::Document]
|
696
|
-
def to_document
|
697
|
-
GraphQL::Language::DocumentFromSchemaDefinition.new(self
|
681
|
+
def to_document
|
682
|
+
GraphQL::Language::DocumentFromSchemaDefinition.new(self).document
|
698
683
|
end
|
699
684
|
|
700
685
|
# Return the Hash response of {Introspection::INTROSPECTION_QUERY}.
|
@@ -713,6 +698,12 @@ module GraphQL
|
|
713
698
|
JSON.pretty_generate(as_json(*args))
|
714
699
|
end
|
715
700
|
|
701
|
+
def new_connections?
|
702
|
+
!!connections
|
703
|
+
end
|
704
|
+
|
705
|
+
attr_accessor :connections
|
706
|
+
|
716
707
|
class << self
|
717
708
|
extend Forwardable
|
718
709
|
# For compatibility, these methods all:
|
@@ -721,7 +712,7 @@ module GraphQL
|
|
721
712
|
# Eventually, the methods will be moved into this class, removing the need for the singleton.
|
722
713
|
def_delegators :graphql_definition,
|
723
714
|
# Schema structure
|
724
|
-
:as_json, :to_json, :to_document, :to_definition,
|
715
|
+
:as_json, :to_json, :to_document, :to_definition,
|
725
716
|
# Execution
|
726
717
|
:execute, :multiplex,
|
727
718
|
:static_validator, :introspection_system,
|
@@ -745,15 +736,13 @@ module GraphQL
|
|
745
736
|
:union_memberships,
|
746
737
|
:get_field, :root_types, :references_to, :type_from_ast,
|
747
738
|
:possible_types,
|
748
|
-
:disable_introspection_entry_points
|
749
|
-
:disable_schema_introspection_entry_point=,
|
750
|
-
:disable_type_introspection_entry_point=
|
739
|
+
:disable_introspection_entry_points=
|
751
740
|
|
752
741
|
def graphql_definition
|
753
742
|
@graphql_definition ||= to_graphql
|
754
743
|
end
|
755
744
|
|
756
|
-
def use(plugin,
|
745
|
+
def use(plugin, options = {})
|
757
746
|
own_plugins << [plugin, options]
|
758
747
|
end
|
759
748
|
|
@@ -773,8 +762,6 @@ module GraphQL
|
|
773
762
|
schema_defn.default_max_page_size = default_max_page_size
|
774
763
|
schema_defn.orphan_types = orphan_types
|
775
764
|
schema_defn.disable_introspection_entry_points = disable_introspection_entry_points?
|
776
|
-
schema_defn.disable_schema_introspection_entry_point = disable_schema_introspection_entry_point?
|
777
|
-
schema_defn.disable_type_introspection_entry_point = disable_type_introspection_entry_point?
|
778
765
|
|
779
766
|
prepped_dirs = {}
|
780
767
|
directives.each { |k, v| prepped_dirs[k] = v.graphql_definition}
|
@@ -828,6 +815,9 @@ module GraphQL
|
|
828
815
|
schema_defn
|
829
816
|
end
|
830
817
|
|
818
|
+
# @return [GraphQL::Pagination::Connections] if installed
|
819
|
+
attr_accessor :connections
|
820
|
+
|
831
821
|
def query(new_query_object = nil)
|
832
822
|
if new_query_object
|
833
823
|
@query_object = new_query_object
|
@@ -930,14 +920,6 @@ module GraphQL
|
|
930
920
|
@disable_introspection_entry_points = true
|
931
921
|
end
|
932
922
|
|
933
|
-
def disable_schema_introspection_entry_point
|
934
|
-
@disable_schema_introspection_entry_point = true
|
935
|
-
end
|
936
|
-
|
937
|
-
def disable_type_introspection_entry_point
|
938
|
-
@disable_type_introspection_entry_point = true
|
939
|
-
end
|
940
|
-
|
941
923
|
def disable_introspection_entry_points?
|
942
924
|
if instance_variable_defined?(:@disable_introspection_entry_points)
|
943
925
|
@disable_introspection_entry_points
|
@@ -946,22 +928,6 @@ module GraphQL
|
|
946
928
|
end
|
947
929
|
end
|
948
930
|
|
949
|
-
def disable_schema_introspection_entry_point?
|
950
|
-
if instance_variable_defined?(:@disable_schema_introspection_entry_point)
|
951
|
-
@disable_schema_introspection_entry_point
|
952
|
-
else
|
953
|
-
find_inherited_value(:disable_schema_introspection_entry_point?, false)
|
954
|
-
end
|
955
|
-
end
|
956
|
-
|
957
|
-
def disable_type_introspection_entry_point?
|
958
|
-
if instance_variable_defined?(:@disable_type_introspection_entry_point)
|
959
|
-
@disable_type_introspection_entry_point
|
960
|
-
else
|
961
|
-
find_inherited_value(:disable_type_introspection_entry_point?, false)
|
962
|
-
end
|
963
|
-
end
|
964
|
-
|
965
931
|
def orphan_types(*new_orphan_types)
|
966
932
|
if new_orphan_types.any?
|
967
933
|
own_orphan_types.concat(new_orphan_types.flatten)
|
@@ -1000,16 +966,16 @@ module GraphQL
|
|
1000
966
|
if type.kind.object?
|
1001
967
|
type
|
1002
968
|
else
|
1003
|
-
raise
|
969
|
+
raise NotImplementedError, "#{self.name}.resolve_type(type, obj, ctx) must be implemented to use Union types or Interface types (tried to resolve: #{type.name})"
|
1004
970
|
end
|
1005
971
|
end
|
1006
972
|
|
1007
973
|
def object_from_id(node_id, ctx)
|
1008
|
-
raise
|
974
|
+
raise NotImplementedError, "#{self.name}.object_from_id(node_id, ctx) must be implemented to load by ID (tried to load from id `#{node_id}`)"
|
1009
975
|
end
|
1010
976
|
|
1011
977
|
def id_from_object(object, type, ctx)
|
1012
|
-
raise
|
978
|
+
raise NotImplementedError, "#{self.name}.id_from_object(object, type, ctx) must be implemented to create global ids (tried to create an id for `#{object.inspect}`)"
|
1013
979
|
end
|
1014
980
|
|
1015
981
|
def visible?(member, context)
|
@@ -1071,13 +1037,6 @@ module GraphQL
|
|
1071
1037
|
DefaultTypeError.call(type_err, ctx)
|
1072
1038
|
end
|
1073
1039
|
|
1074
|
-
attr_writer :error_handler
|
1075
|
-
|
1076
|
-
# @return [GraphQL::Execution::Errors, Class<GraphQL::Execution::Errors::NullErrorHandler>]
|
1077
|
-
def error_handler
|
1078
|
-
@error_handler ||= GraphQL::Execution::Errors::NullErrorHandler
|
1079
|
-
end
|
1080
|
-
|
1081
1040
|
def lazy_resolve(lazy_class, value_method)
|
1082
1041
|
lazy_classes[lazy_class] = value_method
|
1083
1042
|
end
|
@@ -5,6 +5,7 @@ module GraphQL
|
|
5
5
|
include GraphQL::Schema::Member::CachedGraphQLDefinition
|
6
6
|
include GraphQL::Schema::Member::AcceptsDefinition
|
7
7
|
include GraphQL::Schema::Member::HasPath
|
8
|
+
include GraphQL::Schema::Member::HasAstNode
|
8
9
|
|
9
10
|
NO_DEFAULT = :__no_default__
|
10
11
|
|
@@ -93,7 +94,35 @@ module GraphQL
|
|
93
94
|
true
|
94
95
|
end
|
95
96
|
|
96
|
-
def authorized?(obj, ctx)
|
97
|
+
def authorized?(obj, value, ctx)
|
98
|
+
authorized_as_type?(obj, value, ctx, as_type: type)
|
99
|
+
end
|
100
|
+
|
101
|
+
def authorized_as_type?(obj, value, ctx, as_type:)
|
102
|
+
if value.nil?
|
103
|
+
return true
|
104
|
+
end
|
105
|
+
|
106
|
+
if as_type.kind.non_null?
|
107
|
+
as_type = as_type.of_type
|
108
|
+
end
|
109
|
+
|
110
|
+
if as_type.kind.list?
|
111
|
+
value.each do |v|
|
112
|
+
if !authorized_as_type?(obj, v, ctx, as_type: as_type.of_type)
|
113
|
+
return false
|
114
|
+
end
|
115
|
+
end
|
116
|
+
elsif as_type.kind.input_object?
|
117
|
+
as_type.arguments.each do |_name, input_obj_arg|
|
118
|
+
input_obj_arg = input_obj_arg.type_class
|
119
|
+
if value.key?(input_obj_arg.keyword) && !input_obj_arg.authorized?(obj, value[input_obj_arg.keyword], ctx)
|
120
|
+
return false
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
# None of the early-return conditions were activated,
|
125
|
+
# so this is authorized.
|
97
126
|
true
|
98
127
|
end
|
99
128
|
|
@@ -104,6 +133,7 @@ module GraphQL
|
|
104
133
|
argument.description = @description
|
105
134
|
argument.metadata[:type_class] = self
|
106
135
|
argument.as = @as
|
136
|
+
argument.ast_node = ast_node
|
107
137
|
argument.method_access = @method_access
|
108
138
|
if NO_DEFAULT != @default_value
|
109
139
|
argument.default_value = @default_value
|
@@ -121,10 +151,6 @@ module GraphQL
|
|
121
151
|
# Used by the runtime.
|
122
152
|
# @api private
|
123
153
|
def prepare_value(obj, value)
|
124
|
-
if value.is_a?(GraphQL::Schema::InputObject)
|
125
|
-
value = value.prepare
|
126
|
-
end
|
127
|
-
|
128
154
|
if @prepare.nil?
|
129
155
|
value
|
130
156
|
elsif @prepare.is_a?(String) || @prepare.is_a?(Symbol)
|
@@ -10,9 +10,8 @@ module Base64Bp
|
|
10
10
|
module_function
|
11
11
|
|
12
12
|
def urlsafe_encode64(bin, padding:)
|
13
|
-
str = strict_encode64(bin)
|
14
|
-
str.
|
15
|
-
str.delete!("=") unless padding
|
13
|
+
str = strict_encode64(bin).tr("+/", "-_")
|
14
|
+
str = str.delete("=") unless padding
|
16
15
|
str
|
17
16
|
end
|
18
17
|
|