graphql 2.6.12 → 2.6.14
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.
- checksums.yaml +4 -4
- data/.rdoc_options +4 -0
- data/lib/generators/graphql/core.rb +1 -0
- data/lib/generators/graphql/detailed_trace_generator.rb +1 -0
- data/lib/generators/graphql/enum_generator.rb +1 -0
- data/lib/generators/graphql/field_extractor.rb +1 -0
- data/lib/generators/graphql/input_generator.rb +1 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +1 -0
- data/lib/generators/graphql/install_generator.rb +1 -0
- data/lib/generators/graphql/interface_generator.rb +1 -0
- data/lib/generators/graphql/loader_generator.rb +8 -2
- data/lib/generators/graphql/mutation_create_generator.rb +8 -2
- data/lib/generators/graphql/mutation_delete_generator.rb +8 -2
- data/lib/generators/graphql/mutation_generator.rb +8 -2
- data/lib/generators/graphql/mutation_update_generator.rb +8 -2
- data/lib/generators/graphql/object_generator.rb +1 -0
- data/lib/generators/graphql/orm_mutations_base.rb +8 -2
- data/lib/generators/graphql/relay.rb +1 -0
- data/lib/generators/graphql/relay_generator.rb +1 -0
- data/lib/generators/graphql/scalar_generator.rb +1 -0
- data/lib/generators/graphql/type_generator.rb +38 -8
- data/lib/generators/graphql/union_generator.rb +1 -0
- data/lib/graphql/analysis/analyzer.rb +35 -9
- data/lib/graphql/analysis/field_usage.rb +1 -0
- data/lib/graphql/analysis/max_query_complexity.rb +3 -2
- data/lib/graphql/analysis/max_query_depth.rb +1 -0
- data/lib/graphql/analysis/query_complexity.rb +57 -20
- data/lib/graphql/analysis/query_depth.rb +17 -12
- data/lib/graphql/analysis/visitor.rb +79 -16
- data/lib/graphql/analysis.rb +23 -6
- data/lib/graphql/analysis_error.rb +1 -0
- data/lib/graphql/autoload.rb +30 -7
- data/lib/graphql/backtrace/table.rb +21 -5
- data/lib/graphql/backtrace/traced_error.rb +8 -3
- data/lib/graphql/backtrace.rb +14 -9
- data/lib/graphql/coercion_error.rb +1 -0
- data/lib/graphql/current.rb +44 -19
- data/lib/graphql/dashboard/application_controller.rb +1 -0
- data/lib/graphql/dashboard/detailed_traces.rb +1 -0
- data/lib/graphql/dashboard/installable.rb +1 -0
- data/lib/graphql/dashboard/landings_controller.rb +1 -0
- data/lib/graphql/dashboard/limiters.rb +1 -0
- data/lib/graphql/dashboard/operation_store.rb +1 -0
- data/lib/graphql/dashboard/statics_controller.rb +1 -0
- data/lib/graphql/dashboard/subscriptions.rb +1 -0
- data/lib/graphql/dashboard.rb +36 -22
- data/lib/graphql/dataloader/active_record_association_source.rb +1 -0
- data/lib/graphql/dataloader/active_record_source.rb +1 -0
- data/lib/graphql/dataloader/async_dataloader.rb +8 -7
- data/lib/graphql/dataloader/null_dataloader.rb +4 -3
- data/lib/graphql/dataloader/request.rb +8 -2
- data/lib/graphql/dataloader/request_all.rb +8 -2
- data/lib/graphql/dataloader/source.rb +127 -35
- data/lib/graphql/dataloader.rb +91 -42
- data/lib/graphql/date_encoding_error.rb +2 -1
- data/lib/graphql/dig.rb +12 -3
- data/lib/graphql/duration_encoding_error.rb +2 -1
- data/lib/graphql/execution/directive_checks.rb +8 -3
- data/lib/graphql/execution/errors.rb +20 -6
- data/lib/graphql/execution/field_resolve_step.rb +263 -161
- data/lib/graphql/execution/finalize.rb +12 -6
- data/lib/graphql/execution/input_values.rb +5 -2
- data/lib/graphql/execution/interpreter/argument_value.rb +17 -5
- data/lib/graphql/execution/interpreter/arguments.rb +24 -9
- data/lib/graphql/execution/interpreter/arguments_cache.rb +2 -1
- data/lib/graphql/execution/interpreter/execution_errors.rb +1 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +1 -0
- data/lib/graphql/execution/interpreter/resolve.rb +18 -8
- data/lib/graphql/execution/interpreter/runtime/graphql_result.rb +4 -1
- data/lib/graphql/execution/interpreter/runtime.rb +66 -23
- data/lib/graphql/execution/interpreter.rb +15 -6
- data/lib/graphql/execution/lazy/lazy_method_map.rb +21 -8
- data/lib/graphql/execution/lazy.rb +34 -10
- data/lib/graphql/execution/load_argument_step.rb +1 -0
- data/lib/graphql/execution/lookahead.rb +137 -54
- data/lib/graphql/execution/multiplex.rb +4 -4
- data/lib/graphql/execution/next.rb +7 -0
- data/lib/graphql/execution/prepare_object_step.rb +38 -13
- data/lib/graphql/execution/resolve_type_step.rb +2 -1
- data/lib/graphql/execution/runner.rb +9 -3
- data/lib/graphql/execution/selections_step.rb +3 -2
- data/lib/graphql/execution.rb +2 -2
- data/lib/graphql/execution_error.rb +19 -10
- data/lib/graphql/float_decoding_error.rb +1 -0
- data/lib/graphql/float_encoding_error.rb +7 -2
- data/lib/graphql/integer_decoding_error.rb +2 -1
- data/lib/graphql/integer_encoding_error.rb +8 -3
- data/lib/graphql/introspection/base_object.rb +3 -1
- data/lib/graphql/introspection/directive_location_enum.rb +1 -0
- data/lib/graphql/introspection/directive_type.rb +1 -0
- data/lib/graphql/introspection/dynamic_fields.rb +1 -0
- data/lib/graphql/introspection/entry_points.rb +1 -0
- data/lib/graphql/introspection/enum_value_type.rb +1 -0
- data/lib/graphql/introspection/field_type.rb +1 -0
- data/lib/graphql/introspection/input_value_type.rb +1 -0
- data/lib/graphql/introspection/introspection_query.rb +1 -0
- data/lib/graphql/introspection/schema_type.rb +1 -0
- data/lib/graphql/introspection/type_kind_enum.rb +1 -0
- data/lib/graphql/introspection/type_type.rb +1 -0
- data/lib/graphql/introspection.rb +1 -0
- data/lib/graphql/invalid_name_error.rb +1 -0
- data/lib/graphql/invalid_null_error.rb +19 -6
- data/lib/graphql/language/block_string.rb +2 -1
- data/lib/graphql/language/cache.rb +10 -4
- data/lib/graphql/language/comment.rb +1 -0
- data/lib/graphql/language/definition_slice.rb +1 -0
- data/lib/graphql/language/document_from_schema_definition.rb +9 -10
- data/lib/graphql/language/generation.rb +23 -9
- data/lib/graphql/language/lexer.rb +6 -1
- data/lib/graphql/language/nodes.rb +2094 -419
- data/lib/graphql/language/parser.rb +22 -12
- data/lib/graphql/language/printer.rb +31 -16
- data/lib/graphql/language/sanitized_printer.rb +16 -5
- data/lib/graphql/language/static_visitor.rb +19 -4
- data/lib/graphql/language/visitor.rb +51 -29
- data/lib/graphql/language.rb +13 -7
- data/lib/graphql/load_application_object_failed_error.rb +14 -5
- data/lib/graphql/name_validator.rb +1 -0
- data/lib/graphql/pagination/active_record_relation_connection.rb +1 -0
- data/lib/graphql/pagination/array_connection.rb +20 -6
- data/lib/graphql/pagination/connection.rb +178 -48
- data/lib/graphql/pagination/connections.rb +21 -14
- data/lib/graphql/pagination/mongoid_relation_connection.rb +1 -0
- data/lib/graphql/pagination/relation_connection.rb +137 -29
- data/lib/graphql/pagination/sequel_dataset_connection.rb +1 -0
- data/lib/graphql/pagination.rb +1 -0
- data/lib/graphql/parse_error.rb +1 -0
- data/lib/graphql/query/context/scoped_context.rb +2 -1
- data/lib/graphql/query/context.rb +106 -35
- data/lib/graphql/query/fingerprint.rb +15 -7
- data/lib/graphql/query/input_validation_result.rb +1 -0
- data/lib/graphql/query/null_context.rb +1 -0
- data/lib/graphql/query/partial.rb +28 -16
- data/lib/graphql/query/result.rb +15 -5
- data/lib/graphql/query/validation_pipeline.rb +16 -6
- data/lib/graphql/query/variable_validation_error.rb +1 -0
- data/lib/graphql/query/variables.rb +4 -1
- data/lib/graphql/query.rb +193 -49
- data/lib/graphql/railtie.rb +7 -3
- data/lib/graphql/rake_task/validate.rb +72 -17
- data/lib/graphql/rake_task.rb +55 -23
- data/lib/graphql/relay/range_add.rb +32 -21
- data/lib/graphql/relay.rb +1 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +1 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/default_required_true.rb +9 -6
- data/lib/graphql/rubocop/graphql/field_type_in_block.rb +12 -8
- data/lib/graphql/rubocop/graphql/root_types_in_block.rb +9 -5
- data/lib/graphql/rubocop.rb +1 -0
- data/lib/graphql/runtime_error.rb +1 -0
- data/lib/graphql/runtime_type_error.rb +1 -0
- data/lib/graphql/schema/addition.rb +69 -50
- data/lib/graphql/schema/always_visible.rb +1 -0
- data/lib/graphql/schema/argument.rb +279 -45
- data/lib/graphql/schema/base_64_encoder.rb +2 -2
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -0
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +2 -2
- data/lib/graphql/schema/build_from_definition.rb +507 -178
- data/lib/graphql/schema/built_in_types.rb +1 -0
- data/lib/graphql/schema/directive/deprecated.rb +1 -0
- data/lib/graphql/schema/directive/feature.rb +39 -22
- data/lib/graphql/schema/directive/flagged.rb +6 -1
- data/lib/graphql/schema/directive/include.rb +1 -0
- data/lib/graphql/schema/directive/one_of.rb +1 -0
- data/lib/graphql/schema/directive/skip.rb +1 -0
- data/lib/graphql/schema/directive/specified_by.rb +1 -0
- data/lib/graphql/schema/directive/transform.rb +17 -8
- data/lib/graphql/schema/directive.rb +28 -7
- data/lib/graphql/schema/enum.rb +99 -38
- data/lib/graphql/schema/enum_value.rb +21 -13
- data/lib/graphql/schema/field/connection_extension.rb +10 -2
- data/lib/graphql/schema/field/scope_extension.rb +1 -0
- data/lib/graphql/schema/field.rb +622 -110
- data/lib/graphql/schema/field_extension.rb +89 -34
- data/lib/graphql/schema/find_inherited_value.rb +5 -3
- data/lib/graphql/schema/finder.rb +22 -8
- data/lib/graphql/schema/has_single_input_argument.rb +39 -6
- data/lib/graphql/schema/input_object.rb +40 -13
- data/lib/graphql/schema/interface.rb +33 -17
- data/lib/graphql/schema/introspection_system.rb +7 -3
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/list.rb +15 -4
- data/lib/graphql/schema/loader.rb +23 -12
- data/lib/graphql/schema/member/base_dsl_methods.rb +58 -12
- data/lib/graphql/schema/member/build_type.rb +21 -7
- data/lib/graphql/schema/member/graphql_type_names.rb +10 -6
- data/lib/graphql/schema/member/has_arguments.rb +111 -48
- data/lib/graphql/schema/member/has_ast_node.rb +1 -0
- data/lib/graphql/schema/member/has_authorization.rb +5 -0
- data/lib/graphql/schema/member/has_dataloader.rb +91 -34
- data/lib/graphql/schema/member/has_deprecation_reason.rb +15 -2
- data/lib/graphql/schema/member/has_directives.rb +45 -11
- data/lib/graphql/schema/member/has_fields.rb +151 -70
- data/lib/graphql/schema/member/has_interfaces.rb +8 -2
- data/lib/graphql/schema/member/has_path.rb +14 -5
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +1 -0
- data/lib/graphql/schema/member/has_validators.rb +19 -4
- data/lib/graphql/schema/member/relay_shortcuts.rb +10 -2
- data/lib/graphql/schema/member/scoped.rb +14 -3
- data/lib/graphql/schema/member/type_system_helpers.rb +36 -6
- data/lib/graphql/schema/member/validates_input.rb +1 -0
- data/lib/graphql/schema/member.rb +9 -2
- data/lib/graphql/schema/mutation.rb +50 -46
- data/lib/graphql/schema/non_null.rb +21 -5
- data/lib/graphql/schema/object.rb +44 -15
- data/lib/graphql/schema/printer.rb +52 -31
- data/lib/graphql/schema/ractor_shareable.rb +6 -2
- data/lib/graphql/schema/relay_classic_mutation.rb +3 -3
- data/lib/graphql/schema/resolver/has_payload_type.rb +29 -7
- data/lib/graphql/schema/resolver.rb +156 -45
- data/lib/graphql/schema/scalar.rb +1 -0
- data/lib/graphql/schema/subscription.rb +67 -28
- data/lib/graphql/schema/timeout.rb +65 -25
- data/lib/graphql/schema/type_expression.rb +14 -5
- data/lib/graphql/schema/type_membership.rb +29 -10
- data/lib/graphql/schema/union.rb +4 -2
- data/lib/graphql/schema/unique_within_type.rb +24 -5
- data/lib/graphql/schema/validator/all_validator.rb +17 -9
- data/lib/graphql/schema/validator/allow_blank_validator.rb +8 -2
- data/lib/graphql/schema/validator/allow_null_validator.rb +8 -2
- data/lib/graphql/schema/validator/exclusion_validator.rb +14 -5
- data/lib/graphql/schema/validator/format_validator.rb +21 -10
- data/lib/graphql/schema/validator/inclusion_validator.rb +15 -6
- data/lib/graphql/schema/validator/length_validator.rb +23 -12
- data/lib/graphql/schema/validator/numericality_validator.rb +29 -16
- data/lib/graphql/schema/validator/required_validator.rb +45 -31
- data/lib/graphql/schema/validator.rb +89 -25
- data/lib/graphql/schema/visibility/migration.rb +14 -7
- data/lib/graphql/schema/visibility/profile.rb +20 -17
- data/lib/graphql/schema/visibility/visit.rb +12 -10
- data/lib/graphql/schema/visibility.rb +24 -20
- data/lib/graphql/schema/warden.rb +117 -31
- data/lib/graphql/schema/wrapper.rb +4 -1
- data/lib/graphql/schema.rb +1050 -302
- data/lib/graphql/static_validation/all_rules.rb +2 -1
- data/lib/graphql/static_validation/base_visitor.rb +48 -8
- data/lib/graphql/static_validation/definition_dependencies.rb +27 -7
- data/lib/graphql/static_validation/error.rb +3 -0
- data/lib/graphql/static_validation/interpreter_visitor.rb +1 -0
- data/lib/graphql/static_validation/literal_validator.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +4 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +1 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +3 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +3 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +9 -1
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +295 -134
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +14 -2
- data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +3 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -0
- data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +1 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +3 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/not_single_subscription_error.rb +1 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +4 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +3 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +1 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +3 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +4 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +1 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists_and_single_subscription_selection.rb +4 -1
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +1 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +3 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +3 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +207 -51
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +3 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +1 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +6 -3
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +1 -0
- data/lib/graphql/static_validation/validation_context.rb +3 -2
- data/lib/graphql/static_validation/validation_timeout_error.rb +1 -0
- data/lib/graphql/static_validation/validator.rb +41 -16
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +1 -0
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +85 -65
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +10 -4
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +1 -0
- data/lib/graphql/subscriptions/event.rb +25 -6
- data/lib/graphql/subscriptions/serialize.rb +58 -19
- data/lib/graphql/subscriptions.rb +172 -46
- data/lib/graphql/testing/helpers.rb +17 -4
- data/lib/graphql/testing/mock_action_cable.rb +55 -33
- data/lib/graphql/testing.rb +1 -0
- data/lib/graphql/tracing/active_support_notifications_trace.rb +17 -9
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +2 -1
- data/lib/graphql/tracing/appoptics_trace.rb +2 -1
- data/lib/graphql/tracing/appoptics_tracing.rb +2 -1
- data/lib/graphql/tracing/appsignal_trace.rb +16 -7
- data/lib/graphql/tracing/appsignal_tracing.rb +7 -3
- data/lib/graphql/tracing/call_legacy_tracers.rb +1 -0
- data/lib/graphql/tracing/data_dog_trace.rb +17 -6
- data/lib/graphql/tracing/data_dog_tracing.rb +10 -3
- data/lib/graphql/tracing/detailed_trace/active_record_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/memory_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace/redis_backend.rb +1 -0
- data/lib/graphql/tracing/detailed_trace.rb +105 -42
- data/lib/graphql/tracing/legacy_hooks_trace.rb +5 -0
- data/lib/graphql/tracing/legacy_trace.rb +1 -0
- data/lib/graphql/tracing/monitor_trace.rb +17 -11
- data/lib/graphql/tracing/new_relic_trace.rb +17 -8
- data/lib/graphql/tracing/new_relic_tracing.rb +7 -3
- data/lib/graphql/tracing/notifications_trace.rb +11 -8
- data/lib/graphql/tracing/notifications_tracing.rb +23 -7
- data/lib/graphql/tracing/null_trace.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace/trace_pb.rb +1 -0
- data/lib/graphql/tracing/perfetto_trace.rb +41 -19
- data/lib/graphql/tracing/platform_trace.rb +3 -1
- data/lib/graphql/tracing/platform_tracing.rb +16 -7
- data/lib/graphql/tracing/prometheus_trace/graphql_collector.rb +1 -0
- data/lib/graphql/tracing/prometheus_trace.rb +22 -13
- data/lib/graphql/tracing/prometheus_tracing.rb +1 -0
- data/lib/graphql/tracing/scout_trace.rb +10 -4
- data/lib/graphql/tracing/scout_tracing.rb +7 -3
- data/lib/graphql/tracing/sentry_trace.rb +12 -5
- data/lib/graphql/tracing/statsd_trace.rb +12 -6
- data/lib/graphql/tracing/statsd_tracing.rb +7 -1
- data/lib/graphql/tracing/trace.rb +231 -58
- data/lib/graphql/tracing.rb +25 -9
- data/lib/graphql/type_kinds.rb +2 -1
- data/lib/graphql/types/big_int.rb +1 -0
- data/lib/graphql/types/boolean.rb +1 -0
- data/lib/graphql/types/float.rb +1 -0
- data/lib/graphql/types/id.rb +1 -0
- data/lib/graphql/types/int.rb +2 -1
- data/lib/graphql/types/iso_8601_date.rb +21 -4
- data/lib/graphql/types/iso_8601_date_time.rb +33 -6
- data/lib/graphql/types/iso_8601_duration.rb +42 -9
- data/lib/graphql/types/json.rb +1 -0
- data/lib/graphql/types/relay/base_connection.rb +38 -32
- data/lib/graphql/types/relay/base_edge.rb +15 -9
- data/lib/graphql/types/relay/connection_behaviors.rb +19 -3
- data/lib/graphql/types/relay/edge_behaviors.rb +17 -4
- data/lib/graphql/types/relay/has_node_field.rb +6 -1
- data/lib/graphql/types/relay/has_nodes_field.rb +6 -1
- data/lib/graphql/types/relay/node.rb +1 -0
- data/lib/graphql/types/relay/node_behaviors.rb +5 -1
- data/lib/graphql/types/relay/page_info.rb +1 -0
- data/lib/graphql/types/relay/page_info_behaviors.rb +1 -0
- data/lib/graphql/types/relay.rb +4 -3
- data/lib/graphql/types/string.rb +1 -0
- data/lib/graphql/types.rb +1 -0
- data/lib/graphql/unauthorized_enum_value_error.rb +4 -1
- data/lib/graphql/unauthorized_error.rb +11 -4
- data/lib/graphql/unauthorized_field_error.rb +4 -1
- data/lib/graphql/unresolved_type_error.rb +16 -5
- data/lib/graphql/version.rb +2 -1
- data/lib/graphql.rb +37 -9
- data/readme.md +1 -1
- metadata +89 -5
- data/.yardopts +0 -5
data/lib/graphql/rake_task.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require "fileutils"
|
|
3
4
|
require "rake"
|
|
4
5
|
require "graphql/rake_task/validate"
|
|
@@ -11,21 +12,32 @@ module GraphQL
|
|
|
11
12
|
#
|
|
12
13
|
# Use `load_context:` and `visible?` to dump schemas under certain visibility constraints.
|
|
13
14
|
#
|
|
14
|
-
#
|
|
15
|
-
# require "graphql/rake_task"
|
|
16
|
-
# GraphQL::RakeTask.new(schema_name: "MySchema")
|
|
15
|
+
# **Examples**
|
|
17
16
|
#
|
|
18
|
-
#
|
|
19
|
-
# # Schema IDL dumped to ./schema.graphql
|
|
20
|
-
# # Schema JSON dumped to ./schema.json
|
|
17
|
+
# **Example: Dump a Schema to .graphql + .json files**
|
|
21
18
|
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
19
|
+
# ```ruby
|
|
20
|
+
# require "graphql/rake_task"
|
|
21
|
+
# GraphQL::RakeTask.new(schema_name: "MySchema")
|
|
25
22
|
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
23
|
+
# # $ rake graphql:schema:dump
|
|
24
|
+
# # Schema IDL dumped to ./schema.graphql
|
|
25
|
+
# # Schema JSON dumped to ./schema.json
|
|
26
|
+
# ```
|
|
27
|
+
#
|
|
28
|
+
# **Example: Invoking the task from Ruby**
|
|
29
|
+
#
|
|
30
|
+
# ```ruby
|
|
31
|
+
# require "rake"
|
|
32
|
+
# Rake::Task["graphql:schema:dump"].invoke
|
|
33
|
+
# ```
|
|
34
|
+
#
|
|
35
|
+
# **Example: Providing arguments to build the introspection query**
|
|
36
|
+
#
|
|
37
|
+
# ```ruby
|
|
38
|
+
# require "graphql/rake_task"
|
|
39
|
+
# GraphQL::RakeTask.new(schema_name: "MySchema", include_is_one_of: true)
|
|
40
|
+
# ```
|
|
29
41
|
class RakeTask
|
|
30
42
|
include Rake::DSL
|
|
31
43
|
|
|
@@ -45,37 +57,57 @@ module GraphQL
|
|
|
45
57
|
include_is_one_of: false
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
#
|
|
60
|
+
# **Returns**
|
|
61
|
+
#
|
|
62
|
+
# - `String` — Namespace for generated tasks
|
|
49
63
|
attr_writer :namespace
|
|
50
64
|
|
|
51
65
|
def rake_namespace
|
|
52
66
|
@namespace
|
|
53
67
|
end
|
|
54
68
|
|
|
55
|
-
#
|
|
69
|
+
# **Returns**
|
|
70
|
+
#
|
|
71
|
+
# - `Array<String>`
|
|
56
72
|
attr_accessor :dependencies
|
|
57
73
|
|
|
58
|
-
#
|
|
59
|
-
#
|
|
74
|
+
# See [load_schema](rdoc-ref:#load_schema) for loading a schema another way
|
|
75
|
+
#
|
|
76
|
+
# **Returns**
|
|
77
|
+
#
|
|
78
|
+
# - `String` — By default, used to find the schema as a constant.
|
|
60
79
|
attr_accessor :schema_name
|
|
61
80
|
|
|
62
|
-
#
|
|
81
|
+
# **Returns**
|
|
82
|
+
#
|
|
83
|
+
# - `<#call(task)>` — A proc for loading the target GraphQL schema
|
|
63
84
|
attr_accessor :load_schema
|
|
64
85
|
|
|
65
|
-
#
|
|
86
|
+
# **Returns**
|
|
87
|
+
#
|
|
88
|
+
# - `<#call(task)>` — A callable for loading the query context
|
|
66
89
|
attr_accessor :load_context
|
|
67
90
|
|
|
68
|
-
#
|
|
91
|
+
# **Returns**
|
|
92
|
+
#
|
|
93
|
+
# - `String` — target for IDL task
|
|
69
94
|
attr_accessor :idl_outfile
|
|
70
95
|
|
|
71
|
-
#
|
|
96
|
+
# **Returns**
|
|
97
|
+
#
|
|
98
|
+
# - `String` — target for JSON task
|
|
72
99
|
attr_accessor :json_outfile
|
|
73
100
|
|
|
74
|
-
#
|
|
101
|
+
# **Returns**
|
|
102
|
+
#
|
|
103
|
+
# - `String` — directory for IDL & JSON files
|
|
75
104
|
attr_accessor :directory
|
|
76
105
|
|
|
77
|
-
#
|
|
78
|
-
#
|
|
106
|
+
# See [GraphQL::Schema.as_json](rdoc-ref:GraphQL::Schema.as_json).
|
|
107
|
+
#
|
|
108
|
+
# **Returns**
|
|
109
|
+
#
|
|
110
|
+
# - `Boolean` — Options for additional fields in the introspection query JSON response
|
|
79
111
|
attr_accessor :include_deprecated_args, :include_schema_description, :include_is_repeatable, :include_specified_by_url, :include_is_one_of
|
|
80
112
|
|
|
81
113
|
# Set the parameters of this task by passing keyword arguments
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
module GraphQL
|
|
3
4
|
module Relay
|
|
4
5
|
# This provides some isolation from `GraphQL::Relay` internals.
|
|
@@ -8,32 +9,42 @@ module GraphQL
|
|
|
8
9
|
# The connection doesn't receive outside arguments, so the list of items
|
|
9
10
|
# should be ordered and paginated before providing it here.
|
|
10
11
|
#
|
|
11
|
-
#
|
|
12
|
-
# post = Post.find(args[:post_id])
|
|
13
|
-
# comments = post.comments
|
|
14
|
-
# new_comment = comments.build(body: args[:body])
|
|
15
|
-
# new_comment.save!
|
|
12
|
+
# **Examples**
|
|
16
13
|
#
|
|
17
|
-
#
|
|
18
|
-
# parent: post,
|
|
19
|
-
# collection: comments,
|
|
20
|
-
# item: new_comment,
|
|
21
|
-
# context: context,
|
|
22
|
-
# )
|
|
14
|
+
# **Example: Adding a comment to list of comments**
|
|
23
15
|
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
16
|
+
# ```ruby
|
|
17
|
+
# post = Post.find(args[:post_id])
|
|
18
|
+
# comments = post.comments
|
|
19
|
+
# new_comment = comments.build(body: args[:body])
|
|
20
|
+
# new_comment.save!
|
|
21
|
+
#
|
|
22
|
+
# range_add = GraphQL::Relay::RangeAdd.new(
|
|
23
|
+
# parent: post,
|
|
24
|
+
# collection: comments,
|
|
25
|
+
# item: new_comment,
|
|
26
|
+
# context: context,
|
|
27
|
+
# )
|
|
28
|
+
#
|
|
29
|
+
# response = {
|
|
30
|
+
# post: post,
|
|
31
|
+
# comments_connection: range_add.connection,
|
|
32
|
+
# new_comment_edge: range_add.edge,
|
|
33
|
+
# }
|
|
34
|
+
# ```
|
|
29
35
|
class RangeAdd
|
|
30
36
|
attr_reader :edge, :connection, :parent
|
|
31
37
|
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
38
|
+
# **Parameters**
|
|
39
|
+
#
|
|
40
|
+
# - `collection` (`Object`) — The list of items to wrap in a connection
|
|
41
|
+
# - `item` (`Object`) — The newly-added item (will be wrapped in `edge_class`)
|
|
42
|
+
# - `context` (`GraphQL::Query::Context`) — The surrounding `ctx`, will be passed to the connection
|
|
43
|
+
# - `parent` (`Object`) — The owner of `collection`, will be passed to the connection if provided
|
|
44
|
+
# - `edge_class` (`Class`) — The class to wrap `item` with (defaults to the connection's edge class)
|
|
45
|
+
#
|
|
46
|
+
# :call-seq:
|
|
47
|
+
# initialize(Object collection:, Object item:, GraphQL::Query::Context context:, Object parent:, Class edge_class:)
|
|
37
48
|
def initialize(collection:, item:, context:, parent: nil, edge_class: nil)
|
|
38
49
|
conn_class = context.schema.connections.wrapper_for(collection)
|
|
39
50
|
# The rest will be added by ConnectionExtension
|
data/lib/graphql/relay.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require_relative "base_cop"
|
|
3
4
|
|
|
4
5
|
module GraphQL
|
|
@@ -11,15 +12,17 @@ module GraphQL
|
|
|
11
12
|
# to non-null fields (`null: false`) without a breaking change. (The opposite change, from `null: false`
|
|
12
13
|
# to `null: true`, change.)
|
|
13
14
|
#
|
|
14
|
-
#
|
|
15
|
-
# # Both of these define `name: String` in GraphQL:
|
|
15
|
+
# **Examples**
|
|
16
16
|
#
|
|
17
|
-
#
|
|
18
|
-
# field :name, String, null: true
|
|
17
|
+
# **Example: # Both of these define `name: String` in GraphQL:**
|
|
19
18
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
19
|
+
# ```ruby
|
|
20
|
+
# # bad
|
|
21
|
+
# field :name, String, null: true
|
|
22
22
|
#
|
|
23
|
+
# # good
|
|
24
|
+
# field :name, String
|
|
25
|
+
# ```
|
|
23
26
|
class DefaultNullTrue < BaseCop
|
|
24
27
|
MSG = "`null: true` is the default and can be removed."
|
|
25
28
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require_relative "./base_cop"
|
|
3
4
|
|
|
4
5
|
module GraphQL
|
|
@@ -11,15 +12,17 @@ module GraphQL
|
|
|
11
12
|
# to optional arguments (`required: false`) without a breaking change. (The opposite change, from `required: false`
|
|
12
13
|
# to `required: true`, change.)
|
|
13
14
|
#
|
|
14
|
-
#
|
|
15
|
-
# # Both of these define `id: ID!` in GraphQL:
|
|
15
|
+
# **Examples**
|
|
16
16
|
#
|
|
17
|
-
#
|
|
18
|
-
# argument :id, ID, required: true
|
|
17
|
+
# **Example: # Both of these define `id: ID!` in GraphQL:**
|
|
19
18
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
19
|
+
# ```ruby
|
|
20
|
+
# # bad
|
|
21
|
+
# argument :id, ID, required: true
|
|
22
22
|
#
|
|
23
|
+
# # good
|
|
24
|
+
# argument :id, ID
|
|
25
|
+
# ```
|
|
23
26
|
class DefaultRequiredTrue < BaseCop
|
|
24
27
|
MSG = "`required: true` is the default and can be removed."
|
|
25
28
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require_relative "./base_cop"
|
|
3
4
|
|
|
4
5
|
module GraphQL
|
|
@@ -7,15 +8,18 @@ module GraphQL
|
|
|
7
8
|
# Identify (and auto-correct) any field whose type configuration isn't given
|
|
8
9
|
# in the configuration block.
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
# # bad, immediately causes Rails to load `app/graphql/types/thing.rb`
|
|
12
|
-
# field :thing, Types::Thing
|
|
11
|
+
# **Examples**
|
|
13
12
|
#
|
|
14
|
-
#
|
|
15
|
-
# field :thing do
|
|
16
|
-
# type(Types::Thing)
|
|
17
|
-
# end
|
|
13
|
+
# **Example: # bad, immediately causes Rails to load `app/graphql/types/thing.rb`**
|
|
18
14
|
#
|
|
15
|
+
# ```ruby
|
|
16
|
+
# field :thing, Types::Thing
|
|
17
|
+
#
|
|
18
|
+
# # good, defers loading until the file is needed
|
|
19
|
+
# field :thing do
|
|
20
|
+
# type(Types::Thing)
|
|
21
|
+
# end
|
|
22
|
+
# ```
|
|
19
23
|
class FieldTypeInBlock < BaseCop
|
|
20
24
|
MSG = "type configuration can be moved to a block to defer loading the type's file"
|
|
21
25
|
|
|
@@ -133,7 +137,7 @@ module GraphQL
|
|
|
133
137
|
field_indent << " "
|
|
134
138
|
indent_test_idx -= 1
|
|
135
139
|
if indent_test_idx == 0
|
|
136
|
-
raise "Invariant: somehow backtracted to beginning of class when looking for field indent (source: #{
|
|
140
|
+
raise "Invariant: somehow backtracted to beginning of class when looking for field indent (source: #{type_defn_source.inspect})"
|
|
137
141
|
end
|
|
138
142
|
end
|
|
139
143
|
field_indent
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
require_relative "./base_cop"
|
|
3
4
|
|
|
4
5
|
module GraphQL
|
|
@@ -6,13 +7,16 @@ module GraphQL
|
|
|
6
7
|
module GraphQL
|
|
7
8
|
# Identify (and auto-correct) any root types in your schema file.
|
|
8
9
|
#
|
|
9
|
-
#
|
|
10
|
-
# # bad, immediately causes Rails to load `app/graphql/types/query.rb`
|
|
11
|
-
# query Types::Query
|
|
10
|
+
# **Examples**
|
|
12
11
|
#
|
|
13
|
-
#
|
|
14
|
-
# query { Types::Query }
|
|
12
|
+
# **Example: # bad, immediately causes Rails to load `app/graphql/types/query.rb`**
|
|
15
13
|
#
|
|
14
|
+
# ```ruby
|
|
15
|
+
# query Types::Query
|
|
16
|
+
#
|
|
17
|
+
# # good, defers loading until the file is needed
|
|
18
|
+
# query { Types::Query }
|
|
19
|
+
# ```
|
|
16
20
|
class RootTypesInBlock < BaseCop
|
|
17
21
|
MSG = "type configuration can be moved to a block to defer loading the type's file"
|
|
18
22
|
|
data/lib/graphql/rubocop.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
module GraphQL
|
|
4
5
|
class Schema
|
|
@@ -10,9 +11,10 @@ module GraphQL
|
|
|
10
11
|
@own_types = own_types
|
|
11
12
|
@directives = Set.new
|
|
12
13
|
@possible_types = {}
|
|
14
|
+
@possible_types_sets = {}
|
|
13
15
|
@types = {}
|
|
14
16
|
@union_memberships = {}
|
|
15
|
-
@references =
|
|
17
|
+
@references = {}.compare_by_identity
|
|
16
18
|
@arguments_with_default_values = []
|
|
17
19
|
add_type_and_traverse(new_types)
|
|
18
20
|
end
|
|
@@ -20,7 +22,8 @@ module GraphQL
|
|
|
20
22
|
private
|
|
21
23
|
|
|
22
24
|
def references_to(thing, from:)
|
|
23
|
-
@references[thing].
|
|
25
|
+
refs = @references[thing] ||= {}.compare_by_identity
|
|
26
|
+
refs[from] = true
|
|
24
27
|
end
|
|
25
28
|
|
|
26
29
|
def get_type(name)
|
|
@@ -41,19 +44,25 @@ module GraphQL
|
|
|
41
44
|
|
|
42
45
|
def add_directives_from(owner)
|
|
43
46
|
if !(dir_instances = owner.directives).empty?
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
new_dirs = nil #: Array[singleton(GraphQL::Schema::Directive)]?
|
|
48
|
+
dir_instances.each do |dir|
|
|
49
|
+
dir_class = dir.class
|
|
50
|
+
if !@directives.include?(dir_class)
|
|
51
|
+
new_dirs ||= []
|
|
52
|
+
new_dirs << dir_class
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
if new_dirs
|
|
56
|
+
@directives.merge(new_dirs)
|
|
57
|
+
add_type_and_traverse(new_dirs)
|
|
58
|
+
end
|
|
47
59
|
end
|
|
48
60
|
end
|
|
49
61
|
|
|
50
62
|
def add_type_and_traverse(new_types)
|
|
51
63
|
late_types = []
|
|
52
|
-
path = []
|
|
53
64
|
new_types.each do |t|
|
|
54
|
-
|
|
55
|
-
add_type(t, owner: nil, late_types: late_types, path: path)
|
|
56
|
-
path.pop
|
|
65
|
+
add_type(t, owner: nil, late_types: late_types)
|
|
57
66
|
end
|
|
58
67
|
missed_late_types = 0
|
|
59
68
|
while (late_type_vals = late_types.shift)
|
|
@@ -63,13 +72,13 @@ module GraphQL
|
|
|
63
72
|
# Reset the counter, since we might succeed next go-round
|
|
64
73
|
missed_late_types = 0
|
|
65
74
|
update_type_owner(type_owner, type)
|
|
66
|
-
add_type(type, owner: type_owner, late_types: late_types
|
|
75
|
+
add_type(type, owner: type_owner, late_types: late_types)
|
|
67
76
|
elsif lt.is_a?(LateBoundType)
|
|
68
77
|
if (type = get_type(lt.name))
|
|
69
78
|
# Reset the counter, since we might succeed next go-round
|
|
70
79
|
missed_late_types = 0
|
|
71
80
|
update_type_owner(type_owner, type)
|
|
72
|
-
add_type(type, owner: type_owner, late_types: late_types
|
|
81
|
+
add_type(type, owner: type_owner, late_types: late_types)
|
|
73
82
|
else
|
|
74
83
|
missed_late_types += 1
|
|
75
84
|
# Add it back to the list, maybe we'll be able to resolve it later.
|
|
@@ -88,17 +97,29 @@ module GraphQL
|
|
|
88
97
|
nil
|
|
89
98
|
end
|
|
90
99
|
|
|
100
|
+
# The Set makes this fast for interfaces with many possible types. The Array keeps their order.
|
|
101
|
+
def add_possible_type(interface_type, object_type)
|
|
102
|
+
types_set = @possible_types_sets[interface_type] ||= Set.new
|
|
103
|
+
if types_set.add?(object_type)
|
|
104
|
+
pt = @possible_types[interface_type] ||= []
|
|
105
|
+
pt << object_type
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
91
109
|
def update_type_owner(owner, type)
|
|
92
110
|
case owner
|
|
93
111
|
when Module
|
|
112
|
+
owner = owner #: as GraphQL::Schema::Member::type_definition
|
|
94
113
|
if owner.kind.union?
|
|
114
|
+
union_type = owner #: as singleton(GraphQL::Schema::Union)
|
|
95
115
|
# It's a union with possible_types
|
|
96
116
|
# Replace the item by class name
|
|
97
|
-
|
|
98
|
-
@possible_types[owner] =
|
|
117
|
+
union_type.assign_type_membership_object_type(type)
|
|
118
|
+
@possible_types[owner] = union_type.possible_types
|
|
99
119
|
elsif type.kind.interface? && (owner.kind.object? || owner.kind.interface?)
|
|
120
|
+
implementing_type = owner #: as GraphQL::Schema::Member::HasInterfaces
|
|
100
121
|
new_interfaces = []
|
|
101
|
-
|
|
122
|
+
implementing_type.interfaces.each do |int_t|
|
|
102
123
|
if int_t.is_a?(String) && int_t == type.graphql_name
|
|
103
124
|
new_interfaces << type
|
|
104
125
|
elsif int_t.is_a?(LateBoundType) && int_t.graphql_name == type.graphql_name
|
|
@@ -108,15 +129,19 @@ module GraphQL
|
|
|
108
129
|
# they were probably already added, maybe with options.
|
|
109
130
|
end
|
|
110
131
|
end
|
|
111
|
-
|
|
132
|
+
implementing_type.implements(*new_interfaces)
|
|
112
133
|
new_interfaces.each do |int|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
pt << owner
|
|
134
|
+
if owner.is_a?(Class)
|
|
135
|
+
add_possible_type(int, owner)
|
|
116
136
|
end
|
|
117
137
|
int.interfaces.each do |indirect_int|
|
|
118
|
-
if indirect_int.is_a?(LateBoundType)
|
|
119
|
-
|
|
138
|
+
if indirect_int.is_a?(LateBoundType)
|
|
139
|
+
if (indirect_int_type = get_type(indirect_int.graphql_name))
|
|
140
|
+
update_type_owner(owner, indirect_int_type)
|
|
141
|
+
end
|
|
142
|
+
elsif owner.is_a?(Class)
|
|
143
|
+
# `implements` added this one, too, because `int` implements it
|
|
144
|
+
add_possible_type(indirect_int, owner)
|
|
120
145
|
end
|
|
121
146
|
end
|
|
122
147
|
end
|
|
@@ -149,7 +174,7 @@ module GraphQL
|
|
|
149
174
|
end
|
|
150
175
|
end
|
|
151
176
|
|
|
152
|
-
def add_type(type, owner:, late_types
|
|
177
|
+
def add_type(type, owner:, late_types:)
|
|
153
178
|
if type.is_a?(String) || type.is_a?(GraphQL::Schema::LateBoundType)
|
|
154
179
|
late_types << [owner, type]
|
|
155
180
|
return
|
|
@@ -169,9 +194,7 @@ module GraphQL
|
|
|
169
194
|
if !arg_type.is_a?(GraphQL::Schema::LateBoundType)
|
|
170
195
|
references_to(arg_type, from: arg)
|
|
171
196
|
end
|
|
172
|
-
|
|
173
|
-
add_type(arg_type, owner: arg, late_types: late_types, path: path)
|
|
174
|
-
path.pop
|
|
197
|
+
add_type(arg_type, owner: arg, late_types: late_types)
|
|
175
198
|
if arg.default_value?
|
|
176
199
|
@arguments_with_default_values << arg
|
|
177
200
|
end
|
|
@@ -190,40 +213,45 @@ module GraphQL
|
|
|
190
213
|
if type.kind.fields?
|
|
191
214
|
type.all_field_definitions.each do |field|
|
|
192
215
|
field.ensure_loaded
|
|
193
|
-
name = field.graphql_name
|
|
194
216
|
field_type = field.type.unwrap
|
|
195
|
-
if
|
|
217
|
+
if field_type.is_a?(GraphQL::Schema::LateBoundType)
|
|
218
|
+
add_type(field_type, owner: field, late_types: late_types)
|
|
219
|
+
else
|
|
196
220
|
references_to(field_type, from: field)
|
|
221
|
+
if !@types[field_type.graphql_name].equal?(field_type)
|
|
222
|
+
add_type(field_type, owner: field, late_types: late_types)
|
|
223
|
+
end
|
|
197
224
|
end
|
|
198
|
-
path.push(name)
|
|
199
|
-
add_type(field_type, owner: field, late_types: late_types, path: path)
|
|
200
225
|
add_directives_from(field)
|
|
201
226
|
field.all_argument_definitions.each do |arg|
|
|
202
227
|
add_directives_from(arg)
|
|
203
228
|
arg_type = arg.type.unwrap
|
|
204
|
-
if
|
|
229
|
+
if arg_type.is_a?(GraphQL::Schema::LateBoundType)
|
|
230
|
+
add_type(arg_type, owner: arg, late_types: late_types)
|
|
231
|
+
else
|
|
205
232
|
references_to(arg_type, from: arg)
|
|
233
|
+
if !@types[arg_type.graphql_name].equal?(arg_type)
|
|
234
|
+
add_type(arg_type, owner: arg, late_types: late_types)
|
|
235
|
+
end
|
|
206
236
|
end
|
|
207
|
-
path.push(arg.graphql_name)
|
|
208
|
-
add_type(arg_type, owner: arg, late_types: late_types, path: path)
|
|
209
|
-
path.pop
|
|
210
237
|
if arg.default_value?
|
|
211
238
|
@arguments_with_default_values << arg
|
|
212
239
|
end
|
|
213
240
|
end
|
|
214
|
-
path.pop
|
|
215
241
|
end
|
|
216
242
|
end
|
|
217
243
|
if type.kind.input_object?
|
|
218
244
|
type.all_argument_definitions.each do |arg|
|
|
219
245
|
add_directives_from(arg)
|
|
220
246
|
arg_type = arg.type.unwrap
|
|
221
|
-
if
|
|
247
|
+
if arg_type.is_a?(GraphQL::Schema::LateBoundType)
|
|
248
|
+
add_type(arg_type, owner: arg, late_types: late_types)
|
|
249
|
+
else
|
|
222
250
|
references_to(arg_type, from: arg)
|
|
251
|
+
if !@types[arg_type.graphql_name].equal?(arg_type)
|
|
252
|
+
add_type(arg_type, owner: arg, late_types: late_types)
|
|
253
|
+
end
|
|
223
254
|
end
|
|
224
|
-
path.push(arg.graphql_name)
|
|
225
|
-
add_type(arg_type, owner: arg, late_types: late_types, path: path)
|
|
226
|
-
path.pop
|
|
227
255
|
if arg.default_value?
|
|
228
256
|
@arguments_with_default_values << arg
|
|
229
257
|
end
|
|
@@ -231,18 +259,14 @@ module GraphQL
|
|
|
231
259
|
end
|
|
232
260
|
if type.kind.union?
|
|
233
261
|
@possible_types[type] = type.all_possible_types
|
|
234
|
-
path.push("possible_types")
|
|
235
262
|
type.all_possible_types.each do |t|
|
|
236
|
-
add_type(t, owner: type, late_types: late_types
|
|
263
|
+
add_type(t, owner: type, late_types: late_types)
|
|
237
264
|
end
|
|
238
|
-
path.pop
|
|
239
265
|
end
|
|
240
266
|
if type.kind.interface?
|
|
241
|
-
path.push("orphan_types")
|
|
242
267
|
type.orphan_types.each do |t|
|
|
243
|
-
add_type(t, owner: type, late_types: late_types
|
|
268
|
+
add_type(t, owner: type, late_types: late_types)
|
|
244
269
|
end
|
|
245
|
-
path.pop
|
|
246
270
|
end
|
|
247
271
|
if type.kind.object?
|
|
248
272
|
possible_types_for_this_name = @possible_types[type] ||= []
|
|
@@ -250,26 +274,21 @@ module GraphQL
|
|
|
250
274
|
end
|
|
251
275
|
|
|
252
276
|
if type.kind.object? || type.kind.interface?
|
|
253
|
-
path.push("implements")
|
|
254
277
|
type.interface_type_memberships.each do |interface_type_membership|
|
|
255
278
|
case interface_type_membership
|
|
256
279
|
when Schema::TypeMembership
|
|
257
280
|
interface_type = interface_type_membership.abstract_type
|
|
258
281
|
# We can get these now; we'll have to get late-bound types later
|
|
259
282
|
if interface_type.is_a?(Module) && type.is_a?(Class)
|
|
260
|
-
|
|
261
|
-
if !implementers.include?(type)
|
|
262
|
-
implementers << type
|
|
263
|
-
end
|
|
283
|
+
add_possible_type(interface_type, type)
|
|
264
284
|
end
|
|
265
285
|
when String, Schema::LateBoundType
|
|
266
286
|
interface_type = interface_type_membership
|
|
267
287
|
else
|
|
268
288
|
raise ArgumentError, "Invariant: unexpected type membership for #{type.graphql_name}: #{interface_type_membership.class} (#{interface_type_membership.inspect})"
|
|
269
289
|
end
|
|
270
|
-
add_type(interface_type, owner: type, late_types: late_types
|
|
290
|
+
add_type(interface_type, owner: type, late_types: late_types)
|
|
271
291
|
end
|
|
272
|
-
path.pop
|
|
273
292
|
end
|
|
274
293
|
|
|
275
294
|
if type.kind.enum?
|