graphql 1.9.21 → 2.0.0
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 +44 -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 +28 -12
- 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_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 +22 -27
- 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 +29 -2
- data/lib/graphql/analysis/ast/query_complexity.rb +175 -68
- data/lib/graphql/analysis/ast/query_depth.rb +0 -1
- data/lib/graphql/analysis/ast/visitor.rb +17 -8
- data/lib/graphql/analysis/ast.rb +14 -14
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/table.rb +37 -16
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +39 -9
- data/lib/graphql/backtrace.rb +20 -17
- 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/deprecation.rb +9 -0
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/directive_checks.rb +2 -2
- data/lib/graphql/execution/errors.rb +108 -14
- data/lib/graphql/execution/instrumentation.rb +1 -1
- 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 +105 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
- data/lib/graphql/execution/interpreter/resolve.rb +37 -25
- data/lib/graphql/execution/interpreter/runtime.rb +715 -387
- data/lib/graphql/execution/interpreter.rb +32 -31
- data/lib/graphql/execution/lazy/lazy_method_map.rb +4 -0
- data/lib/graphql/execution/lazy.rb +5 -1
- data/lib/graphql/execution/lookahead.rb +32 -114
- data/lib/graphql/execution/multiplex.rb +60 -92
- data/lib/graphql/execution.rb +11 -3
- data/lib/graphql/filter.rb +1 -1
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +18 -2
- data/lib/graphql/introspection/base_object.rb +2 -5
- 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 +5 -18
- 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 +41 -11
- data/lib/graphql/introspection/introspection_query.rb +6 -92
- data/lib/graphql/introspection/schema_type.rb +10 -10
- data/lib/graphql/introspection/type_type.rb +27 -17
- data/lib/graphql/introspection.rb +99 -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/definition_slice.rb +21 -10
- data/lib/graphql/language/document_from_schema_definition.rb +99 -63
- data/lib/graphql/language/lexer.rb +53 -27
- data/lib/graphql/language/lexer.rl +5 -3
- data/lib/graphql/language/nodes.rb +64 -93
- data/lib/graphql/language/parser.rb +929 -896
- data/lib/graphql/language/parser.y +125 -102
- data/lib/graphql/language/printer.rb +11 -2
- data/lib/graphql/language/sanitized_printer.rb +222 -0
- data/lib/graphql/language/token.rb +0 -4
- data/lib/graphql/language/visitor.rb +2 -2
- data/lib/graphql/language.rb +3 -1
- data/lib/graphql/name_validator.rb +2 -7
- data/lib/graphql/pagination/active_record_relation_connection.rb +85 -0
- data/lib/graphql/pagination/array_connection.rb +77 -0
- data/lib/graphql/pagination/connection.rb +226 -0
- data/lib/graphql/pagination/connections.rb +134 -0
- data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
- data/lib/graphql/pagination/relation_connection.rb +226 -0
- data/lib/graphql/pagination/sequel_dataset_connection.rb +28 -0
- data/lib/graphql/pagination.rb +6 -0
- data/lib/graphql/parse_error.rb +0 -1
- data/lib/graphql/query/context.rb +51 -190
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +23 -6
- data/lib/graphql/query/literal_input.rb +26 -11
- data/lib/graphql/query/null_context.rb +24 -8
- data/lib/graphql/query/validation_pipeline.rb +12 -38
- data/lib/graphql/query/variable_validation_error.rb +2 -2
- data/lib/graphql/query/variables.rb +26 -9
- data/lib/graphql/query.rb +62 -32
- data/lib/graphql/railtie.rb +6 -102
- data/lib/graphql/rake_task/validate.rb +3 -0
- data/lib/graphql/rake_task.rb +12 -9
- data/lib/graphql/relay/range_add.rb +23 -9
- 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 +240 -0
- data/lib/graphql/schema/argument.rb +262 -28
- data/lib/graphql/schema/base_64_encoder.rb +2 -0
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -1
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +13 -5
- data/lib/graphql/schema/build_from_definition.rb +319 -220
- data/lib/graphql/schema/built_in_types.rb +5 -5
- data/lib/graphql/schema/directive/deprecated.rb +18 -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 +2 -2
- data/lib/graphql/schema/directive/skip.rb +2 -2
- data/lib/graphql/schema/directive/transform.rb +14 -2
- data/lib/graphql/schema/directive.rb +117 -14
- data/lib/graphql/schema/enum.rb +115 -22
- data/lib/graphql/schema/enum_value.rb +16 -21
- data/lib/graphql/schema/field/connection_extension.rb +46 -20
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +376 -291
- data/lib/graphql/schema/field_extension.rb +89 -2
- data/lib/graphql/schema/find_inherited_value.rb +17 -1
- data/lib/graphql/schema/finder.rb +16 -14
- data/lib/graphql/schema/input_object.rb +147 -60
- data/lib/graphql/schema/interface.rb +28 -43
- data/lib/graphql/schema/introspection_system.rb +101 -38
- data/lib/graphql/schema/late_bound_type.rb +3 -2
- data/lib/graphql/schema/list.rb +46 -3
- data/lib/graphql/schema/loader.rb +144 -102
- data/lib/graphql/schema/member/base_dsl_methods.rb +33 -32
- data/lib/graphql/schema/member/build_type.rb +23 -14
- data/lib/graphql/schema/member/has_arguments.rb +212 -23
- data/lib/graphql/schema/member/has_ast_node.rb +20 -0
- 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 +99 -34
- data/lib/graphql/schema/member/has_interfaces.rb +88 -0
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
- data/lib/graphql/schema/member/has_validators.rb +31 -0
- data/lib/graphql/schema/member/type_system_helpers.rb +3 -3
- data/lib/graphql/schema/member/validates_input.rb +33 -0
- data/lib/graphql/schema/member.rb +11 -6
- data/lib/graphql/schema/mutation.rb +4 -9
- data/lib/graphql/schema/non_null.rb +34 -4
- data/lib/graphql/schema/object.rb +38 -65
- data/lib/graphql/schema/printer.rb +16 -35
- data/lib/graphql/schema/relay_classic_mutation.rb +57 -32
- data/lib/graphql/schema/resolver/has_payload_type.rb +34 -4
- data/lib/graphql/schema/resolver.rb +133 -79
- data/lib/graphql/schema/scalar.rb +40 -15
- data/lib/graphql/schema/subscription.rb +57 -21
- data/lib/graphql/schema/timeout.rb +29 -15
- data/lib/graphql/schema/type_expression.rb +21 -13
- data/lib/graphql/schema/type_membership.rb +19 -5
- data/lib/graphql/schema/union.rb +39 -14
- 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 +182 -32
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +687 -891
- data/lib/graphql/static_validation/all_rules.rb +2 -0
- data/lib/graphql/static_validation/base_visitor.rb +21 -31
- 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 +51 -26
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +45 -83
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +22 -6
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +35 -26
- 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 +14 -14
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +4 -4
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +5 -5
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +94 -51
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +25 -4
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
- 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 +9 -10
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +12 -13
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +19 -14
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +5 -3
- data/lib/graphql/static_validation/type_stack.rb +2 -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 +31 -19
- 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 +123 -22
- 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 +85 -31
- data/lib/graphql/subscriptions/instrumentation.rb +0 -47
- data/lib/graphql/subscriptions/serialize.rb +53 -6
- data/lib/graphql/subscriptions.rb +111 -52
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +8 -17
- data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
- data/lib/graphql/tracing/appsignal_tracing.rb +23 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +14 -1
- data/lib/graphql/tracing/new_relic_tracing.rb +9 -12
- data/lib/graphql/tracing/notifications_tracing.rb +59 -0
- data/lib/graphql/tracing/platform_tracing.rb +57 -29
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +4 -1
- data/lib/graphql/tracing/prometheus_tracing.rb +8 -0
- data/lib/graphql/tracing/scout_tracing.rb +19 -0
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +15 -36
- 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 +16 -8
- data/lib/graphql/types/iso_8601_date_time.rb +32 -10
- data/lib/graphql/types/relay/base_connection.rb +6 -88
- data/lib/graphql/types/relay/base_edge.rb +2 -34
- data/lib/graphql/types/relay/connection_behaviors.rb +170 -0
- data/lib/graphql/types/relay/default_relay.rb +21 -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 +19 -0
- 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 -5
- data/lib/graphql/types/string.rb +8 -2
- data/lib/graphql/unauthorized_error.rb +2 -2
- data/lib/graphql/unresolved_type_error.rb +2 -2
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +41 -58
- data/readme.md +3 -6
- metadata +97 -231
- 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 -159
- data/lib/graphql/authorization.rb +0 -82
- data/lib/graphql/backwards_compatibility.rb +0 -60
- data/lib/graphql/base_type.rb +0 -226
- 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 -91
- 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 -311
- 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 -13
- data/lib/graphql/directive/include_directive.rb +0 -2
- data/lib/graphql/directive/skip_directive.rb +0 -2
- data/lib/graphql/directive.rb +0 -104
- data/lib/graphql/enum_type.rb +0 -193
- data/lib/graphql/execution/execute.rb +0 -326
- data/lib/graphql/execution/flatten.rb +0 -40
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -330
- data/lib/graphql/float_type.rb +0 -2
- data/lib/graphql/function.rb +0 -153
- data/lib/graphql/id_type.rb +0 -2
- data/lib/graphql/input_object_type.rb +0 -154
- data/lib/graphql/int_type.rb +0 -2
- data/lib/graphql/interface_type.rb +0 -86
- 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/list_type.rb +0 -80
- data/lib/graphql/literal_validation_error.rb +0 -6
- data/lib/graphql/non_null_type.rb +0 -81
- data/lib/graphql/object_type.rb +0 -141
- data/lib/graphql/query/arguments.rb +0 -187
- data/lib/graphql/query/arguments_cache.rb +0 -25
- data/lib/graphql/query/executor.rb +0 -53
- 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 -172
- 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 -40
- data/lib/graphql/relay/edge.rb +0 -27
- data/lib/graphql/relay/edge_type.rb +0 -18
- 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 -190
- 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 -133
- 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 -26
- 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 -74
- data/lib/graphql/tracing/skylight_tracing.rb +0 -62
- 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 -135
- data/lib/graphql/upgrader/member.rb +0 -936
- data/lib/graphql/upgrader/schema.rb +0 -37
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Define
|
4
|
-
# Turn argument configs into a {GraphQL::Argument}.
|
5
|
-
module AssignArgument
|
6
|
-
def self.call(target, *args, **kwargs, &block)
|
7
|
-
argument = GraphQL::Argument.from_dsl(*args, **kwargs, &block)
|
8
|
-
target.arguments[argument.name] = argument
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Define
|
4
|
-
module AssignConnection
|
5
|
-
def self.call(type_defn, *field_args, max_page_size: nil, **field_kwargs, &field_block)
|
6
|
-
underlying_field = GraphQL::Define::AssignObjectField.call(type_defn, *field_args, **field_kwargs, &field_block)
|
7
|
-
underlying_field.connection_max_page_size = max_page_size
|
8
|
-
underlying_field.connection = true
|
9
|
-
type_defn.fields[underlying_field.name] = underlying_field
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Define
|
4
|
-
# Turn enum value configs into a {GraphQL::EnumType::EnumValue} and register it with the {GraphQL::EnumType}
|
5
|
-
module AssignEnumValue
|
6
|
-
def self.call(enum_type, name, desc = nil, deprecation_reason: nil, value: name, &block)
|
7
|
-
enum_value = GraphQL::EnumType::EnumValue.define(
|
8
|
-
name: name.to_s,
|
9
|
-
description: desc,
|
10
|
-
deprecation_reason: deprecation_reason,
|
11
|
-
value: value,
|
12
|
-
&block
|
13
|
-
)
|
14
|
-
enum_type.add_value(enum_value)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Define
|
4
|
-
module AssignGlobalIdField
|
5
|
-
def self.call(type_defn, field_name)
|
6
|
-
resolve = GraphQL::Relay::GlobalIdResolve.new(type: type_defn)
|
7
|
-
GraphQL::Define::AssignObjectField.call(type_defn, field_name, type: GraphQL::ID_TYPE.to_non_null_type, resolve: resolve)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Define
|
4
|
-
module AssignMutationFunction
|
5
|
-
def self.call(target, function)
|
6
|
-
# TODO: get all this logic somewhere easier to test
|
7
|
-
|
8
|
-
if !function.type.is_a?(GraphQL::ObjectType)
|
9
|
-
raise "Mutation functions must return object types (not #{function.type.unwrap})"
|
10
|
-
end
|
11
|
-
|
12
|
-
target.return_type = function.type.redefine {
|
13
|
-
name(target.name + "Payload")
|
14
|
-
field :clientMutationId, types.String, "A unique identifier for the client performing the mutation.", property: :client_mutation_id
|
15
|
-
}
|
16
|
-
|
17
|
-
target.arguments = function.arguments
|
18
|
-
target.description = function.description
|
19
|
-
target.resolve = ->(o, a, c) {
|
20
|
-
res = function.call(o, a, c)
|
21
|
-
ResultProxy.new(res, a[:clientMutationId])
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
class ResultProxy < SimpleDelegator
|
26
|
-
attr_reader :client_mutation_id
|
27
|
-
def initialize(target, client_mutation_id)
|
28
|
-
@client_mutation_id = client_mutation_id
|
29
|
-
super(target)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Define
|
4
|
-
# Turn field configs into a {GraphQL::Field} and attach it to a {GraphQL::ObjectType} or {GraphQL::InterfaceType}
|
5
|
-
module AssignObjectField
|
6
|
-
def self.call(owner_type, name, type_or_field = nil, desc = nil, function: nil, field: nil, relay_mutation_function: nil, **kwargs, &block)
|
7
|
-
name_s = name.to_s
|
8
|
-
|
9
|
-
# Move some positional args into keywords if they're present
|
10
|
-
desc && kwargs[:description] ||= desc
|
11
|
-
name && kwargs[:name] ||= name_s
|
12
|
-
|
13
|
-
if !type_or_field.nil? && !type_or_field.is_a?(GraphQL::Field)
|
14
|
-
# Maybe a string, proc or BaseType
|
15
|
-
kwargs[:type] = type_or_field
|
16
|
-
end
|
17
|
-
|
18
|
-
base_field = if type_or_field.is_a?(GraphQL::Field)
|
19
|
-
type_or_field.redefine(name: name_s)
|
20
|
-
elsif function
|
21
|
-
func_field = GraphQL::Function.build_field(function)
|
22
|
-
func_field.name = name_s
|
23
|
-
func_field
|
24
|
-
elsif field.is_a?(GraphQL::Field)
|
25
|
-
field.redefine(name: name_s)
|
26
|
-
else
|
27
|
-
nil
|
28
|
-
end
|
29
|
-
|
30
|
-
obj_field = if base_field
|
31
|
-
base_field.redefine(**kwargs, &block)
|
32
|
-
else
|
33
|
-
GraphQL::Field.define(**kwargs, &block)
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
# Attach the field to the type
|
38
|
-
owner_type.fields[name_s] = obj_field
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphQL
|
4
|
-
module Define
|
5
|
-
# This object delegates most methods to a dictionary of functions, {@dictionary}.
|
6
|
-
# {@target} is passed to the specified function, along with any arguments and block.
|
7
|
-
# This allows a method-based DSL without adding methods to the defined class.
|
8
|
-
class DefinedObjectProxy
|
9
|
-
extend GraphQL::Ruby2Keywords
|
10
|
-
# The object which will be defined by definition functions
|
11
|
-
attr_reader :target
|
12
|
-
|
13
|
-
def initialize(target)
|
14
|
-
@target = target
|
15
|
-
@dictionary = target.class.dictionary
|
16
|
-
end
|
17
|
-
|
18
|
-
# Provides shorthand access to GraphQL's built-in types
|
19
|
-
def types
|
20
|
-
GraphQL::Define::TypeDefiner.instance
|
21
|
-
end
|
22
|
-
|
23
|
-
# Allow `plugin` to perform complex initialization on the definition.
|
24
|
-
# Calls `plugin.use(defn, **kwargs)`.
|
25
|
-
# @param plugin [<#use(defn, **kwargs)>] A plugin object
|
26
|
-
# @param kwargs [Hash] Any options for the plugin
|
27
|
-
def use(plugin, **kwargs)
|
28
|
-
# https://bugs.ruby-lang.org/issues/10708
|
29
|
-
if kwargs == {}
|
30
|
-
plugin.use(self)
|
31
|
-
else
|
32
|
-
plugin.use(self, **kwargs)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Lookup a function from the dictionary and call it if it's found.
|
37
|
-
ruby2_keywords
|
38
|
-
def method_missing(name, *args, &block)
|
39
|
-
definition = @dictionary[name]
|
40
|
-
if definition
|
41
|
-
definition.call(@target, *args, &block)
|
42
|
-
else
|
43
|
-
msg = "#{@target.class.name} can't define '#{name}'"
|
44
|
-
raise NoDefinitionError, msg, caller
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def respond_to_missing?(name, include_private = false)
|
49
|
-
@dictionary[name] || super
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,311 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Define
|
4
|
-
# This module provides the `.define { ... }` API for
|
5
|
-
# {GraphQL::BaseType}, {GraphQL::Field} and others.
|
6
|
-
#
|
7
|
-
# Calling `.accepts_definitions(...)` creates:
|
8
|
-
#
|
9
|
-
# - a keyword to the `.define` method
|
10
|
-
# - a helper method in the `.define { ... }` block
|
11
|
-
#
|
12
|
-
# The `.define { ... }` block will be called lazily. To be sure it has been
|
13
|
-
# called, use the private method `#ensure_defined`. That will call the
|
14
|
-
# definition block if it hasn't been called already.
|
15
|
-
#
|
16
|
-
# The goals are:
|
17
|
-
#
|
18
|
-
# - Minimal overhead in consuming classes
|
19
|
-
# - Independence between consuming classes
|
20
|
-
# - Extendable by third-party libraries without monkey-patching or other nastiness
|
21
|
-
#
|
22
|
-
# @example Make a class definable
|
23
|
-
# class Car
|
24
|
-
# include GraphQL::Define::InstanceDefinable
|
25
|
-
# attr_accessor :make, :model, :doors
|
26
|
-
# accepts_definitions(
|
27
|
-
# # These attrs will be defined with plain setters, `{attr}=`
|
28
|
-
# :make, :model,
|
29
|
-
# # This attr has a custom definition which applies the config to the target
|
30
|
-
# doors: ->(car, doors_count) { doors_count.times { car.doors << Door.new } }
|
31
|
-
# )
|
32
|
-
# ensure_defined(:make, :model, :doors)
|
33
|
-
#
|
34
|
-
# def initialize
|
35
|
-
# @doors = []
|
36
|
-
# end
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# class Door; end;
|
40
|
-
#
|
41
|
-
# # Create an instance with `.define`:
|
42
|
-
# subaru_baja = Car.define do
|
43
|
-
# make "Subaru"
|
44
|
-
# model "Baja"
|
45
|
-
# doors 4
|
46
|
-
# end
|
47
|
-
#
|
48
|
-
# # The custom proc was applied:
|
49
|
-
# subaru_baja.doors #=> [<Door>, <Door>, <Door>, <Door>]
|
50
|
-
#
|
51
|
-
# @example Extending the definition of a class
|
52
|
-
# # Add some definitions:
|
53
|
-
# Car.accepts_definitions(all_wheel_drive: GraphQL::Define.assign_metadata_key(:all_wheel_drive))
|
54
|
-
#
|
55
|
-
# # Use it in a definition
|
56
|
-
# subaru_baja = Car.define do
|
57
|
-
# # ...
|
58
|
-
# all_wheel_drive true
|
59
|
-
# end
|
60
|
-
#
|
61
|
-
# # Access it from metadata
|
62
|
-
# subaru_baja.metadata[:all_wheel_drive] # => true
|
63
|
-
#
|
64
|
-
# @example Extending the definition of a class via a plugin
|
65
|
-
# # A plugin is any object that responds to `.use(definition)`
|
66
|
-
# module SubaruCar
|
67
|
-
# extend self
|
68
|
-
#
|
69
|
-
# def use(defn)
|
70
|
-
# # `defn` has the same methods as within `.define { ... }` block
|
71
|
-
# defn.make "Subaru"
|
72
|
-
# defn.doors 4
|
73
|
-
# end
|
74
|
-
# end
|
75
|
-
#
|
76
|
-
# # Use the plugin within a `.define { ... }` block
|
77
|
-
# subaru_baja = Car.define do
|
78
|
-
# use SubaruCar
|
79
|
-
# model 'Baja'
|
80
|
-
# end
|
81
|
-
#
|
82
|
-
# subaru_baja.make # => "Subaru"
|
83
|
-
# subaru_baja.doors # => [<Door>, <Door>, <Door>, <Door>]
|
84
|
-
#
|
85
|
-
# @example Making a copy with an extended definition
|
86
|
-
# # Create an instance with `.define`:
|
87
|
-
# subaru_baja = Car.define do
|
88
|
-
# make "Subaru"
|
89
|
-
# model "Baja"
|
90
|
-
# doors 4
|
91
|
-
# end
|
92
|
-
#
|
93
|
-
# # Then extend it with `#redefine`
|
94
|
-
# two_door_baja = subaru_baja.redefine do
|
95
|
-
# doors 2
|
96
|
-
# end
|
97
|
-
module InstanceDefinable
|
98
|
-
def self.included(base)
|
99
|
-
base.extend(ClassMethods)
|
100
|
-
base.ensure_defined(:metadata)
|
101
|
-
end
|
102
|
-
|
103
|
-
# `metadata` can store arbitrary key-values with an object.
|
104
|
-
#
|
105
|
-
# @return [Hash<Object, Object>] Hash for user-defined storage
|
106
|
-
def metadata
|
107
|
-
@metadata ||= {}
|
108
|
-
end
|
109
|
-
|
110
|
-
# Mutate this instance using functions from its {.definition}s.
|
111
|
-
# Keywords or helpers in the block correspond to keys given to `accepts_definitions`.
|
112
|
-
#
|
113
|
-
# Note that the block is not called right away -- instead, it's deferred until
|
114
|
-
# one of the defined fields is needed.
|
115
|
-
# @return [void]
|
116
|
-
def define(**kwargs, &block)
|
117
|
-
# make sure the previous definition_proc was executed:
|
118
|
-
ensure_defined
|
119
|
-
stash_dependent_methods
|
120
|
-
@pending_definition = Definition.new(kwargs, block)
|
121
|
-
nil
|
122
|
-
end
|
123
|
-
|
124
|
-
# Shallow-copy this object, then apply new definitions to the copy.
|
125
|
-
# @see {#define} for arguments
|
126
|
-
# @return [InstanceDefinable] A new instance, with any extended definitions
|
127
|
-
def redefine(**kwargs, &block)
|
128
|
-
ensure_defined
|
129
|
-
new_inst = self.dup
|
130
|
-
new_inst.define(**kwargs, &block)
|
131
|
-
new_inst
|
132
|
-
end
|
133
|
-
|
134
|
-
def initialize_copy(other)
|
135
|
-
super
|
136
|
-
@metadata = other.metadata.dup
|
137
|
-
end
|
138
|
-
|
139
|
-
private
|
140
|
-
|
141
|
-
# Run the definition block if it hasn't been run yet.
|
142
|
-
# This can only be run once: the block is deleted after it's used.
|
143
|
-
# You have to call this before using any value which could
|
144
|
-
# come from the definition block.
|
145
|
-
# @return [void]
|
146
|
-
def ensure_defined
|
147
|
-
if @pending_definition
|
148
|
-
defn = @pending_definition
|
149
|
-
@pending_definition = nil
|
150
|
-
|
151
|
-
revive_dependent_methods
|
152
|
-
|
153
|
-
begin
|
154
|
-
defn_proxy = DefinedObjectProxy.new(self)
|
155
|
-
# Apply definition from `define(...)` kwargs
|
156
|
-
defn.define_keywords.each do |keyword, value|
|
157
|
-
# Don't splat string hashes, which blows up on Rubies before 2.7
|
158
|
-
if value.is_a?(Hash) && !value.empty? && value.each_key.all? { |k| k.is_a?(Symbol) }
|
159
|
-
defn_proxy.public_send(keyword, **value)
|
160
|
-
else
|
161
|
-
defn_proxy.public_send(keyword, value)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
# and/or apply definition from `define { ... }` block
|
165
|
-
if defn.define_proc
|
166
|
-
defn_proxy.instance_eval(&defn.define_proc)
|
167
|
-
end
|
168
|
-
rescue StandardError
|
169
|
-
# The definition block failed to run, so make this object pending again:
|
170
|
-
stash_dependent_methods
|
171
|
-
@pending_definition = defn
|
172
|
-
raise
|
173
|
-
end
|
174
|
-
end
|
175
|
-
nil
|
176
|
-
end
|
177
|
-
|
178
|
-
# Take the pending methods and put them back on this object's singleton class.
|
179
|
-
# This reverts the process done by {#stash_dependent_methods}
|
180
|
-
# @return [void]
|
181
|
-
def revive_dependent_methods
|
182
|
-
pending_methods = @pending_methods
|
183
|
-
self.singleton_class.class_eval {
|
184
|
-
pending_methods.each do |method|
|
185
|
-
undef_method(method.name) if method_defined?(method.name)
|
186
|
-
define_method(method.name, method)
|
187
|
-
end
|
188
|
-
}
|
189
|
-
@pending_methods = nil
|
190
|
-
end
|
191
|
-
|
192
|
-
# Find the method names which were declared as definition-dependent,
|
193
|
-
# then grab the method definitions off of this object's class
|
194
|
-
# and store them for later.
|
195
|
-
#
|
196
|
-
# Then make a dummy method for each of those method names which:
|
197
|
-
#
|
198
|
-
# - Triggers the pending definition, if there is one
|
199
|
-
# - Calls the same method again.
|
200
|
-
#
|
201
|
-
# It's assumed that {#ensure_defined} will put the original method definitions
|
202
|
-
# back in place with {#revive_dependent_methods}.
|
203
|
-
# @return [void]
|
204
|
-
def stash_dependent_methods
|
205
|
-
method_names = self.class.ensure_defined_method_names
|
206
|
-
@pending_methods = method_names.map { |n| self.class.instance_method(n) }
|
207
|
-
self.singleton_class.class_eval do
|
208
|
-
method_names.each do |method_name|
|
209
|
-
undef_method(method_name) if method_defined?(method_name)
|
210
|
-
define_method(method_name) { |*args, &block|
|
211
|
-
ensure_defined
|
212
|
-
self.send(method_name, *args, &block)
|
213
|
-
}
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
class Definition
|
219
|
-
attr_reader :define_keywords, :define_proc
|
220
|
-
def initialize(define_keywords, define_proc)
|
221
|
-
@define_keywords = define_keywords
|
222
|
-
@define_proc = define_proc
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
module ClassMethods
|
227
|
-
# Create a new instance
|
228
|
-
# and prepare a definition using its {.definitions}.
|
229
|
-
# @param kwargs [Hash] Key-value pairs corresponding to defininitions from `accepts_definitions`
|
230
|
-
# @param block [Proc] Block which calls helper methods from `accepts_definitions`
|
231
|
-
def define(**kwargs, &block)
|
232
|
-
instance = self.new
|
233
|
-
instance.define(**kwargs, &block)
|
234
|
-
instance
|
235
|
-
end
|
236
|
-
|
237
|
-
# Attach definitions to this class.
|
238
|
-
# Each symbol in `accepts` will be assigned with `{key}=`.
|
239
|
-
# The last entry in accepts may be a hash of name-proc pairs for custom definitions.
|
240
|
-
def accepts_definitions(*accepts)
|
241
|
-
new_assignments = if accepts.last.is_a?(Hash)
|
242
|
-
accepts.pop.dup
|
243
|
-
else
|
244
|
-
{}
|
245
|
-
end
|
246
|
-
|
247
|
-
accepts.each do |key|
|
248
|
-
new_assignments[key] = AssignAttribute.new(key)
|
249
|
-
end
|
250
|
-
|
251
|
-
@own_dictionary = own_dictionary.merge(new_assignments)
|
252
|
-
end
|
253
|
-
|
254
|
-
def ensure_defined(*method_names)
|
255
|
-
@ensure_defined_method_names ||= []
|
256
|
-
@ensure_defined_method_names.concat(method_names)
|
257
|
-
nil
|
258
|
-
end
|
259
|
-
|
260
|
-
def ensure_defined_method_names
|
261
|
-
own_method_names = @ensure_defined_method_names || []
|
262
|
-
if superclass.respond_to?(:ensure_defined_method_names)
|
263
|
-
superclass.ensure_defined_method_names + own_method_names
|
264
|
-
else
|
265
|
-
own_method_names
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
# @return [Hash] combined definitions for self and ancestors
|
270
|
-
def dictionary
|
271
|
-
if superclass.respond_to?(:dictionary)
|
272
|
-
own_dictionary.merge(superclass.dictionary)
|
273
|
-
else
|
274
|
-
own_dictionary
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
# @return [Hash] definitions for this class only
|
279
|
-
def own_dictionary
|
280
|
-
@own_dictionary ||= {}
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
class AssignMetadataKey
|
285
|
-
def initialize(key)
|
286
|
-
@key = key
|
287
|
-
end
|
288
|
-
|
289
|
-
def call(defn, value = true)
|
290
|
-
defn.metadata[@key] = value
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
class AssignAttribute
|
295
|
-
extend GraphQL::Ruby2Keywords
|
296
|
-
|
297
|
-
def initialize(attr_name)
|
298
|
-
@attr_assign_method = :"#{attr_name}="
|
299
|
-
end
|
300
|
-
|
301
|
-
# Even though we're just using the first value here,
|
302
|
-
# We have to add a splat here to use `ruby2_keywords`,
|
303
|
-
# so that it will accept a `[{}]` input from the caller.
|
304
|
-
ruby2_keywords
|
305
|
-
def call(defn, *value)
|
306
|
-
defn.public_send(@attr_assign_method, value.first)
|
307
|
-
end
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|
311
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Define
|
4
|
-
# Wrap the object in NonNullType in response to `!`
|
5
|
-
# @example required Int type
|
6
|
-
# !GraphQL::INT_TYPE
|
7
|
-
#
|
8
|
-
module NonNullWithBang
|
9
|
-
# Make the type non-null
|
10
|
-
# @return [GraphQL::NonNullType] a non-null type which wraps the original type
|
11
|
-
def !
|
12
|
-
to_non_null_type
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Define
|
4
|
-
# Some conveniences for definining return & argument types.
|
5
|
-
#
|
6
|
-
# Passed into initialization blocks, eg {ObjectType#initialize}, {Field#initialize}
|
7
|
-
class TypeDefiner
|
8
|
-
include Singleton
|
9
|
-
# rubocop:disable Naming/MethodName
|
10
|
-
def Int; GraphQL::INT_TYPE; end
|
11
|
-
def String; GraphQL::STRING_TYPE; end
|
12
|
-
def Float; GraphQL::FLOAT_TYPE; end
|
13
|
-
def Boolean; GraphQL::BOOLEAN_TYPE; end
|
14
|
-
def ID; GraphQL::ID_TYPE; end
|
15
|
-
# rubocop:enable Naming/MethodName
|
16
|
-
|
17
|
-
# Make a {ListType} which wraps the input type
|
18
|
-
#
|
19
|
-
# @example making a list type
|
20
|
-
# list_of_strings = types[types.String]
|
21
|
-
# list_of_strings.inspect
|
22
|
-
# # => "[String]"
|
23
|
-
#
|
24
|
-
# @param type [Type] A type to be wrapped in a ListType
|
25
|
-
# @return [GraphQL::ListType] A ListType wrapping `type`
|
26
|
-
def [](type)
|
27
|
-
type.to_list_type
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/graphql/define.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "graphql/define/assign_argument"
|
3
|
-
require "graphql/define/assign_connection"
|
4
|
-
require "graphql/define/assign_enum_value"
|
5
|
-
require "graphql/define/assign_global_id_field"
|
6
|
-
require "graphql/define/assign_mutation_function"
|
7
|
-
require "graphql/define/assign_object_field"
|
8
|
-
require "graphql/define/defined_object_proxy"
|
9
|
-
require "graphql/define/instance_definable"
|
10
|
-
require "graphql/define/no_definition_error"
|
11
|
-
require "graphql/define/non_null_with_bang"
|
12
|
-
require "graphql/define/type_definer"
|
13
|
-
|
14
|
-
module GraphQL
|
15
|
-
module Define
|
16
|
-
# A helper for definitions that store their value in `#metadata`.
|
17
|
-
#
|
18
|
-
# @example Storing application classes with GraphQL types
|
19
|
-
# # Make a custom definition
|
20
|
-
# GraphQL::ObjectType.accepts_definitions(resolves_to_class_names: GraphQL::Define.assign_metadata_key(:resolves_to_class_names))
|
21
|
-
#
|
22
|
-
# # After definition, read the key from metadata
|
23
|
-
# PostType.metadata[:resolves_to_class_names] # => [...]
|
24
|
-
#
|
25
|
-
# @param key [Object] the key to assign in metadata
|
26
|
-
# @return [#call(defn, value)] an assignment for `.accepts_definitions` which writes `key` to `#metadata`
|
27
|
-
def self.assign_metadata_key(key)
|
28
|
-
GraphQL::Define::InstanceDefinable::AssignMetadataKey.new(key)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
# There are two ways to apply the deprecated `!` DSL to class-style schema definitions:
|
4
|
-
#
|
5
|
-
# 1. Scoped by file (CRuby only), add to the top of the file:
|
6
|
-
#
|
7
|
-
# using GraphQL::DeprecatedDSL
|
8
|
-
#
|
9
|
-
# (This is a "refinement", there are also other ways to scope it.)
|
10
|
-
#
|
11
|
-
# 2. Global application, add before schema definition:
|
12
|
-
#
|
13
|
-
# GraphQL::DeprecatedDSL.activate
|
14
|
-
#
|
15
|
-
module DeprecatedDSL
|
16
|
-
TYPE_CLASSES = [
|
17
|
-
GraphQL::Schema::Scalar,
|
18
|
-
GraphQL::Schema::Enum,
|
19
|
-
GraphQL::Schema::InputObject,
|
20
|
-
GraphQL::Schema::Union,
|
21
|
-
GraphQL::Schema::Interface,
|
22
|
-
GraphQL::Schema::Object,
|
23
|
-
]
|
24
|
-
|
25
|
-
def self.activate
|
26
|
-
TYPE_CLASSES.each { |c| c.extend(Methods) }
|
27
|
-
GraphQL::Schema::List.include(Methods)
|
28
|
-
GraphQL::Schema::NonNull.include(Methods)
|
29
|
-
end
|
30
|
-
module Methods
|
31
|
-
def !
|
32
|
-
to_non_null_type
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
TYPE_CLASSES.each do |type_class|
|
37
|
-
refine type_class.singleton_class do
|
38
|
-
include Methods
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
GraphQL::Directive::DeprecatedDirective = GraphQL::Directive.define do
|
3
|
-
name "deprecated"
|
4
|
-
description "Marks an element of a GraphQL schema as no longer supported."
|
5
|
-
locations([GraphQL::Directive::FIELD_DEFINITION, GraphQL::Directive::ENUM_VALUE])
|
6
|
-
|
7
|
-
reason_description = "Explains why this element was deprecated, usually also including a "\
|
8
|
-
"suggestion for how to access supported similar data. Formatted "\
|
9
|
-
"in [Markdown](https://daringfireball.net/projects/markdown/)."
|
10
|
-
|
11
|
-
argument :reason, GraphQL::STRING_TYPE, reason_description, default_value: GraphQL::Directive::DEFAULT_DEPRECATION_REASON
|
12
|
-
default_directive true
|
13
|
-
end
|