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,55 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# test_via: ../execution/execute.rb
|
3
|
-
# test_via: ../execution/lazy.rb
|
4
2
|
module GraphQL
|
5
3
|
class Query
|
6
4
|
# Expose some query-specific info to field resolve functions.
|
7
5
|
# It delegates `[]` to the hash that's passed to `GraphQL::Query#initialize`.
|
8
6
|
class Context
|
9
7
|
module SharedMethods
|
10
|
-
# @return [Object] The target for field resolution
|
11
|
-
attr_accessor :object
|
12
|
-
|
13
|
-
# @return [Hash, Array, String, Integer, Float, Boolean, nil] The resolved value for this field
|
14
|
-
attr_reader :value
|
15
|
-
|
16
|
-
# @return [Boolean] were any fields of this selection skipped?
|
17
|
-
attr_reader :skipped
|
18
|
-
alias :skipped? :skipped
|
19
|
-
|
20
|
-
# @api private
|
21
|
-
attr_writer :skipped
|
22
|
-
|
23
8
|
# Return this value to tell the runtime
|
24
9
|
# to exclude this field from the response altogether
|
25
10
|
def skip
|
26
|
-
GraphQL::Execution::
|
27
|
-
end
|
28
|
-
|
29
|
-
# @return [Boolean] True if this selection has been nullified by a null child
|
30
|
-
def invalid_null?
|
31
|
-
@invalid_null
|
32
|
-
end
|
33
|
-
|
34
|
-
# Remove this child from the result value
|
35
|
-
# (used for null propagation and skip)
|
36
|
-
# @api private
|
37
|
-
def delete(child_ctx)
|
38
|
-
@value.delete(child_ctx.key)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Create a child context to use for `key`
|
42
|
-
# @param key [String, Integer] The key in the response (name or index)
|
43
|
-
# @param irep_node [InternalRepresentation::Node] The node being evaluated
|
44
|
-
# @api private
|
45
|
-
def spawn_child(key:, irep_node:, object:)
|
46
|
-
FieldResolutionContext.new(
|
47
|
-
@context,
|
48
|
-
key,
|
49
|
-
irep_node,
|
50
|
-
self,
|
51
|
-
object
|
52
|
-
)
|
11
|
+
GraphQL::Execution::SKIP
|
53
12
|
end
|
54
13
|
|
55
14
|
# Add error at query-level.
|
@@ -74,12 +33,6 @@ module GraphQL
|
|
74
33
|
def execution_errors
|
75
34
|
@execution_errors ||= ExecutionErrors.new(self)
|
76
35
|
end
|
77
|
-
|
78
|
-
def lookahead
|
79
|
-
ast_nodes = irep_node.ast_nodes
|
80
|
-
field = irep_node.definition.metadata[:type_class] || raise("Lookahead is only compatible with class-based schemas")
|
81
|
-
Execution::Lookahead.new(query: query, ast_nodes: ast_nodes, field: field)
|
82
|
-
end
|
83
36
|
end
|
84
37
|
|
85
38
|
class ExecutionErrors
|
@@ -107,27 +60,6 @@ module GraphQL
|
|
107
60
|
include SharedMethods
|
108
61
|
extend Forwardable
|
109
62
|
|
110
|
-
attr_reader :execution_strategy
|
111
|
-
# `strategy` is required by GraphQL::Batch
|
112
|
-
alias_method :strategy, :execution_strategy
|
113
|
-
|
114
|
-
def execution_strategy=(new_strategy)
|
115
|
-
# GraphQL::Batch re-assigns this value but it was previously not used
|
116
|
-
# (ExecutionContext#strategy was used instead)
|
117
|
-
# now it _is_ used, but it breaks GraphQL::Batch tests
|
118
|
-
@execution_strategy ||= new_strategy
|
119
|
-
end
|
120
|
-
|
121
|
-
# @return [GraphQL::InternalRepresentation::Node] The internal representation for this query node
|
122
|
-
def irep_node
|
123
|
-
@irep_node ||= query.irep_selection
|
124
|
-
end
|
125
|
-
|
126
|
-
# @return [GraphQL::Language::Nodes::Field] The AST node for the currently-executing field
|
127
|
-
def ast_node
|
128
|
-
@irep_node.ast_node
|
129
|
-
end
|
130
|
-
|
131
63
|
# @return [Array<GraphQL::ExecutionError>] errors returned during execution
|
132
64
|
attr_reader :errors
|
133
65
|
|
@@ -158,6 +90,15 @@ module GraphQL
|
|
158
90
|
@scoped_context = {}
|
159
91
|
end
|
160
92
|
|
93
|
+
# @return [Hash] A hash that will be added verbatim to the result hash, as `"extensions" => { ... }`
|
94
|
+
def response_extensions
|
95
|
+
namespace(:__query_result_extensions__)
|
96
|
+
end
|
97
|
+
|
98
|
+
def dataloader
|
99
|
+
@dataloader ||= self[:dataloader] || (query.multiplex ? query.multiplex.dataloader : schema.dataloader_class.new)
|
100
|
+
end
|
101
|
+
|
161
102
|
# @api private
|
162
103
|
attr_writer :interpreter
|
163
104
|
|
@@ -167,8 +108,10 @@ module GraphQL
|
|
167
108
|
# @api private
|
168
109
|
attr_accessor :scoped_context
|
169
110
|
|
170
|
-
|
171
|
-
|
111
|
+
def []=(key, value)
|
112
|
+
@provided_values[key] = value
|
113
|
+
end
|
114
|
+
|
172
115
|
def_delegators :@query, :trace, :interpreter?
|
173
116
|
|
174
117
|
# @!method []=(key, value)
|
@@ -180,6 +123,34 @@ module GraphQL
|
|
180
123
|
@provided_values[key]
|
181
124
|
end
|
182
125
|
|
126
|
+
def delete(key)
|
127
|
+
if @scoped_context.key?(key)
|
128
|
+
@scoped_context.delete(key)
|
129
|
+
else
|
130
|
+
@provided_values.delete(key)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
UNSPECIFIED_FETCH_DEFAULT = Object.new
|
135
|
+
|
136
|
+
def fetch(key, default = UNSPECIFIED_FETCH_DEFAULT)
|
137
|
+
if @scoped_context.key?(key)
|
138
|
+
@scoped_context[key]
|
139
|
+
elsif @provided_values.key?(key)
|
140
|
+
@provided_values[key]
|
141
|
+
elsif default != UNSPECIFIED_FETCH_DEFAULT
|
142
|
+
default
|
143
|
+
elsif block_given?
|
144
|
+
yield(self, key)
|
145
|
+
else
|
146
|
+
raise KeyError.new(key: key)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def dig(key, *other_keys)
|
151
|
+
@scoped_context.key?(key) ? @scoped_context.dig(key, *other_keys) : @provided_values.dig(key, *other_keys)
|
152
|
+
end
|
153
|
+
|
183
154
|
def to_h
|
184
155
|
@provided_values.merge(@scoped_context)
|
185
156
|
end
|
@@ -191,9 +162,12 @@ module GraphQL
|
|
191
162
|
|
192
163
|
# @return [GraphQL::Schema::Warden]
|
193
164
|
def warden
|
194
|
-
@warden ||= @query.warden
|
165
|
+
@warden ||= (@query && @query.warden)
|
195
166
|
end
|
196
167
|
|
168
|
+
# @api private
|
169
|
+
attr_writer :warden
|
170
|
+
|
197
171
|
# Get an isolated hash for `ns`. Doesn't affect user-provided storage.
|
198
172
|
# @param ns [Object] a usage-specific namespace identifier
|
199
173
|
# @return [Hash] namespaced storage
|
@@ -201,14 +175,13 @@ module GraphQL
|
|
201
175
|
@storage[ns]
|
202
176
|
end
|
203
177
|
|
204
|
-
|
205
|
-
|
178
|
+
# @return [Boolean] true if this namespace was accessed before
|
179
|
+
def namespace?(ns)
|
180
|
+
@storage.key?(ns)
|
206
181
|
end
|
207
182
|
|
208
|
-
|
209
|
-
|
210
|
-
@invalid_null = true
|
211
|
-
@value = nil
|
183
|
+
def inspect
|
184
|
+
"#<Query::Context ...>"
|
212
185
|
end
|
213
186
|
|
214
187
|
def scoped_merge!(hash)
|
@@ -219,118 +192,6 @@ module GraphQL
|
|
219
192
|
scoped_merge!(key => value)
|
220
193
|
nil
|
221
194
|
end
|
222
|
-
|
223
|
-
class FieldResolutionContext
|
224
|
-
include SharedMethods
|
225
|
-
include Tracing::Traceable
|
226
|
-
extend Forwardable
|
227
|
-
|
228
|
-
attr_reader :irep_node, :field, :parent_type, :query, :schema, :parent, :key, :type
|
229
|
-
alias :selection :irep_node
|
230
|
-
|
231
|
-
def initialize(context, key, irep_node, parent, object)
|
232
|
-
@context = context
|
233
|
-
@key = key
|
234
|
-
@parent = parent
|
235
|
-
@object = object
|
236
|
-
@irep_node = irep_node
|
237
|
-
@field = irep_node.definition
|
238
|
-
@parent_type = irep_node.owner_type
|
239
|
-
@type = field.type
|
240
|
-
# This is needed constantly, so set it ahead of time:
|
241
|
-
@query = context.query
|
242
|
-
@schema = context.schema
|
243
|
-
@tracers = @query.tracers
|
244
|
-
# This hack flag is required by ConnectionResolve
|
245
|
-
@wrapped_connection = false
|
246
|
-
@wrapped_object = false
|
247
|
-
end
|
248
|
-
|
249
|
-
# @api private
|
250
|
-
attr_accessor :wrapped_connection, :wrapped_object
|
251
|
-
|
252
|
-
def path
|
253
|
-
@path ||= @parent.path.dup << @key
|
254
|
-
end
|
255
|
-
|
256
|
-
def_delegators :@context,
|
257
|
-
:[], :[]=, :key?, :fetch, :to_h, :namespace, :dig,
|
258
|
-
:spawn, :warden, :errors,
|
259
|
-
:execution_strategy, :strategy, :interpreter?
|
260
|
-
|
261
|
-
# @return [GraphQL::Language::Nodes::Field] The AST node for the currently-executing field
|
262
|
-
def ast_node
|
263
|
-
@irep_node.ast_node
|
264
|
-
end
|
265
|
-
|
266
|
-
# Add error to current field resolution.
|
267
|
-
# @param error [GraphQL::ExecutionError] an execution error
|
268
|
-
# @return [void]
|
269
|
-
def add_error(error)
|
270
|
-
super
|
271
|
-
error.ast_node ||= irep_node.ast_node
|
272
|
-
error.path ||= path
|
273
|
-
nil
|
274
|
-
end
|
275
|
-
|
276
|
-
def inspect
|
277
|
-
"#<GraphQL Context @ #{irep_node.owner_type.name}.#{field.name}>"
|
278
|
-
end
|
279
|
-
|
280
|
-
# Set a new value for this field in the response.
|
281
|
-
# It may be updated after resolving a {Lazy}.
|
282
|
-
# If it is {Execute::PROPAGATE_NULL}, tell the owner to propagate null.
|
283
|
-
# If it's {Execute::Execution::SKIP}, remove this field result from its parent
|
284
|
-
# @param new_value [Any] The GraphQL-ready value
|
285
|
-
# @api private
|
286
|
-
def value=(new_value)
|
287
|
-
case new_value
|
288
|
-
when GraphQL::Execution::Execute::PROPAGATE_NULL, nil
|
289
|
-
@invalid_null = true
|
290
|
-
@value = nil
|
291
|
-
if @type.kind.non_null?
|
292
|
-
@parent.received_null_child
|
293
|
-
end
|
294
|
-
when GraphQL::Execution::Execute::SKIP
|
295
|
-
@parent.skipped = true
|
296
|
-
@parent.delete(self)
|
297
|
-
else
|
298
|
-
@value = new_value
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
protected
|
303
|
-
|
304
|
-
def received_null_child
|
305
|
-
case @value
|
306
|
-
when Hash
|
307
|
-
self.value = GraphQL::Execution::Execute::PROPAGATE_NULL
|
308
|
-
when Array
|
309
|
-
if list_of_non_null_items?(@type)
|
310
|
-
self.value = GraphQL::Execution::Execute::PROPAGATE_NULL
|
311
|
-
end
|
312
|
-
when nil
|
313
|
-
# TODO This is a hack
|
314
|
-
# It was already nulled out but it's getting reassigned
|
315
|
-
else
|
316
|
-
raise "Unexpected value for received_null_child (#{self.value.class}): #{value}"
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
private
|
321
|
-
|
322
|
-
def list_of_non_null_items?(type)
|
323
|
-
case type
|
324
|
-
when GraphQL::NonNullType
|
325
|
-
# Unwrap [T]!
|
326
|
-
list_of_non_null_items?(type.of_type)
|
327
|
-
when GraphQL::ListType
|
328
|
-
type.of_type.is_a?(GraphQL::NonNullType)
|
329
|
-
else
|
330
|
-
raise "Unexpected list_of_non_null_items check: #{type}"
|
331
|
-
end
|
332
|
-
end
|
333
|
-
end
|
334
195
|
end
|
335
196
|
end
|
336
197
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'digest/sha2'
|
4
|
+
|
5
|
+
module GraphQL
|
6
|
+
class Query
|
7
|
+
# @api private
|
8
|
+
# @see Query#query_fingerprint
|
9
|
+
# @see Query#variables_fingerprint
|
10
|
+
# @see Query#fingerprint
|
11
|
+
module Fingerprint
|
12
|
+
# Make an obfuscated hash of the given string (either a query string or variables JSON)
|
13
|
+
# @param string [String]
|
14
|
+
# @return [String] A normalized, opaque hash
|
15
|
+
def self.generate(input_str)
|
16
|
+
# Implemented to be:
|
17
|
+
# - Short (and uniform) length
|
18
|
+
# - Stable
|
19
|
+
# - Irreversibly Opaque (don't want to leak variable values)
|
20
|
+
# - URL-friendly
|
21
|
+
bytes = Digest::SHA256.digest(input_str)
|
22
|
+
Base64.urlsafe_encode64(bytes)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -4,22 +4,39 @@ module GraphQL
|
|
4
4
|
class InputValidationResult
|
5
5
|
attr_accessor :problems
|
6
6
|
|
7
|
+
def initialize(valid: true, problems: nil)
|
8
|
+
@valid = valid
|
9
|
+
@problems = problems
|
10
|
+
end
|
11
|
+
|
7
12
|
def valid?
|
8
|
-
@
|
13
|
+
@valid
|
9
14
|
end
|
10
15
|
|
11
|
-
def add_problem(explanation, path = nil)
|
16
|
+
def add_problem(explanation, path = nil, extensions: nil, message: nil)
|
12
17
|
@problems ||= []
|
13
|
-
@
|
18
|
+
@valid = false
|
19
|
+
problem = { "path" => path || [], "explanation" => explanation }
|
20
|
+
if extensions
|
21
|
+
problem["extensions"] = extensions
|
22
|
+
end
|
23
|
+
if message
|
24
|
+
problem["message"] = message
|
25
|
+
end
|
26
|
+
@problems.push(problem)
|
14
27
|
end
|
15
28
|
|
16
29
|
def merge_result!(path, inner_result)
|
17
30
|
return if inner_result.valid?
|
18
31
|
|
19
|
-
inner_result.problems
|
20
|
-
|
21
|
-
|
32
|
+
if inner_result.problems
|
33
|
+
inner_result.problems.each do |p|
|
34
|
+
item_path = [path, *p["path"]]
|
35
|
+
add_problem(p["explanation"], item_path, message: p["message"], extensions: p["extensions"])
|
36
|
+
end
|
22
37
|
end
|
38
|
+
# It could have been explicitly set on inner_result (if it had no problems)
|
39
|
+
@valid = false
|
23
40
|
end
|
24
41
|
end
|
25
42
|
end
|
@@ -12,8 +12,8 @@ module GraphQL
|
|
12
12
|
when Language::Nodes::VariableIdentifier
|
13
13
|
variables[ast_node.name]
|
14
14
|
else
|
15
|
-
case type
|
16
|
-
when
|
15
|
+
case type.kind.name
|
16
|
+
when "SCALAR"
|
17
17
|
# TODO smell
|
18
18
|
# This gets used for plain values during subscriber.trigger
|
19
19
|
if variables
|
@@ -21,7 +21,7 @@ module GraphQL
|
|
21
21
|
else
|
22
22
|
type.coerce_isolated_input(ast_node)
|
23
23
|
end
|
24
|
-
when
|
24
|
+
when "ENUM"
|
25
25
|
# TODO smell
|
26
26
|
# This gets used for plain values sometimes
|
27
27
|
v = ast_node.is_a?(GraphQL::Language::Nodes::Enum) ? ast_node.name : ast_node
|
@@ -30,18 +30,20 @@ module GraphQL
|
|
30
30
|
else
|
31
31
|
type.coerce_isolated_input(v)
|
32
32
|
end
|
33
|
-
when
|
33
|
+
when "NON_NULL"
|
34
34
|
LiteralInput.coerce(type.of_type, ast_node, variables)
|
35
|
-
when
|
35
|
+
when "LIST"
|
36
36
|
if ast_node.is_a?(Array)
|
37
37
|
ast_node.map { |element_ast| LiteralInput.coerce(type.of_type, element_ast, variables) }
|
38
38
|
else
|
39
39
|
[LiteralInput.coerce(type.of_type, ast_node, variables)]
|
40
40
|
end
|
41
|
-
when
|
41
|
+
when "INPUT_OBJECT"
|
42
42
|
# TODO smell: handling AST vs handling plain Ruby
|
43
43
|
next_args = ast_node.is_a?(Hash) ? ast_node : ast_node.arguments
|
44
44
|
from_arguments(next_args, type, variables)
|
45
|
+
else
|
46
|
+
raise "Invariant: unexpected type to coerce to: #{type}"
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -60,7 +62,7 @@ module GraphQL
|
|
60
62
|
raise ArgumentError, "Unexpected ast_arguments: #{ast_arguments}"
|
61
63
|
end
|
62
64
|
|
63
|
-
argument_defns = argument_owner.arguments
|
65
|
+
argument_defns = argument_owner.arguments(context || GraphQL::Query::NullContext)
|
64
66
|
argument_defns.each do |arg_name, arg_defn|
|
65
67
|
ast_arg = indexed_arguments[arg_name]
|
66
68
|
# First, check the argument in the AST.
|
@@ -78,7 +80,10 @@ module GraphQL
|
|
78
80
|
if (!value_is_a_variable || (value_is_a_variable && variables.key?(arg_value.name)))
|
79
81
|
|
80
82
|
value = coerce(arg_defn.type, arg_value, variables)
|
81
|
-
|
83
|
+
# Legacy `prepare` application
|
84
|
+
if arg_defn.is_a?(GraphQL::Argument)
|
85
|
+
value = arg_defn.prepare(value, context)
|
86
|
+
end
|
82
87
|
|
83
88
|
if value.is_a?(GraphQL::ExecutionError)
|
84
89
|
value.ast_node = ast_arg
|
@@ -98,7 +103,9 @@ module GraphQL
|
|
98
103
|
defaults_used << arg_name
|
99
104
|
# `context` isn't present when pre-calculating defaults
|
100
105
|
if context
|
101
|
-
|
106
|
+
if arg_defn.is_a?(GraphQL::Argument)
|
107
|
+
value = arg_defn.prepare(value, context)
|
108
|
+
end
|
102
109
|
if value.is_a?(GraphQL::ExecutionError)
|
103
110
|
value.ast_node = ast_arg
|
104
111
|
raise value
|
@@ -108,8 +115,16 @@ module GraphQL
|
|
108
115
|
end
|
109
116
|
end
|
110
117
|
|
111
|
-
|
112
|
-
|
118
|
+
# A Schema::InputObject, Schema::GraphQL::Field, Schema::Directive, logic from Interpreter::Arguments
|
119
|
+
ruby_kwargs = {}
|
120
|
+
values_hash.each do |key, value|
|
121
|
+
ruby_kwargs[Schema::Member::BuildType.underscore(key).to_sym] = value
|
122
|
+
end
|
123
|
+
if argument_owner.is_a?(Class) && argument_owner < GraphQL::Schema::InputObject
|
124
|
+
argument_owner.new(ruby_kwargs: ruby_kwargs, context: context, defaults_used: defaults_used)
|
125
|
+
else
|
126
|
+
ruby_kwargs
|
127
|
+
end
|
113
128
|
end
|
114
129
|
end
|
115
130
|
end
|
@@ -4,16 +4,28 @@ module GraphQL
|
|
4
4
|
# This object can be `ctx` in places where there is no query
|
5
5
|
class NullContext
|
6
6
|
class NullWarden < GraphQL::Schema::Warden
|
7
|
-
def
|
8
|
-
def
|
9
|
-
def visible_type?(
|
7
|
+
def visible_field?(field, ctx); true; end
|
8
|
+
def visible_argument?(arg, ctx); true; end
|
9
|
+
def visible_type?(type, ctx); true; end
|
10
|
+
def visible_enum_value?(ev, ctx); true; end
|
11
|
+
def visible_type_membership?(tm, ctx); true; end
|
10
12
|
end
|
11
13
|
|
12
|
-
|
14
|
+
class NullQuery
|
15
|
+
def with_error_handling
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class NullSchema < GraphQL::Schema
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :schema, :query, :warden, :dataloader
|
13
24
|
|
14
25
|
def initialize
|
15
|
-
@query =
|
16
|
-
@
|
26
|
+
@query = NullQuery.new
|
27
|
+
@dataloader = GraphQL::Dataloader::NullDataloader.new
|
28
|
+
@schema = NullSchema
|
17
29
|
@warden = NullWarden.new(
|
18
30
|
GraphQL::Filter.new,
|
19
31
|
context: self,
|
@@ -23,16 +35,20 @@ module GraphQL
|
|
23
35
|
|
24
36
|
def [](key); end
|
25
37
|
|
38
|
+
def interpreter?
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
26
42
|
class << self
|
27
43
|
extend Forwardable
|
28
44
|
|
29
45
|
def [](key); end
|
30
46
|
|
31
47
|
def instance
|
32
|
-
@instance
|
48
|
+
@instance ||= self.new
|
33
49
|
end
|
34
50
|
|
35
|
-
def_delegators :instance, :query, :schema, :
|
51
|
+
def_delegators :instance, :query, :warden, :schema, :interpreter?, :dataloader
|
36
52
|
end
|
37
53
|
end
|
38
54
|
end
|
@@ -16,10 +16,8 @@ module GraphQL
|
|
16
16
|
class ValidationPipeline
|
17
17
|
attr_reader :max_depth, :max_complexity
|
18
18
|
|
19
|
-
def initialize(query:,
|
19
|
+
def initialize(query:, parse_error:, operation_name_error:, max_depth:, max_complexity:)
|
20
20
|
@validation_errors = []
|
21
|
-
@internal_representation = nil
|
22
|
-
@validate = validate
|
23
21
|
@parse_error = parse_error
|
24
22
|
@operation_name_error = operation_name_error
|
25
23
|
@query = query
|
@@ -36,18 +34,12 @@ module GraphQL
|
|
36
34
|
@valid
|
37
35
|
end
|
38
36
|
|
39
|
-
# @return [Array<GraphQL::StaticValidation::Error >] Static validation errors for the query string
|
37
|
+
# @return [Array<GraphQL::StaticValidation::Error, GraphQL::Query::VariableValidationError>] Static validation errors for the query string
|
40
38
|
def validation_errors
|
41
39
|
ensure_has_validated
|
42
40
|
@validation_errors
|
43
41
|
end
|
44
42
|
|
45
|
-
# @return [Hash<String, nil => GraphQL::InternalRepresentation::Node] Operation name -> Irep node pairs
|
46
|
-
def internal_representation
|
47
|
-
ensure_has_validated
|
48
|
-
@internal_representation
|
49
|
-
end
|
50
|
-
|
51
43
|
def analyzers
|
52
44
|
ensure_has_validated
|
53
45
|
@query_analyzers
|
@@ -63,7 +55,7 @@ module GraphQL
|
|
63
55
|
|
64
56
|
if @parse_error
|
65
57
|
# This is kind of crazy: we push the parse error into `ctx`
|
66
|
-
# in
|
58
|
+
# in `def self.parse_error` by default so that users can _opt out_ by redefining that hook.
|
67
59
|
# That means we can't _re-add_ the error here (otherwise we'd either
|
68
60
|
# add it twice _or_ override the user's choice to not add it).
|
69
61
|
# So we just have to know that it was invalid and go from there.
|
@@ -72,9 +64,8 @@ module GraphQL
|
|
72
64
|
elsif @operation_name_error
|
73
65
|
@validation_errors << @operation_name_error
|
74
66
|
else
|
75
|
-
validation_result = @schema.static_validator.validate(@query, validate: @validate)
|
67
|
+
validation_result = @schema.static_validator.validate(@query, validate: @query.validate, timeout: @schema.validate_timeout, max_errors: @schema.validate_max_errors)
|
76
68
|
@validation_errors.concat(validation_result[:errors])
|
77
|
-
@internal_representation = validation_result[:irep]
|
78
69
|
|
79
70
|
if @validation_errors.empty?
|
80
71
|
@validation_errors.concat(@query.variables.errors)
|
@@ -90,6 +81,9 @@ module GraphQL
|
|
90
81
|
end
|
91
82
|
|
92
83
|
@valid = @validation_errors.empty?
|
84
|
+
rescue SystemStackError => err
|
85
|
+
@valid = false
|
86
|
+
@schema.query_stack_error(@query, err)
|
93
87
|
end
|
94
88
|
|
95
89
|
# If there are max_* values, add them,
|
@@ -97,35 +91,15 @@ module GraphQL
|
|
97
91
|
def build_analyzers(schema, max_depth, max_complexity)
|
98
92
|
qa = schema.query_analyzers.dup
|
99
93
|
|
100
|
-
# Filter out the built in authorization analyzer.
|
101
|
-
# It is deprecated and does not have an AST analyzer alternative.
|
102
|
-
qa = qa.select do |analyzer|
|
103
|
-
if analyzer == GraphQL::Authorization::Analyzer && schema.using_ast_analysis?
|
104
|
-
raise "The Authorization analyzer is not supported with AST Analyzers"
|
105
|
-
else
|
106
|
-
true
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
94
|
if max_depth || max_complexity
|
111
95
|
# Depending on the analysis engine, we must use different analyzers
|
112
96
|
# remove this once everything has switched over to AST analyzers
|
113
|
-
if
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
qa << GraphQL::Analysis::AST::MaxQueryComplexity
|
119
|
-
end
|
120
|
-
else
|
121
|
-
if max_depth
|
122
|
-
qa << GraphQL::Analysis::MaxQueryDepth.new(max_depth)
|
123
|
-
end
|
124
|
-
if max_complexity
|
125
|
-
qa << GraphQL::Analysis::MaxQueryComplexity.new(max_complexity)
|
126
|
-
end
|
97
|
+
if max_depth
|
98
|
+
qa << GraphQL::Analysis::AST::MaxQueryDepth
|
99
|
+
end
|
100
|
+
if max_complexity
|
101
|
+
qa << GraphQL::Analysis::AST::MaxQueryComplexity
|
127
102
|
end
|
128
|
-
|
129
103
|
qa
|
130
104
|
else
|
131
105
|
qa
|
@@ -8,7 +8,7 @@ module GraphQL
|
|
8
8
|
@value = value
|
9
9
|
@validation_result = validation_result
|
10
10
|
|
11
|
-
msg = "Variable
|
11
|
+
msg = "Variable $#{variable_ast.name} of type #{type.to_type_signature} was provided invalid value"
|
12
12
|
|
13
13
|
if problem_fields.any?
|
14
14
|
msg += " for #{problem_fields.join(", ")}"
|
@@ -23,7 +23,7 @@ module GraphQL
|
|
23
23
|
# a one level deep merge explicitly. However beyond that only show the
|
24
24
|
# latest value and problems.
|
25
25
|
super.merge({ "extensions" => { "value" => value, "problems" => validation_result.problems }}) do |key, oldValue, newValue|
|
26
|
-
if oldValue.respond_to?
|
26
|
+
if oldValue.respond_to?(:merge)
|
27
27
|
oldValue.merge(newValue)
|
28
28
|
else
|
29
29
|
newValue
|