graphql 1.10.2 → 2.0.21
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 +21 -10
- 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/{templates → install/templates}/base_mutation.erb +2 -0
- data/lib/generators/graphql/{templates → install/templates}/mutation_type.erb +2 -0
- data/lib/generators/graphql/install_generator.rb +45 -8
- 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 +28 -12
- data/lib/generators/graphql/orm_mutations_base.rb +40 -0
- data/lib/generators/graphql/relay.rb +49 -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_argument.erb +2 -0
- 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/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_scalar.erb +2 -0
- data/lib/generators/graphql/templates/base_union.erb +2 -0
- data/lib/generators/graphql/templates/enum.erb +7 -1
- data/lib/generators/graphql/templates/graphql_controller.erb +16 -12
- data/lib/generators/graphql/templates/input.erb +9 -0
- data/lib/generators/graphql/templates/interface.erb +6 -2
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +3 -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 +7 -3
- data/lib/generators/graphql/templates/query_type.erb +3 -3
- data/lib/generators/graphql/templates/scalar.erb +5 -1
- data/lib/generators/graphql/templates/schema.erb +24 -33
- data/lib/generators/graphql/templates/union.erb +6 -2
- data/lib/generators/graphql/type_generator.rb +47 -10
- data/lib/generators/graphql/union_generator.rb +5 -5
- data/lib/graphql/analysis/ast/field_usage.rb +30 -1
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -1
- data/lib/graphql/analysis/ast/query_complexity.rb +125 -117
- data/lib/graphql/analysis/ast/query_depth.rb +0 -1
- data/lib/graphql/analysis/ast/visitor.rb +52 -36
- data/lib/graphql/analysis/ast.rb +7 -8
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/table.rb +31 -18
- data/lib/graphql/backtrace/trace.rb +96 -0
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +39 -9
- data/lib/graphql/backtrace.rb +26 -18
- data/lib/graphql/dataloader/null_dataloader.rb +24 -0
- data/lib/graphql/dataloader/request.rb +19 -0
- data/lib/graphql/dataloader/request_all.rb +19 -0
- data/lib/graphql/dataloader/source.rb +164 -0
- data/lib/graphql/dataloader.rb +311 -0
- data/lib/graphql/date_encoding_error.rb +16 -0
- data/lib/graphql/deprecation.rb +9 -0
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/errors.rb +77 -44
- data/lib/graphql/execution/interpreter/argument_value.rb +28 -0
- data/lib/graphql/execution/interpreter/arguments.rb +88 -0
- data/lib/graphql/execution/interpreter/arguments_cache.rb +104 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
- data/lib/graphql/execution/interpreter/resolve.rb +62 -24
- data/lib/graphql/execution/interpreter/runtime.rb +826 -464
- data/lib/graphql/execution/interpreter.rb +206 -68
- data/lib/graphql/execution/lazy.rb +11 -21
- data/lib/graphql/execution/lookahead.rb +55 -136
- data/lib/graphql/execution/multiplex.rb +6 -162
- data/lib/graphql/execution.rb +11 -4
- data/lib/graphql/filter.rb +7 -2
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +18 -2
- data/lib/graphql/introspection/directive_location_enum.rb +2 -2
- data/lib/graphql/introspection/directive_type.rb +11 -5
- data/lib/graphql/introspection/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +4 -17
- data/lib/graphql/introspection/enum_value_type.rb +2 -2
- data/lib/graphql/introspection/field_type.rb +9 -5
- data/lib/graphql/introspection/input_value_type.rb +15 -3
- data/lib/graphql/introspection/introspection_query.rb +6 -92
- data/lib/graphql/introspection/schema_type.rb +11 -6
- data/lib/graphql/introspection/type_type.rb +31 -14
- data/lib/graphql/introspection.rb +100 -0
- data/lib/graphql/invalid_null_error.rb +18 -0
- data/lib/graphql/language/block_string.rb +20 -5
- data/lib/graphql/language/cache.rb +37 -0
- data/lib/graphql/language/document_from_schema_definition.rb +96 -44
- data/lib/graphql/language/lexer.rb +216 -1462
- data/lib/graphql/language/nodes.rb +126 -129
- data/lib/graphql/language/parser.rb +997 -933
- data/lib/graphql/language/parser.y +148 -118
- data/lib/graphql/language/printer.rb +48 -23
- data/lib/graphql/language/sanitized_printer.rb +222 -0
- data/lib/graphql/language/token.rb +0 -4
- data/lib/graphql/language/visitor.rb +192 -84
- data/lib/graphql/language.rb +2 -0
- data/lib/graphql/name_validator.rb +2 -7
- data/lib/graphql/pagination/active_record_relation_connection.rb +45 -3
- data/lib/graphql/pagination/array_connection.rb +6 -4
- data/lib/graphql/pagination/connection.rb +105 -23
- data/lib/graphql/pagination/connections.rb +62 -35
- data/lib/graphql/pagination/relation_connection.rb +88 -36
- data/lib/graphql/parse_error.rb +0 -1
- data/lib/graphql/query/context.rb +203 -198
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +33 -7
- data/lib/graphql/query/null_context.rb +22 -9
- data/lib/graphql/query/validation_pipeline.rb +16 -38
- data/lib/graphql/query/variable_validation_error.rb +3 -3
- data/lib/graphql/query/variables.rb +36 -12
- data/lib/graphql/query.rb +92 -44
- data/lib/graphql/railtie.rb +6 -102
- data/lib/graphql/rake_task/validate.rb +1 -1
- data/lib/graphql/rake_task.rb +41 -10
- data/lib/graphql/relay/range_add.rb +17 -10
- data/lib/graphql/relay.rb +0 -15
- 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/schema/addition.rb +245 -0
- data/lib/graphql/schema/argument.rb +250 -46
- data/lib/graphql/schema/base_64_encoder.rb +2 -0
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +3 -1
- data/lib/graphql/schema/build_from_definition.rb +243 -89
- data/lib/graphql/schema/directive/deprecated.rb +1 -1
- 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/one_of.rb +12 -0
- data/lib/graphql/schema/directive/skip.rb +1 -1
- data/lib/graphql/schema/directive/transform.rb +14 -2
- data/lib/graphql/schema/directive.rb +108 -20
- data/lib/graphql/schema/enum.rb +105 -44
- data/lib/graphql/schema/enum_value.rb +15 -25
- data/lib/graphql/schema/field/connection_extension.rb +50 -30
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +476 -331
- data/lib/graphql/schema/field_extension.rb +86 -2
- data/lib/graphql/schema/find_inherited_value.rb +6 -8
- data/lib/graphql/schema/finder.rb +5 -5
- data/lib/graphql/schema/input_object.rb +133 -121
- data/lib/graphql/schema/interface.rb +17 -45
- data/lib/graphql/schema/introspection_system.rb +3 -8
- data/lib/graphql/schema/late_bound_type.rb +8 -2
- data/lib/graphql/schema/list.rb +25 -8
- data/lib/graphql/schema/loader.rb +139 -103
- data/lib/graphql/schema/member/base_dsl_methods.rb +29 -35
- data/lib/graphql/schema/member/build_type.rb +19 -14
- data/lib/graphql/schema/member/has_arguments.rb +310 -26
- data/lib/graphql/schema/member/has_ast_node.rb +16 -1
- data/lib/graphql/schema/member/has_deprecation_reason.rb +24 -0
- data/lib/graphql/schema/member/has_directives.rb +118 -0
- data/lib/graphql/schema/member/has_fields.rb +164 -42
- data/lib/graphql/schema/member/has_interfaces.rb +129 -0
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
- data/lib/graphql/schema/member/has_validators.rb +57 -0
- data/lib/graphql/schema/member/relay_shortcuts.rb +47 -2
- data/lib/graphql/schema/member/type_system_helpers.rb +20 -3
- data/lib/graphql/schema/member/validates_input.rb +3 -3
- data/lib/graphql/schema/member.rb +6 -6
- data/lib/graphql/schema/mutation.rb +4 -9
- data/lib/graphql/schema/non_null.rb +12 -7
- data/lib/graphql/schema/object.rb +35 -69
- data/lib/graphql/schema/printer.rb +16 -34
- data/lib/graphql/schema/relay_classic_mutation.rb +90 -43
- data/lib/graphql/schema/resolver/has_payload_type.rb +51 -11
- data/lib/graphql/schema/resolver.rb +144 -79
- data/lib/graphql/schema/scalar.rb +27 -18
- data/lib/graphql/schema/subscription.rb +55 -26
- data/lib/graphql/schema/timeout.rb +45 -35
- data/lib/graphql/schema/type_expression.rb +1 -1
- data/lib/graphql/schema/type_membership.rb +21 -4
- data/lib/graphql/schema/union.rb +48 -13
- data/lib/graphql/schema/unique_within_type.rb +1 -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 +185 -32
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +471 -1116
- data/lib/graphql/static_validation/all_rules.rb +3 -0
- data/lib/graphql/static_validation/base_visitor.rb +13 -27
- data/lib/graphql/static_validation/definition_dependencies.rb +7 -2
- data/lib/graphql/static_validation/error.rb +3 -1
- data/lib/graphql/static_validation/literal_validator.rb +69 -26
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +44 -87
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +22 -6
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +28 -22
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +4 -2
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +12 -6
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +13 -13
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +12 -4
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +92 -49
- 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/one_of_input_objects_are_valid.rb +66 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -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 +6 -7
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +13 -7
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +9 -10
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +14 -8
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +4 -2
- data/lib/graphql/static_validation/validation_context.rb +13 -3
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +32 -20
- data/lib/graphql/static_validation.rb +1 -2
- data/lib/graphql/string_encoding_error.rb +13 -3
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +126 -19
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +81 -0
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +58 -0
- data/lib/graphql/subscriptions/event.rb +81 -35
- data/lib/graphql/subscriptions/instrumentation.rb +0 -52
- data/lib/graphql/subscriptions/serialize.rb +53 -6
- data/lib/graphql/subscriptions.rb +113 -58
- data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +8 -21
- data/lib/graphql/tracing/appoptics_trace.rb +231 -0
- data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
- data/lib/graphql/tracing/appsignal_trace.rb +77 -0
- data/lib/graphql/tracing/appsignal_tracing.rb +15 -0
- data/lib/graphql/tracing/data_dog_trace.rb +148 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +26 -2
- data/lib/graphql/tracing/legacy_trace.rb +65 -0
- data/lib/graphql/tracing/new_relic_trace.rb +75 -0
- data/lib/graphql/tracing/new_relic_tracing.rb +1 -12
- data/lib/graphql/tracing/notifications_trace.rb +42 -0
- data/lib/graphql/tracing/notifications_tracing.rb +59 -0
- data/lib/graphql/tracing/platform_trace.rb +109 -0
- data/lib/graphql/tracing/platform_tracing.rb +64 -43
- data/lib/graphql/tracing/prometheus_trace.rb +89 -0
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +5 -2
- data/lib/graphql/tracing/prometheus_tracing.rb +3 -3
- data/lib/graphql/tracing/scout_trace.rb +72 -0
- data/lib/graphql/tracing/scout_tracing.rb +11 -0
- data/lib/graphql/tracing/statsd_trace.rb +56 -0
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing/trace.rb +75 -0
- data/lib/graphql/tracing.rb +23 -71
- data/lib/graphql/type_kinds.rb +6 -3
- 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 +20 -9
- data/lib/graphql/types/iso_8601_date_time.rb +36 -10
- data/lib/graphql/types/relay/base_connection.rb +18 -92
- data/lib/graphql/types/relay/base_edge.rb +2 -34
- data/lib/graphql/types/relay/connection_behaviors.rb +176 -0
- data/lib/graphql/types/relay/edge_behaviors.rb +75 -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 +25 -0
- data/lib/graphql/types/relay/page_info.rb +2 -14
- data/lib/graphql/types/relay/page_info_behaviors.rb +30 -0
- data/lib/graphql/types/relay.rb +10 -5
- data/lib/graphql/types/string.rb +8 -2
- data/lib/graphql/unauthorized_error.rb +2 -2
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +54 -65
- data/readme.md +3 -6
- metadata +116 -236
- data/lib/graphql/analysis/analyze_query.rb +0 -91
- data/lib/graphql/analysis/field_usage.rb +0 -45
- data/lib/graphql/analysis/max_query_complexity.rb +0 -26
- data/lib/graphql/analysis/max_query_depth.rb +0 -26
- data/lib/graphql/analysis/query_complexity.rb +0 -88
- data/lib/graphql/analysis/query_depth.rb +0 -43
- data/lib/graphql/analysis/reducer_state.rb +0 -48
- data/lib/graphql/argument.rb +0 -131
- data/lib/graphql/authorization.rb +0 -82
- data/lib/graphql/backwards_compatibility.rb +0 -60
- data/lib/graphql/base_type.rb +0 -230
- data/lib/graphql/boolean_type.rb +0 -2
- data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
- data/lib/graphql/compatibility/execution_specification.rb +0 -435
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
- data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -213
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -87
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -264
- data/lib/graphql/compatibility/schema_parser_specification.rb +0 -680
- data/lib/graphql/compatibility.rb +0 -5
- data/lib/graphql/define/assign_argument.rb +0 -12
- data/lib/graphql/define/assign_connection.rb +0 -13
- data/lib/graphql/define/assign_enum_value.rb +0 -18
- data/lib/graphql/define/assign_global_id_field.rb +0 -11
- data/lib/graphql/define/assign_mutation_function.rb +0 -34
- data/lib/graphql/define/assign_object_field.rb +0 -42
- data/lib/graphql/define/defined_object_proxy.rb +0 -53
- data/lib/graphql/define/instance_definable.rb +0 -210
- data/lib/graphql/define/no_definition_error.rb +0 -7
- data/lib/graphql/define/non_null_with_bang.rb +0 -16
- data/lib/graphql/define/type_definer.rb +0 -31
- data/lib/graphql/define.rb +0 -31
- data/lib/graphql/deprecated_dsl.rb +0 -42
- data/lib/graphql/directive/deprecated_directive.rb +0 -2
- data/lib/graphql/directive/include_directive.rb +0 -2
- data/lib/graphql/directive/skip_directive.rb +0 -2
- data/lib/graphql/directive.rb +0 -107
- data/lib/graphql/enum_type.rb +0 -127
- data/lib/graphql/execution/execute.rb +0 -326
- data/lib/graphql/execution/flatten.rb +0 -40
- data/lib/graphql/execution/instrumentation.rb +0 -92
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
- data/lib/graphql/execution/lazy/resolve.rb +0 -91
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -222
- data/lib/graphql/float_type.rb +0 -2
- data/lib/graphql/function.rb +0 -124
- data/lib/graphql/id_type.rb +0 -2
- data/lib/graphql/input_object_type.rb +0 -132
- data/lib/graphql/int_type.rb +0 -2
- data/lib/graphql/interface_type.rb +0 -65
- data/lib/graphql/internal_representation/document.rb +0 -27
- data/lib/graphql/internal_representation/node.rb +0 -206
- data/lib/graphql/internal_representation/print.rb +0 -51
- data/lib/graphql/internal_representation/rewrite.rb +0 -184
- data/lib/graphql/internal_representation/scope.rb +0 -88
- data/lib/graphql/internal_representation/visit.rb +0 -36
- data/lib/graphql/internal_representation.rb +0 -7
- data/lib/graphql/language/lexer.rl +0 -258
- data/lib/graphql/list_type.rb +0 -80
- data/lib/graphql/literal_validation_error.rb +0 -6
- data/lib/graphql/non_null_type.rb +0 -71
- data/lib/graphql/object_type.rb +0 -121
- data/lib/graphql/query/arguments.rb +0 -188
- data/lib/graphql/query/arguments_cache.rb +0 -25
- data/lib/graphql/query/executor.rb +0 -53
- data/lib/graphql/query/literal_input.rb +0 -136
- data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
- data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
- data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
- data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
- data/lib/graphql/query/serial_execution.rb +0 -39
- data/lib/graphql/relay/array_connection.rb +0 -85
- data/lib/graphql/relay/base_connection.rb +0 -176
- data/lib/graphql/relay/connection_instrumentation.rb +0 -54
- data/lib/graphql/relay/connection_resolve.rb +0 -43
- data/lib/graphql/relay/connection_type.rb +0 -41
- data/lib/graphql/relay/edge.rb +0 -27
- data/lib/graphql/relay/edge_type.rb +0 -19
- data/lib/graphql/relay/edges_instrumentation.rb +0 -40
- data/lib/graphql/relay/global_id_resolve.rb +0 -18
- data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
- data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
- data/lib/graphql/relay/mutation/resolve.rb +0 -56
- data/lib/graphql/relay/mutation/result.rb +0 -38
- data/lib/graphql/relay/mutation.rb +0 -105
- data/lib/graphql/relay/node.rb +0 -36
- data/lib/graphql/relay/page_info.rb +0 -7
- data/lib/graphql/relay/relation_connection.rb +0 -190
- data/lib/graphql/relay/type_extensions.rb +0 -30
- data/lib/graphql/scalar_type.rb +0 -76
- data/lib/graphql/schema/catchall_middleware.rb +0 -35
- data/lib/graphql/schema/default_parse_error.rb +0 -10
- data/lib/graphql/schema/default_type_error.rb +0 -15
- data/lib/graphql/schema/member/accepts_definition.rb +0 -152
- data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -31
- data/lib/graphql/schema/member/instrumentation.rb +0 -132
- data/lib/graphql/schema/middleware_chain.rb +0 -82
- data/lib/graphql/schema/possible_types.rb +0 -39
- data/lib/graphql/schema/rescue_middleware.rb +0 -60
- data/lib/graphql/schema/timeout_middleware.rb +0 -86
- data/lib/graphql/schema/traversal.rb +0 -228
- data/lib/graphql/schema/validation.rb +0 -303
- data/lib/graphql/static_validation/default_visitor.rb +0 -15
- data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
- data/lib/graphql/string_type.rb +0 -2
- data/lib/graphql/subscriptions/subscription_root.rb +0 -65
- data/lib/graphql/tracing/skylight_tracing.rb +0 -70
- 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/graphql/types/relay/node_field.rb +0 -43
- data/lib/graphql/types/relay/nodes_field.rb +0 -45
- data/lib/graphql/union_type.rb +0 -113
- data/lib/graphql/upgrader/member.rb +0 -936
- data/lib/graphql/upgrader/schema.rb +0 -37
@@ -3,7 +3,7 @@
|
|
3
3
|
module GraphQL
|
4
4
|
class Schema
|
5
5
|
class Member
|
6
|
-
# Shared code for
|
6
|
+
# Shared code for Objects, Interfaces, Mutations, Subscriptions
|
7
7
|
module HasFields
|
8
8
|
# Add a field to this object or interface with the given definition
|
9
9
|
# @see {GraphQL::Schema::Field#initialize} for method signature
|
@@ -14,31 +14,6 @@ module GraphQL
|
|
14
14
|
field_defn
|
15
15
|
end
|
16
16
|
|
17
|
-
# @return [Hash<String => GraphQL::Schema::Field>] Fields on this object, keyed by name, including inherited fields
|
18
|
-
def fields
|
19
|
-
# Local overrides take precedence over inherited fields
|
20
|
-
all_fields = {}
|
21
|
-
ancestors.reverse_each do |ancestor|
|
22
|
-
if ancestor.respond_to?(:own_fields)
|
23
|
-
all_fields.merge!(ancestor.own_fields)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
all_fields
|
27
|
-
end
|
28
|
-
|
29
|
-
def get_field(field_name)
|
30
|
-
if (f = own_fields[field_name])
|
31
|
-
f
|
32
|
-
else
|
33
|
-
for ancestor in ancestors
|
34
|
-
if ancestor.respond_to?(:own_fields) && f = ancestor.own_fields[field_name]
|
35
|
-
return f
|
36
|
-
end
|
37
|
-
end
|
38
|
-
nil
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
17
|
# A list of Ruby keywords.
|
43
18
|
#
|
44
19
|
# @api private
|
@@ -47,22 +22,41 @@ module GraphQL
|
|
47
22
|
# A list of GraphQL-Ruby keywords.
|
48
23
|
#
|
49
24
|
# @api private
|
50
|
-
GRAPHQL_RUBY_KEYWORDS = [:context, :object, :
|
25
|
+
GRAPHQL_RUBY_KEYWORDS = [:context, :object, :raw_value]
|
51
26
|
|
52
27
|
# A list of field names that we should advise users to pick a different
|
53
28
|
# resolve method name.
|
54
29
|
#
|
55
30
|
# @api private
|
56
|
-
CONFLICT_FIELD_NAMES = Set.new(GRAPHQL_RUBY_KEYWORDS + RUBY_KEYWORDS)
|
31
|
+
CONFLICT_FIELD_NAMES = Set.new(GRAPHQL_RUBY_KEYWORDS + RUBY_KEYWORDS + Object.instance_methods)
|
57
32
|
|
58
33
|
# Register this field with the class, overriding a previous one if needed.
|
59
34
|
# @param field_defn [GraphQL::Schema::Field]
|
60
35
|
# @return [void]
|
61
|
-
def add_field(field_defn)
|
62
|
-
|
63
|
-
|
36
|
+
def add_field(field_defn, method_conflict_warning: field_defn.method_conflict_warning?)
|
37
|
+
# Check that `field_defn.original_name` equals `resolver_method` and `method_sym` --
|
38
|
+
# that shows that no override value was given manually.
|
39
|
+
if method_conflict_warning &&
|
40
|
+
CONFLICT_FIELD_NAMES.include?(field_defn.resolver_method) &&
|
41
|
+
field_defn.original_name == field_defn.resolver_method &&
|
42
|
+
field_defn.original_name == field_defn.method_sym &&
|
43
|
+
field_defn.hash_key == NOT_CONFIGURED &&
|
44
|
+
field_defn.dig_keys.nil?
|
45
|
+
warn(conflict_field_name_warning(field_defn))
|
64
46
|
end
|
65
|
-
own_fields[field_defn.name]
|
47
|
+
prev_defn = own_fields[field_defn.name]
|
48
|
+
|
49
|
+
case prev_defn
|
50
|
+
when nil
|
51
|
+
own_fields[field_defn.name] = field_defn
|
52
|
+
when Array
|
53
|
+
prev_defn << field_defn
|
54
|
+
when GraphQL::Schema::Field
|
55
|
+
own_fields[field_defn.name] = [prev_defn, field_defn]
|
56
|
+
else
|
57
|
+
raise "Invariant: unexpected previous field definition for #{field_defn.name.inspect}: #{prev_defn.inspect}"
|
58
|
+
end
|
59
|
+
|
66
60
|
nil
|
67
61
|
end
|
68
62
|
|
@@ -70,28 +64,156 @@ module GraphQL
|
|
70
64
|
def field_class(new_field_class = nil)
|
71
65
|
if new_field_class
|
72
66
|
@field_class = new_field_class
|
73
|
-
elsif @field_class
|
67
|
+
elsif defined?(@field_class) && @field_class
|
74
68
|
@field_class
|
75
|
-
elsif self.is_a?(Class)
|
76
|
-
superclass.respond_to?(:field_class) ? superclass.field_class : GraphQL::Schema::Field
|
77
69
|
else
|
78
|
-
|
79
|
-
ancestor ? ancestor.field_class : GraphQL::Schema::Field
|
70
|
+
find_inherited_value(:field_class, GraphQL::Schema::Field)
|
80
71
|
end
|
81
72
|
end
|
82
73
|
|
83
|
-
def global_id_field(field_name)
|
84
|
-
|
85
|
-
field field_name, "ID", null: false
|
74
|
+
def global_id_field(field_name, **kwargs)
|
75
|
+
type = self
|
76
|
+
field field_name, "ID", **kwargs, null: false
|
86
77
|
define_method(field_name) do
|
87
|
-
|
78
|
+
context.schema.id_from_object(object, type, context)
|
88
79
|
end
|
89
80
|
end
|
90
81
|
|
91
|
-
# @return [Array<GraphQL::Schema::Field
|
82
|
+
# @return [Hash<String => GraphQL::Schema::Field, Array<GraphQL::Schema::Field>>] Fields defined on this class _specifically_, not parent classes
|
92
83
|
def own_fields
|
93
84
|
@own_fields ||= {}
|
94
85
|
end
|
86
|
+
|
87
|
+
def all_field_definitions
|
88
|
+
all_fields = {}
|
89
|
+
ancestors.reverse_each do |ancestor|
|
90
|
+
if ancestor.respond_to?(:own_fields)
|
91
|
+
all_fields.merge!(ancestor.own_fields)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
all_fields = all_fields.values
|
95
|
+
all_fields.flatten!
|
96
|
+
all_fields
|
97
|
+
end
|
98
|
+
|
99
|
+
module InterfaceMethods
|
100
|
+
def get_field(field_name, context = GraphQL::Query::NullContext)
|
101
|
+
warden = Warden.from_context(context)
|
102
|
+
for ancestor in ancestors
|
103
|
+
if ancestor.respond_to?(:own_fields) &&
|
104
|
+
(f_entry = ancestor.own_fields[field_name]) &&
|
105
|
+
(f = Warden.visible_entry?(:visible_field?, f_entry, context, warden))
|
106
|
+
return f
|
107
|
+
end
|
108
|
+
end
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
|
112
|
+
# @return [Hash<String => GraphQL::Schema::Field>] Fields on this object, keyed by name, including inherited fields
|
113
|
+
def fields(context = GraphQL::Query::NullContext)
|
114
|
+
warden = Warden.from_context(context)
|
115
|
+
# Local overrides take precedence over inherited fields
|
116
|
+
visible_fields = {}
|
117
|
+
for ancestor in ancestors
|
118
|
+
if ancestor.respond_to?(:own_fields)
|
119
|
+
ancestor.own_fields.each do |field_name, fields_entry|
|
120
|
+
# Choose the most local definition that passes `.visible?` --
|
121
|
+
# stop checking for fields by name once one has been found.
|
122
|
+
if !visible_fields.key?(field_name) && (f = Warden.visible_entry?(:visible_field?, fields_entry, context, warden))
|
123
|
+
visible_fields[field_name] = f
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
visible_fields
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
module ObjectMethods
|
133
|
+
def get_field(field_name, context = GraphQL::Query::NullContext)
|
134
|
+
# Objects need to check that the interface implementation is visible, too
|
135
|
+
warden = Warden.from_context(context)
|
136
|
+
for ancestor in ancestors
|
137
|
+
if ancestor.respond_to?(:own_fields) &&
|
138
|
+
visible_interface_implementation?(ancestor, context, warden) &&
|
139
|
+
(f_entry = ancestor.own_fields[field_name]) &&
|
140
|
+
(f = Warden.visible_entry?(:visible_field?, f_entry, context, warden))
|
141
|
+
return f
|
142
|
+
end
|
143
|
+
end
|
144
|
+
nil
|
145
|
+
end
|
146
|
+
|
147
|
+
# @return [Hash<String => GraphQL::Schema::Field>] Fields on this object, keyed by name, including inherited fields
|
148
|
+
def fields(context = GraphQL::Query::NullContext)
|
149
|
+
# Objects need to check that the interface implementation is visible, too
|
150
|
+
warden = Warden.from_context(context)
|
151
|
+
# Local overrides take precedence over inherited fields
|
152
|
+
visible_fields = {}
|
153
|
+
for ancestor in ancestors
|
154
|
+
if ancestor.respond_to?(:own_fields) && visible_interface_implementation?(ancestor, context, warden)
|
155
|
+
ancestor.own_fields.each do |field_name, fields_entry|
|
156
|
+
# Choose the most local definition that passes `.visible?` --
|
157
|
+
# stop checking for fields by name once one has been found.
|
158
|
+
if !visible_fields.key?(field_name) && (f = Warden.visible_entry?(:visible_field?, fields_entry, context, warden))
|
159
|
+
visible_fields[field_name] = f
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
visible_fields
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.included(child_class)
|
169
|
+
# Included in an interface definition methods module
|
170
|
+
child_class.include(InterfaceMethods)
|
171
|
+
super
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.extended(child_class)
|
175
|
+
child_class.extend(ObjectMethods)
|
176
|
+
super
|
177
|
+
end
|
178
|
+
|
179
|
+
private
|
180
|
+
|
181
|
+
def inherited(subclass)
|
182
|
+
super
|
183
|
+
subclass.class_eval do
|
184
|
+
@own_fields ||= nil
|
185
|
+
@field_class ||= nil
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# If `type` is an interface, and `self` has a type membership for `type`, then make sure it's visible.
|
190
|
+
def visible_interface_implementation?(type, context, warden)
|
191
|
+
if type.respond_to?(:kind) && type.kind.interface?
|
192
|
+
implements_this_interface = false
|
193
|
+
implementation_is_visible = false
|
194
|
+
warden.interface_type_memberships(self, context).each do |tm|
|
195
|
+
if tm.abstract_type == type
|
196
|
+
implements_this_interface ||= true
|
197
|
+
if warden.visible_type_membership?(tm, context)
|
198
|
+
implementation_is_visible = true
|
199
|
+
break
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
# It's possible this interface came by way of `include` in another interface which this
|
204
|
+
# object type _does_ implement, and that's ok
|
205
|
+
implements_this_interface ? implementation_is_visible : true
|
206
|
+
else
|
207
|
+
# If there's no implementation, then we're looking at Ruby-style inheritance instead
|
208
|
+
true
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# @param [GraphQL::Schema::Field]
|
213
|
+
# @return [String] A warning to give when this field definition might conflict with a built-in method
|
214
|
+
def conflict_field_name_warning(field_defn)
|
215
|
+
"#{self.graphql_name}'s `field :#{field_defn.original_name}` conflicts with a built-in method, use `resolver_method:` to pick a different resolver method for this field (for example, `resolver_method: :resolve_#{field_defn.resolver_method}` and `def resolve_#{field_defn.resolver_method}`). Or use `method_conflict_warning: false` to suppress this warning."
|
216
|
+
end
|
95
217
|
end
|
96
218
|
end
|
97
219
|
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
class Schema
|
5
|
+
class Member
|
6
|
+
module HasInterfaces
|
7
|
+
def implements(*new_interfaces, **options)
|
8
|
+
new_memberships = []
|
9
|
+
new_interfaces.each do |int|
|
10
|
+
if int.is_a?(Module)
|
11
|
+
unless int.include?(GraphQL::Schema::Interface)
|
12
|
+
raise "#{int} cannot be implemented since it's not a GraphQL Interface. Use `include` for plain Ruby modules."
|
13
|
+
end
|
14
|
+
|
15
|
+
new_memberships << int.type_membership_class.new(int, self, **options)
|
16
|
+
|
17
|
+
# Include the methods here,
|
18
|
+
# `.fields` will use the inheritance chain
|
19
|
+
# to find inherited fields
|
20
|
+
include(int)
|
21
|
+
|
22
|
+
# If this interface has interfaces of its own, add those, too
|
23
|
+
int.interfaces.each do |next_interface|
|
24
|
+
implements(next_interface)
|
25
|
+
end
|
26
|
+
elsif int.is_a?(String) || int.is_a?(GraphQL::Schema::LateBoundType)
|
27
|
+
if options.any?
|
28
|
+
raise ArgumentError, "`implements(...)` doesn't support options with late-loaded types yet. Remove #{options} and open an issue to request this feature."
|
29
|
+
end
|
30
|
+
new_memberships << int
|
31
|
+
else
|
32
|
+
raise ArgumentError, "Unexpected interface definition (expected module): #{int} (#{int.class})"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Remove any String or late-bound interfaces which are being replaced
|
37
|
+
own_interface_type_memberships.reject! { |old_i_m|
|
38
|
+
if !(old_i_m.respond_to?(:abstract_type) && old_i_m.abstract_type.is_a?(Module))
|
39
|
+
old_int_type = old_i_m.respond_to?(:abstract_type) ? old_i_m.abstract_type : old_i_m
|
40
|
+
old_name = Schema::Member::BuildType.to_type_name(old_int_type)
|
41
|
+
|
42
|
+
new_memberships.any? { |new_i_m|
|
43
|
+
new_int_type = new_i_m.respond_to?(:abstract_type) ? new_i_m.abstract_type : new_i_m
|
44
|
+
new_name = Schema::Member::BuildType.to_type_name(new_int_type)
|
45
|
+
|
46
|
+
new_name == old_name
|
47
|
+
}
|
48
|
+
end
|
49
|
+
}
|
50
|
+
own_interface_type_memberships.concat(new_memberships)
|
51
|
+
end
|
52
|
+
|
53
|
+
def own_interface_type_memberships
|
54
|
+
@own_interface_type_memberships ||= []
|
55
|
+
end
|
56
|
+
|
57
|
+
def interface_type_memberships
|
58
|
+
own_interface_type_memberships
|
59
|
+
end
|
60
|
+
|
61
|
+
module ClassConfigured
|
62
|
+
# This combination of extended -> inherited -> extended
|
63
|
+
# means that the base class (`Schema::Object`) *won't*
|
64
|
+
# have the superclass-related code in `InheritedInterfaces`,
|
65
|
+
# but child classes of `Schema::Object` will have it.
|
66
|
+
# That way, we don't need a `superclass.respond_to?(...)` check.
|
67
|
+
def inherited(child_class)
|
68
|
+
super
|
69
|
+
child_class.extend(InheritedInterfaces)
|
70
|
+
end
|
71
|
+
|
72
|
+
module InheritedInterfaces
|
73
|
+
def interfaces(context = GraphQL::Query::NullContext)
|
74
|
+
visible_interfaces = super
|
75
|
+
visible_interfaces.concat(superclass.interfaces(context))
|
76
|
+
visible_interfaces.uniq!
|
77
|
+
visible_interfaces
|
78
|
+
end
|
79
|
+
|
80
|
+
def interface_type_memberships
|
81
|
+
own_tms = super
|
82
|
+
inherited_tms = superclass.interface_type_memberships
|
83
|
+
if inherited_tms.size > 0
|
84
|
+
own_tms + inherited_tms
|
85
|
+
else
|
86
|
+
own_tms
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# param context [Query::Context] If omitted, skip filtering.
|
93
|
+
def interfaces(context = GraphQL::Query::NullContext)
|
94
|
+
warden = Warden.from_context(context)
|
95
|
+
visible_interfaces = []
|
96
|
+
own_interface_type_memberships.each do |type_membership|
|
97
|
+
case type_membership
|
98
|
+
when Schema::TypeMembership
|
99
|
+
if warden.visible_type_membership?(type_membership, context)
|
100
|
+
visible_interfaces << type_membership.abstract_type
|
101
|
+
end
|
102
|
+
when String, Schema::LateBoundType
|
103
|
+
# During initialization, `type_memberships` can hold late-bound types
|
104
|
+
visible_interfaces << type_membership
|
105
|
+
else
|
106
|
+
raise "Invariant: Unexpected type_membership #{type_membership.class}: #{type_membership.inspect}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
visible_interfaces.uniq!
|
110
|
+
|
111
|
+
visible_interfaces
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def self.extended(child_class)
|
117
|
+
child_class.extend(ClassConfigured)
|
118
|
+
end
|
119
|
+
|
120
|
+
def inherited(subclass)
|
121
|
+
super
|
122
|
+
subclass.class_eval do
|
123
|
+
@own_interface_type_memberships ||= nil
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
class Schema
|
5
|
+
class Member
|
6
|
+
# Set up a type-specific error to make debugging & bug tracker integration better
|
7
|
+
module HasUnresolvedTypeError
|
8
|
+
private
|
9
|
+
def add_unresolved_type_error(child_class)
|
10
|
+
child_class.const_set(:UnresolvedTypeError, Class.new(GraphQL::UnresolvedTypeError))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class Schema
|
4
|
+
class Member
|
5
|
+
module HasValidators
|
6
|
+
include GraphQL::EmptyObjects
|
7
|
+
|
8
|
+
# Build {GraphQL::Schema::Validator}s based on the given configuration
|
9
|
+
# and use them for this schema member
|
10
|
+
# @param validation_config [Hash{Symbol => Hash}]
|
11
|
+
# @return [void]
|
12
|
+
def validates(validation_config)
|
13
|
+
new_validators = GraphQL::Schema::Validator.from_config(self, validation_config)
|
14
|
+
@own_validators ||= []
|
15
|
+
@own_validators.concat(new_validators)
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Array<GraphQL::Schema::Validator>]
|
20
|
+
def validators
|
21
|
+
@own_validators || EMPTY_ARRAY
|
22
|
+
end
|
23
|
+
|
24
|
+
module ClassConfigured
|
25
|
+
def inherited(child_cls)
|
26
|
+
super
|
27
|
+
child_cls.extend(ClassValidators)
|
28
|
+
end
|
29
|
+
|
30
|
+
module ClassValidators
|
31
|
+
include GraphQL::EmptyObjects
|
32
|
+
|
33
|
+
def validators
|
34
|
+
inherited_validators = superclass.validators
|
35
|
+
if inherited_validators.any?
|
36
|
+
if @own_validators.nil?
|
37
|
+
inherited_validators
|
38
|
+
else
|
39
|
+
inherited_validators + @own_validators
|
40
|
+
end
|
41
|
+
elsif @own_validators.nil?
|
42
|
+
EMPTY_ARRAY
|
43
|
+
else
|
44
|
+
@own_validators
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.extended(child_cls)
|
51
|
+
super
|
52
|
+
child_cls.extend(ClassConfigured)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -6,21 +6,40 @@ module GraphQL
|
|
6
6
|
module RelayShortcuts
|
7
7
|
def edge_type_class(new_edge_type_class = nil)
|
8
8
|
if new_edge_type_class
|
9
|
+
initialize_relay_metadata
|
9
10
|
@edge_type_class = new_edge_type_class
|
10
11
|
else
|
11
|
-
|
12
|
+
# Don't call `ancestor.edge_type_class`
|
13
|
+
# because we don't want a fallback from any ancestors --
|
14
|
+
# only apply the fallback if _no_ ancestor has a configured value!
|
15
|
+
for ancestor in self.ancestors
|
16
|
+
if ancestor.respond_to?(:configured_edge_type_class, true) && (etc = ancestor.configured_edge_type_class)
|
17
|
+
return etc
|
18
|
+
end
|
19
|
+
end
|
20
|
+
Types::Relay::BaseEdge
|
12
21
|
end
|
13
22
|
end
|
14
23
|
|
15
24
|
def connection_type_class(new_connection_type_class = nil)
|
16
25
|
if new_connection_type_class
|
26
|
+
initialize_relay_metadata
|
17
27
|
@connection_type_class = new_connection_type_class
|
18
28
|
else
|
19
|
-
|
29
|
+
# Don't call `ancestor.connection_type_class`
|
30
|
+
# because we don't want a fallback from any ancestors --
|
31
|
+
# only apply the fallback if _no_ ancestor has a configured value!
|
32
|
+
for ancestor in self.ancestors
|
33
|
+
if ancestor.respond_to?(:configured_connection_type_class, true) && (ctc = ancestor.configured_connection_type_class)
|
34
|
+
return ctc
|
35
|
+
end
|
36
|
+
end
|
37
|
+
Types::Relay::BaseConnection
|
20
38
|
end
|
21
39
|
end
|
22
40
|
|
23
41
|
def edge_type
|
42
|
+
initialize_relay_metadata
|
24
43
|
@edge_type ||= begin
|
25
44
|
edge_name = self.graphql_name + "Edge"
|
26
45
|
node_type_class = self
|
@@ -32,6 +51,7 @@ module GraphQL
|
|
32
51
|
end
|
33
52
|
|
34
53
|
def connection_type
|
54
|
+
initialize_relay_metadata
|
35
55
|
@connection_type ||= begin
|
36
56
|
conn_name = self.graphql_name + "Connection"
|
37
57
|
edge_type_class = self.edge_type
|
@@ -41,6 +61,31 @@ module GraphQL
|
|
41
61
|
end
|
42
62
|
end
|
43
63
|
end
|
64
|
+
|
65
|
+
protected
|
66
|
+
|
67
|
+
def configured_connection_type_class
|
68
|
+
@connection_type_class
|
69
|
+
end
|
70
|
+
|
71
|
+
def configured_edge_type_class
|
72
|
+
@edge_type_class
|
73
|
+
end
|
74
|
+
|
75
|
+
attr_writer :edge_type, :connection_type, :connection_type_class, :edge_type_class
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
# If one of thse values is accessed, initialize all the instance variables to retain
|
80
|
+
# a consistent object shape.
|
81
|
+
def initialize_relay_metadata
|
82
|
+
if !defined?(@connection_type)
|
83
|
+
@connection_type = nil
|
84
|
+
@edge_type = nil
|
85
|
+
@connection_type_class = nil
|
86
|
+
@edge_type_class = nil
|
87
|
+
end
|
88
|
+
end
|
44
89
|
end
|
45
90
|
end
|
46
91
|
end
|
@@ -4,14 +4,21 @@ module GraphQL
|
|
4
4
|
class Schema
|
5
5
|
class Member
|
6
6
|
module TypeSystemHelpers
|
7
|
+
def initialize(*args, &block)
|
8
|
+
super
|
9
|
+
@to_non_null_type ||= nil
|
10
|
+
@to_list_type ||= nil
|
11
|
+
end
|
12
|
+
ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true)
|
13
|
+
|
7
14
|
# @return [Schema::NonNull] Make a non-null-type representation of this type
|
8
15
|
def to_non_null_type
|
9
|
-
GraphQL::Schema::NonNull.new(self)
|
16
|
+
@to_non_null_type ||= GraphQL::Schema::NonNull.new(self)
|
10
17
|
end
|
11
18
|
|
12
19
|
# @return [Schema::List] Make a list-type representation of this type
|
13
20
|
def to_list_type
|
14
|
-
GraphQL::Schema::List.new(self)
|
21
|
+
@to_list_type ||= GraphQL::Schema::List.new(self)
|
15
22
|
end
|
16
23
|
|
17
24
|
# @return [Boolean] true if this is a non-nullable type. A nullable list of non-nullables is considered nullable.
|
@@ -30,7 +37,17 @@ module GraphQL
|
|
30
37
|
|
31
38
|
# @return [GraphQL::TypeKinds::TypeKind]
|
32
39
|
def kind
|
33
|
-
raise GraphQL::RequiredImplementationMissingError
|
40
|
+
raise GraphQL::RequiredImplementationMissingError, "No `.kind` defined for #{self}"
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def inherited(subclass)
|
46
|
+
subclass.class_eval do
|
47
|
+
@to_non_null_type ||= nil
|
48
|
+
@to_list_type ||= nil
|
49
|
+
end
|
50
|
+
super
|
34
51
|
end
|
35
52
|
end
|
36
53
|
end
|
@@ -8,11 +8,11 @@ module GraphQL
|
|
8
8
|
validate_input(val, ctx).valid?
|
9
9
|
end
|
10
10
|
|
11
|
-
def validate_input(val, ctx)
|
11
|
+
def validate_input(val, ctx, max_errors: nil)
|
12
12
|
if val.nil?
|
13
|
-
|
13
|
+
Query::InputValidationResult::VALID
|
14
14
|
else
|
15
|
-
validate_non_null_input(val, ctx)
|
15
|
+
validate_non_null_input(val, ctx, max_errors: max_errors) || Query::InputValidationResult::VALID
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -1,15 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'graphql/schema/member/accepts_definition'
|
3
2
|
require 'graphql/schema/member/base_dsl_methods'
|
4
|
-
require 'graphql/schema/member/cached_graphql_definition'
|
5
3
|
require 'graphql/schema/member/graphql_type_names'
|
6
4
|
require 'graphql/schema/member/has_ast_node'
|
5
|
+
require 'graphql/schema/member/has_directives'
|
6
|
+
require 'graphql/schema/member/has_deprecation_reason'
|
7
|
+
require 'graphql/schema/member/has_interfaces'
|
7
8
|
require 'graphql/schema/member/has_path'
|
9
|
+
require 'graphql/schema/member/has_unresolved_type_error'
|
10
|
+
require 'graphql/schema/member/has_validators'
|
8
11
|
require 'graphql/schema/member/relay_shortcuts'
|
9
12
|
require 'graphql/schema/member/scoped'
|
10
13
|
require 'graphql/schema/member/type_system_helpers'
|
11
14
|
require 'graphql/schema/member/validates_input'
|
12
|
-
require "graphql/relay/type_extensions"
|
13
15
|
|
14
16
|
module GraphQL
|
15
17
|
class Schema
|
@@ -19,8 +21,6 @@ module GraphQL
|
|
19
21
|
# @api private
|
20
22
|
class Member
|
21
23
|
include GraphQLTypeNames
|
22
|
-
extend CachedGraphQLDefinition
|
23
|
-
extend GraphQL::Relay::TypeExtensions
|
24
24
|
extend BaseDSLMethods
|
25
25
|
extend BaseDSLMethods::ConfigurationExtension
|
26
26
|
introspection(false)
|
@@ -29,11 +29,11 @@ module GraphQL
|
|
29
29
|
extend RelayShortcuts
|
30
30
|
extend HasPath
|
31
31
|
extend HasAstNode
|
32
|
+
extend HasDirectives
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
37
|
require 'graphql/schema/member/has_arguments'
|
37
38
|
require 'graphql/schema/member/has_fields'
|
38
|
-
require 'graphql/schema/member/instrumentation'
|
39
39
|
require 'graphql/schema/member/build_type'
|
@@ -63,21 +63,16 @@ module GraphQL
|
|
63
63
|
extend GraphQL::Schema::Resolver::HasPayloadType
|
64
64
|
|
65
65
|
class << self
|
66
|
-
# Override this method to handle legacy-style usages of `MyMutation.field`
|
67
|
-
def field(*args, **kwargs, &block)
|
68
|
-
if args.empty?
|
69
|
-
raise ArgumentError, "#{name}.field is used for adding fields to this mutation. Use `mutation: #{name}` to attach this mutation instead."
|
70
|
-
else
|
71
|
-
super
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
66
|
def visible?(context)
|
76
67
|
true
|
77
68
|
end
|
78
69
|
|
79
70
|
private
|
80
71
|
|
72
|
+
def conflict_field_name_warning(field_defn)
|
73
|
+
"#{self.graphql_name}'s `field :#{field_defn.name}` conflicts with a built-in method, use `hash_key:` or `method:` to pick a different resolve behavior for this field (for example, `hash_key: :#{field_defn.resolver_method}_value`, and modify the return hash). Or use `method_conflict_warning: false` to suppress this warning."
|
74
|
+
end
|
75
|
+
|
81
76
|
# Override this to attach self as `mutation`
|
82
77
|
def generate_payload_type
|
83
78
|
payload_class = super
|