graphql 1.11.6 → 1.13.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/generators/graphql/core.rb +3 -8
- data/lib/generators/graphql/enum_generator.rb +4 -10
- data/lib/generators/graphql/field_extractor.rb +31 -0
- data/lib/generators/graphql/input_generator.rb +50 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +34 -0
- data/lib/generators/graphql/install_generator.rb +17 -7
- data/lib/generators/graphql/interface_generator.rb +7 -7
- data/lib/generators/graphql/loader_generator.rb +1 -0
- data/lib/generators/graphql/mutation_create_generator.rb +22 -0
- data/lib/generators/graphql/mutation_delete_generator.rb +22 -0
- data/lib/generators/graphql/mutation_generator.rb +6 -30
- data/lib/generators/graphql/mutation_update_generator.rb +22 -0
- data/lib/generators/graphql/object_generator.rb +12 -38
- data/lib/generators/graphql/orm_mutations_base.rb +40 -0
- data/lib/generators/graphql/relay.rb +63 -0
- data/lib/generators/graphql/relay_generator.rb +21 -0
- data/lib/generators/graphql/scalar_generator.rb +4 -2
- data/lib/generators/graphql/templates/base_connection.erb +8 -0
- data/lib/generators/graphql/templates/base_edge.erb +8 -0
- data/lib/generators/graphql/templates/enum.erb +5 -1
- data/lib/generators/graphql/templates/graphql_controller.erb +2 -2
- data/lib/generators/graphql/templates/input.erb +9 -0
- data/lib/generators/graphql/templates/interface.erb +4 -2
- data/lib/generators/graphql/templates/mutation.erb +1 -1
- data/lib/generators/graphql/templates/mutation_create.erb +20 -0
- data/lib/generators/graphql/templates/mutation_delete.erb +20 -0
- data/lib/generators/graphql/templates/mutation_update.erb +21 -0
- data/lib/generators/graphql/templates/node_type.erb +9 -0
- data/lib/generators/graphql/templates/object.erb +5 -3
- data/lib/generators/graphql/templates/query_type.erb +1 -3
- data/lib/generators/graphql/templates/scalar.erb +3 -1
- data/lib/generators/graphql/templates/schema.erb +19 -34
- data/lib/generators/graphql/templates/union.erb +4 -2
- data/lib/generators/graphql/type_generator.rb +47 -10
- data/lib/generators/graphql/union_generator.rb +5 -5
- data/lib/graphql/analysis/analyze_query.rb +7 -0
- data/lib/graphql/analysis/ast/field_usage.rb +28 -1
- data/lib/graphql/analysis/ast/query_complexity.rb +10 -14
- data/lib/graphql/analysis/ast/visitor.rb +14 -5
- data/lib/graphql/analysis/ast.rb +11 -2
- data/lib/graphql/argument.rb +1 -1
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/legacy_tracer.rb +56 -0
- data/lib/graphql/backtrace/table.rb +34 -3
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +40 -10
- data/lib/graphql/backtrace.rb +28 -19
- data/lib/graphql/backwards_compatibility.rb +2 -1
- data/lib/graphql/base_type.rb +6 -4
- data/lib/graphql/boolean_type.rb +1 -1
- data/lib/graphql/compatibility/execution_specification.rb +1 -0
- data/lib/graphql/compatibility/lazy_execution_specification.rb +2 -0
- data/lib/graphql/compatibility/query_parser_specification.rb +2 -0
- data/lib/graphql/compatibility/schema_parser_specification.rb +2 -0
- data/lib/graphql/dataloader/null_dataloader.rb +22 -0
- data/lib/graphql/dataloader/request.rb +19 -0
- data/lib/graphql/dataloader/request_all.rb +19 -0
- data/lib/graphql/dataloader/source.rb +155 -0
- data/lib/graphql/dataloader.rb +308 -0
- data/lib/graphql/date_encoding_error.rb +16 -0
- data/lib/graphql/define/assign_global_id_field.rb +1 -1
- data/lib/graphql/define/instance_definable.rb +48 -3
- data/lib/graphql/define/type_definer.rb +5 -5
- data/lib/graphql/deprecated_dsl.rb +18 -5
- data/lib/graphql/deprecation.rb +9 -0
- data/lib/graphql/directive/deprecated_directive.rb +1 -1
- data/lib/graphql/directive/include_directive.rb +1 -1
- data/lib/graphql/directive/skip_directive.rb +1 -1
- data/lib/graphql/directive.rb +1 -5
- data/lib/graphql/enum_type.rb +9 -3
- data/lib/graphql/execution/errors.rb +110 -7
- data/lib/graphql/execution/execute.rb +8 -1
- data/lib/graphql/execution/interpreter/arguments.rb +57 -5
- data/lib/graphql/execution/interpreter/arguments_cache.rb +49 -15
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +0 -7
- data/lib/graphql/execution/interpreter/resolve.rb +37 -25
- data/lib/graphql/execution/interpreter/runtime.rb +670 -294
- data/lib/graphql/execution/interpreter.rb +16 -16
- data/lib/graphql/execution/lazy.rb +5 -1
- data/lib/graphql/execution/lookahead.rb +2 -2
- data/lib/graphql/execution/multiplex.rb +39 -23
- data/lib/graphql/field.rb +1 -1
- data/lib/graphql/float_type.rb +1 -1
- data/lib/graphql/function.rb +4 -0
- data/lib/graphql/id_type.rb +1 -1
- data/lib/graphql/input_object_type.rb +3 -1
- data/lib/graphql/int_type.rb +1 -1
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +18 -2
- data/lib/graphql/interface_type.rb +4 -2
- data/lib/graphql/internal_representation/document.rb +2 -2
- data/lib/graphql/internal_representation/rewrite.rb +1 -1
- data/lib/graphql/introspection/directive_location_enum.rb +2 -2
- data/lib/graphql/introspection/directive_type.rb +11 -5
- data/lib/graphql/introspection/entry_points.rb +2 -2
- data/lib/graphql/introspection/enum_value_type.rb +2 -2
- data/lib/graphql/introspection/field_type.rb +3 -3
- data/lib/graphql/introspection/input_value_type.rb +10 -4
- data/lib/graphql/introspection/schema_type.rb +10 -5
- data/lib/graphql/introspection/type_type.rb +18 -12
- data/lib/graphql/introspection.rb +5 -2
- data/lib/graphql/invalid_null_error.rb +1 -1
- data/lib/graphql/language/block_string.rb +2 -6
- data/lib/graphql/language/cache.rb +37 -0
- data/lib/graphql/language/document_from_schema_definition.rb +60 -26
- data/lib/graphql/language/lexer.rb +50 -28
- data/lib/graphql/language/lexer.rl +2 -4
- data/lib/graphql/language/nodes.rb +14 -4
- data/lib/graphql/language/parser.rb +856 -825
- data/lib/graphql/language/parser.y +28 -11
- data/lib/graphql/language/printer.rb +10 -1
- data/lib/graphql/language/sanitized_printer.rb +5 -5
- data/lib/graphql/language/token.rb +0 -4
- data/lib/graphql/language.rb +1 -0
- data/lib/graphql/name_validator.rb +0 -4
- data/lib/graphql/object_type.rb +4 -4
- data/lib/graphql/pagination/active_record_relation_connection.rb +47 -3
- data/lib/graphql/pagination/connection.rb +19 -1
- data/lib/graphql/pagination/connections.rb +45 -30
- data/lib/graphql/pagination/relation_connection.rb +69 -28
- data/lib/graphql/parse_error.rb +0 -1
- data/lib/graphql/query/arguments.rb +2 -2
- data/lib/graphql/query/arguments_cache.rb +1 -2
- data/lib/graphql/query/context.rb +22 -4
- data/lib/graphql/query/executor.rb +0 -1
- data/lib/graphql/query/input_validation_result.rb +9 -0
- data/lib/graphql/query/literal_input.rb +1 -1
- data/lib/graphql/query/null_context.rb +21 -9
- data/lib/graphql/query/serial_execution/field_resolution.rb +1 -1
- data/lib/graphql/query/serial_execution.rb +1 -0
- data/lib/graphql/query/validation_pipeline.rb +3 -4
- data/lib/graphql/query/variable_validation_error.rb +3 -3
- data/lib/graphql/query/variables.rb +35 -4
- data/lib/graphql/query.rb +20 -8
- data/lib/graphql/railtie.rb +9 -1
- data/lib/graphql/rake_task.rb +3 -0
- data/lib/graphql/relay/array_connection.rb +2 -2
- data/lib/graphql/relay/base_connection.rb +7 -0
- data/lib/graphql/relay/connection_instrumentation.rb +4 -4
- data/lib/graphql/relay/connection_type.rb +16 -3
- data/lib/graphql/relay/edges_instrumentation.rb +0 -1
- data/lib/graphql/relay/global_id_resolve.rb +1 -2
- data/lib/graphql/relay/mutation.rb +2 -1
- data/lib/graphql/relay/node.rb +3 -0
- data/lib/graphql/relay/page_info.rb +1 -1
- data/lib/graphql/relay/range_add.rb +14 -5
- data/lib/graphql/relay/type_extensions.rb +2 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +36 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +43 -0
- data/lib/graphql/rubocop/graphql/default_required_true.rb +43 -0
- data/lib/graphql/rubocop.rb +4 -0
- data/lib/graphql/scalar_type.rb +3 -1
- data/lib/graphql/schema/addition.rb +247 -0
- data/lib/graphql/schema/argument.rb +177 -21
- data/lib/graphql/schema/build_from_definition.rb +150 -55
- data/lib/graphql/schema/default_type_error.rb +2 -0
- data/lib/graphql/schema/directive/feature.rb +1 -1
- data/lib/graphql/schema/directive/flagged.rb +57 -0
- data/lib/graphql/schema/directive/include.rb +1 -1
- data/lib/graphql/schema/directive/skip.rb +1 -1
- data/lib/graphql/schema/directive/transform.rb +14 -2
- data/lib/graphql/schema/directive.rb +103 -4
- data/lib/graphql/schema/enum.rb +72 -11
- data/lib/graphql/schema/enum_value.rb +18 -6
- data/lib/graphql/schema/field/connection_extension.rb +4 -2
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +332 -111
- data/lib/graphql/schema/field_extension.rb +89 -2
- data/lib/graphql/schema/find_inherited_value.rb +4 -1
- data/lib/graphql/schema/finder.rb +5 -5
- data/lib/graphql/schema/input_object.rb +79 -55
- data/lib/graphql/schema/interface.rb +12 -20
- data/lib/graphql/schema/introspection_system.rb +1 -1
- data/lib/graphql/schema/list.rb +21 -4
- data/lib/graphql/schema/loader.rb +11 -0
- data/lib/graphql/schema/member/accepts_definition.rb +15 -3
- data/lib/graphql/schema/member/base_dsl_methods.rb +5 -16
- data/lib/graphql/schema/member/build_type.rb +4 -7
- data/lib/graphql/schema/member/cached_graphql_definition.rb +29 -2
- data/lib/graphql/schema/member/has_arguments.rb +166 -74
- data/lib/graphql/schema/member/has_deprecation_reason.rb +25 -0
- data/lib/graphql/schema/member/has_directives.rb +98 -0
- data/lib/graphql/schema/member/has_fields.rb +77 -22
- data/lib/graphql/schema/member/has_interfaces.rb +100 -0
- data/lib/graphql/schema/member/has_validators.rb +31 -0
- data/lib/graphql/schema/member/instrumentation.rb +0 -1
- data/lib/graphql/schema/member/type_system_helpers.rb +1 -1
- data/lib/graphql/schema/member/validates_input.rb +2 -2
- data/lib/graphql/schema/member.rb +5 -0
- data/lib/graphql/schema/middleware_chain.rb +1 -1
- data/lib/graphql/schema/non_null.rb +9 -3
- data/lib/graphql/schema/object.rb +40 -80
- data/lib/graphql/schema/printer.rb +16 -20
- data/lib/graphql/schema/relay_classic_mutation.rb +38 -4
- data/lib/graphql/schema/resolver/has_payload_type.rb +29 -2
- data/lib/graphql/schema/resolver.rb +110 -64
- data/lib/graphql/schema/scalar.rb +18 -2
- data/lib/graphql/schema/subscription.rb +55 -9
- data/lib/graphql/schema/timeout_middleware.rb +3 -1
- data/lib/graphql/schema/traversal.rb +1 -1
- data/lib/graphql/schema/type_expression.rb +1 -1
- data/lib/graphql/schema/type_membership.rb +18 -4
- data/lib/graphql/schema/union.rb +8 -1
- data/lib/graphql/schema/validation.rb +4 -2
- data/lib/graphql/schema/validator/allow_blank_validator.rb +29 -0
- data/lib/graphql/schema/validator/allow_null_validator.rb +26 -0
- data/lib/graphql/schema/validator/exclusion_validator.rb +33 -0
- data/lib/graphql/schema/validator/format_validator.rb +48 -0
- data/lib/graphql/schema/validator/inclusion_validator.rb +35 -0
- data/lib/graphql/schema/validator/length_validator.rb +59 -0
- data/lib/graphql/schema/validator/numericality_validator.rb +82 -0
- data/lib/graphql/schema/validator/required_validator.rb +82 -0
- data/lib/graphql/schema/validator.rb +171 -0
- data/lib/graphql/schema/warden.rb +126 -53
- data/lib/graphql/schema.rb +262 -281
- data/lib/graphql/static_validation/all_rules.rb +2 -0
- data/lib/graphql/static_validation/base_visitor.rb +9 -6
- data/lib/graphql/static_validation/definition_dependencies.rb +0 -1
- data/lib/graphql/static_validation/error.rb +3 -1
- data/lib/graphql/static_validation/literal_validator.rb +1 -1
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +4 -2
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +6 -2
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +3 -2
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +4 -2
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +1 -1
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +1 -1
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +90 -47
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +25 -4
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -2
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +30 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +30 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -2
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +5 -5
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +14 -8
- data/lib/graphql/static_validation/validation_context.rb +12 -2
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +41 -10
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +13 -3
- data/lib/graphql/string_type.rb +1 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +39 -8
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +0 -3
- data/lib/graphql/subscriptions/event.rb +68 -32
- data/lib/graphql/subscriptions/instrumentation.rb +0 -1
- data/lib/graphql/subscriptions/serialize.rb +34 -5
- data/lib/graphql/subscriptions/subscription_root.rb +1 -1
- data/lib/graphql/subscriptions.rb +34 -39
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +8 -21
- data/lib/graphql/tracing/appoptics_tracing.rb +3 -1
- data/lib/graphql/tracing/appsignal_tracing.rb +15 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +24 -2
- data/lib/graphql/tracing/notifications_tracing.rb +59 -0
- data/lib/graphql/tracing/platform_tracing.rb +24 -12
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +4 -1
- data/lib/graphql/tracing/skylight_tracing.rb +1 -1
- data/lib/graphql/tracing.rb +2 -2
- data/lib/graphql/types/big_int.rb +5 -1
- data/lib/graphql/types/int.rb +10 -3
- data/lib/graphql/types/iso_8601_date.rb +13 -5
- data/lib/graphql/types/iso_8601_date_time.rb +8 -1
- data/lib/graphql/types/relay/base_connection.rb +6 -91
- data/lib/graphql/types/relay/base_edge.rb +2 -34
- data/lib/graphql/types/relay/connection_behaviors.rb +174 -0
- data/lib/graphql/types/relay/default_relay.rb +31 -0
- data/lib/graphql/types/relay/edge_behaviors.rb +64 -0
- data/lib/graphql/types/relay/has_node_field.rb +41 -0
- data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
- data/lib/graphql/types/relay/node.rb +2 -4
- data/lib/graphql/types/relay/node_behaviors.rb +15 -0
- data/lib/graphql/types/relay/node_field.rb +3 -22
- data/lib/graphql/types/relay/nodes_field.rb +16 -18
- data/lib/graphql/types/relay/page_info.rb +2 -14
- data/lib/graphql/types/relay/page_info_behaviors.rb +25 -0
- data/lib/graphql/types/relay.rb +11 -3
- data/lib/graphql/types/string.rb +8 -2
- data/lib/graphql/unauthorized_error.rb +1 -1
- data/lib/graphql/union_type.rb +3 -1
- data/lib/graphql/upgrader/member.rb +1 -0
- data/lib/graphql/upgrader/schema.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +68 -37
- data/readme.md +3 -6
- metadata +83 -113
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
- data/lib/graphql/types/relay/base_field.rb +0 -22
- data/lib/graphql/types/relay/base_interface.rb +0 -29
- data/lib/graphql/types/relay/base_object.rb +0 -26
- /data/lib/generators/graphql/{templates → install/templates}/base_mutation.erb +0 -0
- /data/lib/generators/graphql/{templates → install/templates}/mutation_type.erb +0 -0
@@ -147,6 +147,7 @@ rule
|
|
147
147
|
name_without_on:
|
148
148
|
IDENTIFIER
|
149
149
|
| FRAGMENT
|
150
|
+
| REPEATABLE
|
150
151
|
| TRUE
|
151
152
|
| FALSE
|
152
153
|
| operation_type
|
@@ -155,6 +156,7 @@ rule
|
|
155
156
|
enum_name: /* any identifier, but not "true", "false" or "null" */
|
156
157
|
IDENTIFIER
|
157
158
|
| FRAGMENT
|
159
|
+
| REPEATABLE
|
158
160
|
| ON
|
159
161
|
| operation_type
|
160
162
|
| schema_keyword
|
@@ -325,8 +327,9 @@ rule
|
|
325
327
|
| EXTEND TYPE name implements { result = make_node(:ObjectTypeExtension, name: val[2], interfaces: val[3], directives: [], fields: [], position_source: val[0]) }
|
326
328
|
|
327
329
|
interface_type_extension:
|
328
|
-
EXTEND INTERFACE name directives_list_opt LCURLY field_definition_list RCURLY { result = make_node(:InterfaceTypeExtension, name: val[2],
|
329
|
-
| EXTEND INTERFACE name directives_list { result = make_node(:InterfaceTypeExtension, name: val[2],
|
330
|
+
EXTEND INTERFACE name implements_opt directives_list_opt LCURLY field_definition_list RCURLY { result = make_node(:InterfaceTypeExtension, name: val[2], interfaces: val[3], directives: val[4], fields: val[6], position_source: val[0]) }
|
331
|
+
| EXTEND INTERFACE name implements_opt directives_list { result = make_node(:InterfaceTypeExtension, name: val[2], interfaces: val[3], directives: val[4], fields: [], position_source: val[0]) }
|
332
|
+
| EXTEND INTERFACE name implements { result = make_node(:InterfaceTypeExtension, name: val[2], interfaces: val[3], directives: [], fields: [], position_source: val[0]) }
|
330
333
|
|
331
334
|
union_type_extension:
|
332
335
|
EXTEND UNION name directives_list_opt EQUALS union_members { result = make_node(:UnionTypeExtension, name: val[2], directives: val[3], types: val[5], position_source: val[0]) }
|
@@ -397,8 +400,8 @@ rule
|
|
397
400
|
| field_definition_list field_definition { val[0] << val[1] }
|
398
401
|
|
399
402
|
interface_type_definition:
|
400
|
-
description_opt INTERFACE name directives_list_opt LCURLY field_definition_list RCURLY {
|
401
|
-
result = make_node(:InterfaceTypeDefinition, name: val[2],
|
403
|
+
description_opt INTERFACE name implements_opt directives_list_opt LCURLY field_definition_list RCURLY {
|
404
|
+
result = make_node(:InterfaceTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[6], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
402
405
|
}
|
403
406
|
|
404
407
|
union_members:
|
@@ -421,10 +424,14 @@ rule
|
|
421
424
|
}
|
422
425
|
|
423
426
|
directive_definition:
|
424
|
-
description_opt DIRECTIVE DIR_SIGN name arguments_definitions_opt ON directive_locations {
|
425
|
-
result = make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[
|
427
|
+
description_opt DIRECTIVE DIR_SIGN name arguments_definitions_opt directive_repeatable_opt ON directive_locations {
|
428
|
+
result = make_node(:DirectiveDefinition, name: val[3], arguments: val[4], locations: val[7], repeatable: !!val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
|
426
429
|
}
|
427
430
|
|
431
|
+
directive_repeatable_opt:
|
432
|
+
/* nothing */
|
433
|
+
| REPEATABLE
|
434
|
+
|
428
435
|
directive_locations:
|
429
436
|
name { result = [make_node(:DirectiveLocation, name: val[0].to_s, position_source: val[0])] }
|
430
437
|
| directive_locations PIPE name { val[0] << make_node(:DirectiveLocation, name: val[2].to_s, position_source: val[2]) }
|
@@ -462,12 +469,22 @@ def parse_document
|
|
462
469
|
end
|
463
470
|
end
|
464
471
|
|
465
|
-
|
466
|
-
|
467
|
-
|
472
|
+
class << self
|
473
|
+
attr_accessor :cache
|
474
|
+
|
475
|
+
def parse(query_string, filename: nil, tracer: GraphQL::Tracing::NullTracer)
|
476
|
+
new(query_string, filename: filename, tracer: tracer).parse_document
|
477
|
+
end
|
468
478
|
|
469
|
-
def
|
470
|
-
|
479
|
+
def parse_file(filename, tracer: GraphQL::Tracing::NullTracer)
|
480
|
+
if cache
|
481
|
+
cache.fetch(filename) do
|
482
|
+
parse(File.read(filename), filename: filename, tracer: tracer)
|
483
|
+
end
|
484
|
+
else
|
485
|
+
parse(File.read(filename), filename: filename, tracer: tracer)
|
486
|
+
end
|
487
|
+
end
|
471
488
|
end
|
472
489
|
|
473
490
|
private
|
@@ -164,11 +164,15 @@ module GraphQL
|
|
164
164
|
def print_object_type_definition(object_type)
|
165
165
|
out = print_description(object_type)
|
166
166
|
out << "type #{object_type.name}"
|
167
|
-
out <<
|
167
|
+
out << print_implements(object_type) unless object_type.interfaces.empty?
|
168
168
|
out << print_directives(object_type.directives)
|
169
169
|
out << print_field_definitions(object_type.fields)
|
170
170
|
end
|
171
171
|
|
172
|
+
def print_implements(type)
|
173
|
+
" implements #{type.interfaces.map(&:name).join(" & ")}"
|
174
|
+
end
|
175
|
+
|
172
176
|
def print_input_value_definition(input_value)
|
173
177
|
out = "#{input_value.name}: #{print_node(input_value.type)}".dup
|
174
178
|
out << " = #{print_node(input_value.default_value)}" unless input_value.default_value.nil?
|
@@ -200,6 +204,7 @@ module GraphQL
|
|
200
204
|
def print_interface_type_definition(interface_type)
|
201
205
|
out = print_description(interface_type)
|
202
206
|
out << "interface #{interface_type.name}"
|
207
|
+
out << print_implements(interface_type) if interface_type.interfaces.any?
|
203
208
|
out << print_directives(interface_type.directives)
|
204
209
|
out << print_field_definitions(interface_type.fields)
|
205
210
|
end
|
@@ -247,6 +252,10 @@ module GraphQL
|
|
247
252
|
out << print_arguments(directive.arguments)
|
248
253
|
end
|
249
254
|
|
255
|
+
if directive.repeatable
|
256
|
+
out << " repeatable"
|
257
|
+
end
|
258
|
+
|
250
259
|
out << " on #{directive.locations.map(&:name).join(' | ')}"
|
251
260
|
end
|
252
261
|
|
@@ -79,7 +79,7 @@ module GraphQL
|
|
79
79
|
|
80
80
|
arg_owner = @current_input_type || @current_directive || @current_field
|
81
81
|
old_current_argument = @current_argument
|
82
|
-
@current_argument = arg_owner.
|
82
|
+
@current_argument = arg_owner.get_argument(argument.name, @query.context)
|
83
83
|
|
84
84
|
old_input_type = @current_input_type
|
85
85
|
@current_input_type = @current_argument.type.non_null? ? @current_argument.type.of_type : @current_argument.type
|
@@ -113,7 +113,7 @@ module GraphQL
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def print_field(field, indent: "")
|
116
|
-
@current_field = query.
|
116
|
+
@current_field = query.get_field(@current_type, field.name)
|
117
117
|
old_type = @current_type
|
118
118
|
@current_type = @current_field.type.unwrap
|
119
119
|
res = super
|
@@ -125,7 +125,7 @@ module GraphQL
|
|
125
125
|
old_type = @current_type
|
126
126
|
|
127
127
|
if inline_fragment.type
|
128
|
-
@current_type = query.
|
128
|
+
@current_type = query.get_type(inline_fragment.type.name)
|
129
129
|
end
|
130
130
|
|
131
131
|
res = super
|
@@ -137,7 +137,7 @@ module GraphQL
|
|
137
137
|
|
138
138
|
def print_fragment_definition(fragment_def, indent: "")
|
139
139
|
old_type = @current_type
|
140
|
-
@current_type = query.
|
140
|
+
@current_type = query.get_type(fragment_def.type.name)
|
141
141
|
|
142
142
|
res = super
|
143
143
|
|
@@ -193,7 +193,7 @@ module GraphQL
|
|
193
193
|
end
|
194
194
|
|
195
195
|
arguments = value.map do |key, val|
|
196
|
-
sub_type = type.
|
196
|
+
sub_type = type.get_argument(key.to_s, @query.context).type
|
197
197
|
|
198
198
|
GraphQL::Language::Nodes::Argument.new(
|
199
199
|
name: key.to_s,
|
@@ -4,10 +4,6 @@ module GraphQL
|
|
4
4
|
# Emitted by the lexer and passed to the parser.
|
5
5
|
# Contains type, value and position data.
|
6
6
|
class Token
|
7
|
-
if !String.method_defined?(:-@)
|
8
|
-
using GraphQL::StringDedupBackport
|
9
|
-
end
|
10
|
-
|
11
7
|
# @return [Symbol] The kind of token this is
|
12
8
|
attr_reader :name
|
13
9
|
# @return [String] The text of this token
|
data/lib/graphql/language.rb
CHANGED
@@ -6,6 +6,7 @@ require "graphql/language/document_from_schema_definition"
|
|
6
6
|
require "graphql/language/generation"
|
7
7
|
require "graphql/language/lexer"
|
8
8
|
require "graphql/language/nodes"
|
9
|
+
require "graphql/language/cache"
|
9
10
|
require "graphql/language/parser"
|
10
11
|
require "graphql/language/token"
|
11
12
|
require "graphql/language/visitor"
|
data/lib/graphql/object_type.rb
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
module GraphQL
|
3
3
|
# @api deprecated
|
4
4
|
class ObjectType < GraphQL::BaseType
|
5
|
-
|
6
|
-
|
5
|
+
extend Define::InstanceDefinable::DeprecatedDefine
|
6
|
+
|
7
|
+
deprecated_accepts_definitions :interfaces, :fields, :mutation, :relay_node_type, field: GraphQL::Define::AssignObjectField
|
8
|
+
deprecated_accepts_definitions implements: ->(type, *interfaces, inherit: false) { type.implements(interfaces, inherit: inherit) }
|
7
9
|
|
8
10
|
attr_accessor :fields, :mutation, :relay_node_type
|
9
11
|
ensure_defined(:fields, :mutation, :interfaces, :relay_node_type)
|
@@ -119,8 +121,6 @@ module GraphQL
|
|
119
121
|
iface = GraphQL::BaseType.resolve_related_type(type_membership.abstract_type)
|
120
122
|
if iface.is_a?(GraphQL::InterfaceType)
|
121
123
|
@clean_inherited_fields.merge!(iface.fields)
|
122
|
-
else
|
123
|
-
pp iface
|
124
124
|
end
|
125
125
|
end
|
126
126
|
@clean_inherited_fields
|
@@ -5,8 +5,20 @@ module GraphQL
|
|
5
5
|
module Pagination
|
6
6
|
# Customizes `RelationConnection` to work with `ActiveRecord::Relation`s.
|
7
7
|
class ActiveRecordRelationConnection < Pagination::RelationConnection
|
8
|
+
private
|
9
|
+
|
10
|
+
def relation_larger_than(relation, initial_offset, size)
|
11
|
+
if already_loaded?(relation)
|
12
|
+
(relation.size + initial_offset) > size
|
13
|
+
else
|
14
|
+
set_offset(sliced_nodes, initial_offset + size).exists?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
def relation_count(relation)
|
9
|
-
int_or_hash = if
|
19
|
+
int_or_hash = if already_loaded?(relation)
|
20
|
+
relation.size
|
21
|
+
elsif relation.respond_to?(:unscope)
|
10
22
|
relation.unscope(:order).count(:all)
|
11
23
|
else
|
12
24
|
# Rails 3
|
@@ -21,11 +33,19 @@ module GraphQL
|
|
21
33
|
end
|
22
34
|
|
23
35
|
def relation_limit(relation)
|
24
|
-
relation.
|
36
|
+
if relation.is_a?(Array)
|
37
|
+
nil
|
38
|
+
else
|
39
|
+
relation.limit_value
|
40
|
+
end
|
25
41
|
end
|
26
42
|
|
27
43
|
def relation_offset(relation)
|
28
|
-
relation.
|
44
|
+
if relation.is_a?(Array)
|
45
|
+
nil
|
46
|
+
else
|
47
|
+
relation.offset_value
|
48
|
+
end
|
29
49
|
end
|
30
50
|
|
31
51
|
def null_relation(relation)
|
@@ -36,6 +56,30 @@ module GraphQL
|
|
36
56
|
relation.where("1=2")
|
37
57
|
end
|
38
58
|
end
|
59
|
+
|
60
|
+
def set_limit(nodes, limit)
|
61
|
+
if already_loaded?(nodes)
|
62
|
+
nodes.take(limit)
|
63
|
+
else
|
64
|
+
super
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def set_offset(nodes, offset)
|
69
|
+
if already_loaded?(nodes)
|
70
|
+
# If the client sent a bogus cursor beyond the size of the relation,
|
71
|
+
# it might get `nil` from `#[...]`, so return an empty array in that case
|
72
|
+
nodes[offset..-1] || []
|
73
|
+
else
|
74
|
+
super
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def already_loaded?(relation)
|
81
|
+
relation.is_a?(Array) || relation.loaded?
|
82
|
+
end
|
39
83
|
end
|
40
84
|
end
|
41
85
|
end
|
@@ -45,6 +45,9 @@ module GraphQL
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
# @return [Hash<Symbol => Object>] The field arguments from the field that returned this connection
|
49
|
+
attr_accessor :arguments
|
50
|
+
|
48
51
|
# @param items [Object] some unpaginated collection item, like an `Array` or `ActiveRecord::Relation`
|
49
52
|
# @param context [Query::Context]
|
50
53
|
# @param parent [Object] The object this collection belongs to
|
@@ -52,15 +55,18 @@ module GraphQL
|
|
52
55
|
# @param after [String, nil] A cursor for pagination, if the client provided one
|
53
56
|
# @param last [Integer, nil] Limit parameter from the client, if provided
|
54
57
|
# @param before [String, nil] A cursor for pagination, if the client provided one.
|
58
|
+
# @param arguments [Hash] The arguments to the field that returned the collection wrapped by this connection
|
55
59
|
# @param max_page_size [Integer, nil] A configured value to cap the result size. Applied as `first` if neither first or last are given.
|
56
|
-
def initialize(items, parent: nil, context: nil, first: nil, after: nil, max_page_size: :not_given, last: nil, before: nil, edge_class: nil)
|
60
|
+
def initialize(items, parent: nil, field: nil, context: nil, first: nil, after: nil, max_page_size: :not_given, last: nil, before: nil, edge_class: nil, arguments: nil)
|
57
61
|
@items = items
|
58
62
|
@parent = parent
|
59
63
|
@context = context
|
64
|
+
@field = field
|
60
65
|
@first_value = first
|
61
66
|
@after_value = after
|
62
67
|
@last_value = last
|
63
68
|
@before_value = before
|
69
|
+
@arguments = arguments
|
64
70
|
@edge_class = edge_class || self.class::Edge
|
65
71
|
# This is only true if the object was _initialized_ with an override
|
66
72
|
# or if one is assigned later.
|
@@ -104,6 +110,15 @@ module GraphQL
|
|
104
110
|
end
|
105
111
|
end
|
106
112
|
|
113
|
+
# This is called by `Relay::RangeAdd` -- it can be overridden
|
114
|
+
# when `item` needs some modifications based on this connection's state.
|
115
|
+
#
|
116
|
+
# @param item [Object] An item newly added to `items`
|
117
|
+
# @return [Edge]
|
118
|
+
def range_add_edge(item)
|
119
|
+
edge_class.new(item, self)
|
120
|
+
end
|
121
|
+
|
107
122
|
attr_writer :last
|
108
123
|
# @return [Integer, nil] A clamped `last` value. (The underlying instance variable doesn't have limits on it)
|
109
124
|
def last
|
@@ -118,6 +133,9 @@ module GraphQL
|
|
118
133
|
# @return [Class] A wrapper class for edges of this connection
|
119
134
|
attr_accessor :edge_class
|
120
135
|
|
136
|
+
# @return [GraphQL::Schema::Field] The field this connection was returned by
|
137
|
+
attr_accessor :field
|
138
|
+
|
121
139
|
# @return [Array<Object>] A slice of {items}, constrained by {@first_value}/{@after_value}/{@last_value}/{@before_value}
|
122
140
|
def nodes
|
123
141
|
raise PaginationImplementationMissingError, "Implement #{self.class}#nodes to paginate `@items`"
|
@@ -6,20 +6,13 @@ module GraphQL
|
|
6
6
|
#
|
7
7
|
# Attach as a plugin.
|
8
8
|
#
|
9
|
-
# @example Using new default connections
|
10
|
-
# class MySchema < GraphQL::Schema
|
11
|
-
# use GraphQL::Pagination::Connections
|
12
|
-
# end
|
13
|
-
#
|
14
9
|
# @example Adding a custom wrapper
|
15
10
|
# class MySchema < GraphQL::Schema
|
16
|
-
# use GraphQL::Pagination::Connections
|
17
11
|
# connections.add(MyApp::SearchResults, MyApp::SearchResultsConnection)
|
18
12
|
# end
|
19
13
|
#
|
20
14
|
# @example Removing default connection support for arrays (they can still be manually wrapped)
|
21
15
|
# class MySchema < GraphQL::Schema
|
22
|
-
# use GraphQL::Pagination::Connections
|
23
16
|
# connections.delete(Array)
|
24
17
|
# end
|
25
18
|
#
|
@@ -29,14 +22,10 @@ module GraphQL
|
|
29
22
|
end
|
30
23
|
|
31
24
|
def self.use(schema_defn)
|
32
|
-
if schema_defn.
|
33
|
-
|
34
|
-
else
|
35
|
-
# Unwrap a `.define` object
|
36
|
-
schema_defn = schema_defn.target
|
37
|
-
schema_defn.connections = self.new(schema: schema_defn)
|
38
|
-
schema_defn.class.connections = schema_defn.connections
|
25
|
+
if schema_defn.plugins.any? { |(plugin, args)| plugin == self }
|
26
|
+
GraphQL::Deprecation.warn("#{self} is now the default, remove `use #{self}` from #{caller(2,1).first}")
|
39
27
|
end
|
28
|
+
schema_defn.connections = self.new(schema: schema_defn)
|
40
29
|
end
|
41
30
|
|
42
31
|
def initialize(schema:)
|
@@ -76,26 +65,47 @@ module GraphQL
|
|
76
65
|
|
77
66
|
# Used by the runtime to wrap values in connection wrappers.
|
78
67
|
# @api Private
|
79
|
-
def wrap(field, parent, items, arguments, context
|
68
|
+
def wrap(field, parent, items, arguments, context)
|
80
69
|
return items if GraphQL::Execution::Interpreter::RawValue === items
|
81
|
-
|
70
|
+
wrappers = context ? context.namespace(:connections)[:all_wrappers] : all_wrappers
|
82
71
|
impl = wrapper_for(items, wrappers: wrappers)
|
83
72
|
|
84
|
-
if impl
|
85
|
-
|
73
|
+
if impl
|
74
|
+
impl.new(
|
75
|
+
items,
|
76
|
+
context: context,
|
77
|
+
parent: parent,
|
78
|
+
field: field,
|
79
|
+
max_page_size: field.has_max_page_size? ? field.max_page_size : context.schema.default_max_page_size,
|
80
|
+
first: arguments[:first],
|
81
|
+
after: arguments[:after],
|
82
|
+
last: arguments[:last],
|
83
|
+
before: arguments[:before],
|
84
|
+
arguments: arguments,
|
85
|
+
edge_class: edge_class_for_field(field),
|
86
|
+
)
|
87
|
+
else
|
88
|
+
begin
|
89
|
+
connection_class = GraphQL::Relay::BaseConnection.connection_for_nodes(items)
|
90
|
+
if parent.is_a?(GraphQL::Schema::Object)
|
91
|
+
parent = parent.object
|
92
|
+
end
|
93
|
+
connection_class.new(
|
94
|
+
items,
|
95
|
+
arguments,
|
96
|
+
field: field,
|
97
|
+
max_page_size: field.max_page_size,
|
98
|
+
parent: parent,
|
99
|
+
context: context,
|
100
|
+
)
|
101
|
+
rescue RuntimeError => err
|
102
|
+
if err.message.include?("No connection implementation to wrap")
|
103
|
+
raise ImplementationMissingError, "Couldn't find a connection wrapper for #{items.class} during #{field.path} (#{items.inspect})"
|
104
|
+
else
|
105
|
+
raise err
|
106
|
+
end
|
107
|
+
end
|
86
108
|
end
|
87
|
-
|
88
|
-
impl.new(
|
89
|
-
items,
|
90
|
-
context: context,
|
91
|
-
parent: parent,
|
92
|
-
max_page_size: field.max_page_size || context.schema.default_max_page_size,
|
93
|
-
first: arguments[:first],
|
94
|
-
after: arguments[:after],
|
95
|
-
last: arguments[:last],
|
96
|
-
before: arguments[:before],
|
97
|
-
edge_class: edge_class_for_field(field),
|
98
|
-
)
|
99
109
|
end
|
100
110
|
|
101
111
|
# use an override if there is one
|
@@ -139,6 +149,11 @@ module GraphQL
|
|
139
149
|
if defined?(Mongoid::Association::Referenced::HasMany::Targets::Enumerable)
|
140
150
|
add(Mongoid::Association::Referenced::HasMany::Targets::Enumerable, Pagination::MongoidRelationConnection)
|
141
151
|
end
|
152
|
+
|
153
|
+
# Mongoid 7.3+
|
154
|
+
if defined?(Mongoid::Association::Referenced::HasMany::Enumerable)
|
155
|
+
add(Mongoid::Association::Referenced::HasMany::Enumerable, Pagination::MongoidRelationConnection)
|
156
|
+
end
|
142
157
|
end
|
143
158
|
end
|
144
159
|
end
|
@@ -32,7 +32,11 @@ module GraphQL
|
|
32
32
|
@has_next_page = if before_offset && before_offset > 0
|
33
33
|
true
|
34
34
|
elsif first
|
35
|
-
|
35
|
+
if @nodes && @nodes.count < first
|
36
|
+
false
|
37
|
+
else
|
38
|
+
relation_larger_than(sliced_nodes, @sliced_nodes_offset, first)
|
39
|
+
end
|
36
40
|
else
|
37
41
|
false
|
38
42
|
end
|
@@ -43,12 +47,20 @@ module GraphQL
|
|
43
47
|
def cursor_for(item)
|
44
48
|
load_nodes
|
45
49
|
# index in nodes + existing offset + 1 (because it's offset, not index)
|
46
|
-
offset = nodes.index(item) + 1 + (@paged_nodes_offset || 0)
|
50
|
+
offset = nodes.index(item) + 1 + (@paged_nodes_offset || 0) - (relation_offset(items) || 0)
|
47
51
|
encode(offset.to_s)
|
48
52
|
end
|
49
53
|
|
50
54
|
private
|
51
55
|
|
56
|
+
# @param relation [Object] A database query object
|
57
|
+
# @param _initial_offset [Integer] The number of items already excluded from the relation
|
58
|
+
# @param size [Integer] The value against which we check the relation size
|
59
|
+
# @return [Boolean] True if the number of items in this relation is larger than `size`
|
60
|
+
def relation_larger_than(relation, _initial_offset, size)
|
61
|
+
relation_count(set_limit(relation, size + 1)) == size + 1
|
62
|
+
end
|
63
|
+
|
52
64
|
# @param relation [Object] A database query object
|
53
65
|
# @return [Integer, nil] The offset value, or nil if there isn't one
|
54
66
|
def relation_offset(relation)
|
@@ -100,30 +112,51 @@ module GraphQL
|
|
100
112
|
end
|
101
113
|
end
|
102
114
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
115
|
+
def calculate_sliced_nodes_parameters
|
116
|
+
if defined?(@sliced_nodes_limit)
|
117
|
+
return
|
118
|
+
else
|
119
|
+
next_offset = relation_offset(items) || 0
|
109
120
|
if after_offset
|
110
|
-
|
111
|
-
paginated_nodes = set_offset(paginated_nodes, previous_offset + after_offset)
|
121
|
+
next_offset += after_offset
|
112
122
|
end
|
113
123
|
|
114
124
|
if before_offset && after_offset
|
115
125
|
if after_offset < before_offset
|
116
126
|
# Get the number of items between the two cursors
|
117
127
|
space_between = before_offset - after_offset - 1
|
118
|
-
|
128
|
+
relation_limit = space_between
|
119
129
|
else
|
120
|
-
# TODO I think this is untested
|
121
130
|
# The cursors overextend one another to an empty set
|
122
|
-
|
131
|
+
@sliced_nodes_null_relation = true
|
123
132
|
end
|
124
133
|
elsif before_offset
|
125
134
|
# Use limit to cut off the tail of the relation
|
126
|
-
|
135
|
+
relation_limit = before_offset - 1
|
136
|
+
end
|
137
|
+
|
138
|
+
@sliced_nodes_limit = relation_limit
|
139
|
+
@sliced_nodes_offset = next_offset
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Apply `before` and `after` to the underlying `items`,
|
144
|
+
# returning a new relation.
|
145
|
+
def sliced_nodes
|
146
|
+
@sliced_nodes ||= begin
|
147
|
+
calculate_sliced_nodes_parameters
|
148
|
+
paginated_nodes = items
|
149
|
+
|
150
|
+
if @sliced_nodes_null_relation
|
151
|
+
paginated_nodes = null_relation(paginated_nodes)
|
152
|
+
else
|
153
|
+
if @sliced_nodes_limit
|
154
|
+
paginated_nodes = set_limit(paginated_nodes, @sliced_nodes_limit)
|
155
|
+
end
|
156
|
+
|
157
|
+
if @sliced_nodes_offset
|
158
|
+
paginated_nodes = set_offset(paginated_nodes, @sliced_nodes_offset)
|
159
|
+
end
|
127
160
|
end
|
128
161
|
|
129
162
|
paginated_nodes
|
@@ -144,32 +177,40 @@ module GraphQL
|
|
144
177
|
# returning a new relation
|
145
178
|
def limited_nodes
|
146
179
|
@limited_nodes ||= begin
|
147
|
-
|
148
|
-
|
180
|
+
calculate_sliced_nodes_parameters
|
181
|
+
if @sliced_nodes_null_relation
|
182
|
+
# it's an empty set
|
183
|
+
return sliced_nodes
|
184
|
+
end
|
185
|
+
relation_limit = @sliced_nodes_limit
|
186
|
+
relation_offset = @sliced_nodes_offset
|
149
187
|
|
150
|
-
if first && (
|
188
|
+
if first && (relation_limit.nil? || relation_limit > first)
|
151
189
|
# `first` would create a stricter limit that the one already applied, so add it
|
152
|
-
|
190
|
+
relation_limit = first
|
153
191
|
end
|
154
192
|
|
155
193
|
if last
|
156
|
-
if
|
157
|
-
if last <=
|
194
|
+
if relation_limit
|
195
|
+
if last <= relation_limit
|
158
196
|
# `last` is a smaller slice than the current limit, so apply it
|
159
|
-
|
160
|
-
|
161
|
-
paginated_nodes = set_limit(paginated_nodes, last)
|
197
|
+
relation_offset += (relation_limit - last)
|
198
|
+
relation_limit = last
|
162
199
|
end
|
163
200
|
else
|
164
201
|
# No limit, so get the last items
|
165
|
-
sliced_nodes_count = relation_count(
|
166
|
-
|
167
|
-
|
168
|
-
paginated_nodes = set_limit(paginated_nodes, last)
|
202
|
+
sliced_nodes_count = relation_count(sliced_nodes)
|
203
|
+
relation_offset += (sliced_nodes_count - [last, sliced_nodes_count].min)
|
204
|
+
relation_limit = last
|
169
205
|
end
|
170
206
|
end
|
171
207
|
|
172
|
-
@paged_nodes_offset = relation_offset
|
208
|
+
@paged_nodes_offset = relation_offset
|
209
|
+
paginated_nodes = items
|
210
|
+
paginated_nodes = set_offset(paginated_nodes, relation_offset)
|
211
|
+
if relation_limit
|
212
|
+
paginated_nodes = set_limit(paginated_nodes, relation_limit)
|
213
|
+
end
|
173
214
|
paginated_nodes
|
174
215
|
end
|
175
216
|
end
|
data/lib/graphql/parse_error.rb
CHANGED
@@ -9,7 +9,7 @@ module GraphQL
|
|
9
9
|
include GraphQL::Dig
|
10
10
|
|
11
11
|
def self.construct_arguments_class(argument_owner)
|
12
|
-
argument_definitions = argument_owner.arguments
|
12
|
+
argument_definitions = argument_owner.arguments # rubocop:disable Development/ContextIsPassedCop -- legacy-related
|
13
13
|
argument_owner.arguments_class = Class.new(self) do
|
14
14
|
self.argument_owner = argument_owner
|
15
15
|
self.argument_definitions = argument_definitions
|
@@ -22,7 +22,7 @@ module GraphQL
|
|
22
22
|
method_names.each do |method_name|
|
23
23
|
# Don't define a helper method if it would override something.
|
24
24
|
if method_defined?(method_name)
|
25
|
-
warn(
|
25
|
+
GraphQL::Deprecation.warn(
|
26
26
|
"Unable to define a helper for argument with name '#{method_name}' "\
|
27
27
|
"as this is a reserved name. Add `method_access: false` to stop this warning."
|
28
28
|
)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# test_via: ../query.rb
|
3
2
|
module GraphQL
|
4
3
|
class Query
|
5
4
|
module ArgumentsCache
|
@@ -8,7 +7,7 @@ module GraphQL
|
|
8
7
|
Hash.new do |h1, irep_or_ast_node|
|
9
8
|
h1[irep_or_ast_node] = Hash.new do |h2, definition|
|
10
9
|
ast_node = irep_or_ast_node.is_a?(GraphQL::InternalRepresentation::Node) ? irep_or_ast_node.ast_node : irep_or_ast_node
|
11
|
-
h2[definition] = if definition.arguments.empty?
|
10
|
+
h2[definition] = if definition.arguments(query.context).empty?
|
12
11
|
GraphQL::Query::Arguments::NO_ARGS
|
13
12
|
else
|
14
13
|
GraphQL::Query::LiteralInput.from_arguments(
|