graphql 1.9.17 → 2.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/core.rb +21 -10
- data/lib/generators/graphql/enum_generator.rb +4 -10
- data/lib/generators/graphql/field_extractor.rb +31 -0
- data/lib/generators/graphql/input_generator.rb +50 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +34 -0
- data/lib/generators/graphql/{templates → install/templates}/base_mutation.erb +2 -0
- data/lib/generators/graphql/{templates → install/templates}/mutation_type.erb +2 -0
- data/lib/generators/graphql/install_generator.rb +45 -8
- data/lib/generators/graphql/interface_generator.rb +7 -7
- data/lib/generators/graphql/loader_generator.rb +1 -0
- data/lib/generators/graphql/mutation_create_generator.rb +22 -0
- data/lib/generators/graphql/mutation_delete_generator.rb +22 -0
- data/lib/generators/graphql/mutation_generator.rb +6 -30
- data/lib/generators/graphql/mutation_update_generator.rb +22 -0
- data/lib/generators/graphql/object_generator.rb +28 -12
- data/lib/generators/graphql/orm_mutations_base.rb +40 -0
- data/lib/generators/graphql/relay.rb +49 -0
- data/lib/generators/graphql/relay_generator.rb +21 -0
- data/lib/generators/graphql/scalar_generator.rb +4 -2
- data/lib/generators/graphql/templates/base_argument.erb +2 -0
- data/lib/generators/graphql/templates/base_connection.erb +8 -0
- data/lib/generators/graphql/templates/base_edge.erb +8 -0
- data/lib/generators/graphql/templates/base_enum.erb +2 -0
- data/lib/generators/graphql/templates/base_field.erb +2 -0
- data/lib/generators/graphql/templates/base_input_object.erb +2 -0
- data/lib/generators/graphql/templates/base_interface.erb +2 -0
- data/lib/generators/graphql/templates/base_object.erb +2 -0
- data/lib/generators/graphql/templates/base_scalar.erb +2 -0
- data/lib/generators/graphql/templates/base_union.erb +2 -0
- data/lib/generators/graphql/templates/enum.erb +7 -1
- data/lib/generators/graphql/templates/graphql_controller.erb +16 -12
- data/lib/generators/graphql/templates/input.erb +9 -0
- data/lib/generators/graphql/templates/interface.erb +6 -2
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +3 -1
- data/lib/generators/graphql/templates/mutation_create.erb +20 -0
- data/lib/generators/graphql/templates/mutation_delete.erb +20 -0
- data/lib/generators/graphql/templates/mutation_update.erb +21 -0
- data/lib/generators/graphql/templates/node_type.erb +9 -0
- data/lib/generators/graphql/templates/object.erb +7 -3
- data/lib/generators/graphql/templates/query_type.erb +3 -3
- data/lib/generators/graphql/templates/scalar.erb +5 -1
- data/lib/generators/graphql/templates/schema.erb +25 -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 +31 -2
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -1
- 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 +54 -38
- data/lib/graphql/analysis/ast.rb +16 -16
- 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/trace.rb +96 -0
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +39 -9
- data/lib/graphql/backtrace.rb +26 -18
- data/lib/graphql/dataloader/null_dataloader.rb +24 -0
- data/lib/graphql/dataloader/request.rb +19 -0
- data/lib/graphql/dataloader/request_all.rb +19 -0
- data/lib/graphql/dataloader/source.rb +164 -0
- data/lib/graphql/dataloader.rb +311 -0
- data/lib/graphql/date_encoding_error.rb +16 -0
- data/lib/graphql/deprecation.rb +9 -0
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/directive_checks.rb +2 -2
- data/lib/graphql/execution/errors.rb +77 -45
- data/lib/graphql/execution/interpreter/argument_value.rb +28 -0
- data/lib/graphql/execution/interpreter/arguments.rb +88 -0
- data/lib/graphql/execution/interpreter/arguments_cache.rb +104 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
- data/lib/graphql/execution/interpreter/resolve.rb +62 -24
- data/lib/graphql/execution/interpreter/runtime.rb +830 -417
- data/lib/graphql/execution/interpreter.rb +206 -74
- data/lib/graphql/execution/lazy/lazy_method_map.rb +4 -0
- data/lib/graphql/execution/lazy.rb +11 -21
- data/lib/graphql/execution/lookahead.rb +65 -136
- data/lib/graphql/execution/multiplex.rb +6 -152
- data/lib/graphql/execution.rb +11 -4
- data/lib/graphql/filter.rb +8 -3
- 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 +12 -6
- 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 +12 -12
- data/lib/graphql/introspection/type_type.rb +34 -17
- data/lib/graphql/introspection.rb +100 -0
- data/lib/graphql/invalid_null_error.rb +18 -0
- data/lib/graphql/language/block_string.rb +20 -5
- data/lib/graphql/language/cache.rb +37 -0
- data/lib/graphql/language/definition_slice.rb +21 -10
- data/lib/graphql/language/document_from_schema_definition.rb +136 -78
- data/lib/graphql/language/lexer.rb +216 -1462
- data/lib/graphql/language/nodes.rb +129 -132
- data/lib/graphql/language/parser.rb +994 -932
- data/lib/graphql/language/parser.y +152 -120
- data/lib/graphql/language/printer.rb +48 -23
- data/lib/graphql/language/sanitized_printer.rb +222 -0
- data/lib/graphql/language/token.rb +0 -4
- data/lib/graphql/language/visitor.rb +192 -84
- data/lib/graphql/language.rb +3 -1
- data/lib/graphql/name_validator.rb +2 -7
- data/lib/graphql/pagination/active_record_relation_connection.rb +77 -0
- data/lib/graphql/pagination/array_connection.rb +79 -0
- data/lib/graphql/pagination/connection.rb +253 -0
- data/lib/graphql/pagination/connections.rb +135 -0
- data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
- data/lib/graphql/pagination/relation_connection.rb +228 -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 +205 -203
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +33 -7
- data/lib/graphql/query/null_context.rb +22 -9
- data/lib/graphql/query/validation_pipeline.rb +16 -38
- data/lib/graphql/query/variable_validation_error.rb +3 -3
- data/lib/graphql/query/variables.rb +39 -12
- data/lib/graphql/query.rb +95 -43
- data/lib/graphql/railtie.rb +6 -102
- data/lib/graphql/rake_task/validate.rb +4 -1
- data/lib/graphql/rake_task.rb +41 -10
- data/lib/graphql/relay/range_add.rb +17 -10
- data/lib/graphql/relay.rb +0 -15
- data/lib/graphql/rubocop/graphql/base_cop.rb +36 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +43 -0
- data/lib/graphql/rubocop/graphql/default_required_true.rb +43 -0
- data/lib/graphql/rubocop.rb +4 -0
- data/lib/graphql/schema/addition.rb +245 -0
- data/lib/graphql/schema/argument.rb +285 -36
- 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 +348 -205
- 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/one_of.rb +12 -0
- data/lib/graphql/schema/directive/skip.rb +2 -2
- data/lib/graphql/schema/directive/transform.rb +14 -2
- data/lib/graphql/schema/directive.rb +134 -15
- data/lib/graphql/schema/enum.rb +137 -39
- data/lib/graphql/schema/enum_value.rb +17 -23
- data/lib/graphql/schema/field/connection_extension.rb +50 -20
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +504 -331
- data/lib/graphql/schema/field_extension.rb +86 -2
- data/lib/graphql/schema/find_inherited_value.rb +12 -1
- data/lib/graphql/schema/finder.rb +16 -14
- data/lib/graphql/schema/input_object.rb +182 -60
- data/lib/graphql/schema/interface.rb +24 -49
- data/lib/graphql/schema/introspection_system.rb +103 -37
- data/lib/graphql/schema/late_bound_type.rb +9 -2
- data/lib/graphql/schema/list.rb +61 -3
- data/lib/graphql/schema/loader.rb +144 -96
- data/lib/graphql/schema/member/base_dsl_methods.rb +41 -37
- data/lib/graphql/schema/member/build_type.rb +24 -15
- data/lib/graphql/schema/member/has_arguments.rb +310 -26
- data/lib/graphql/schema/member/has_ast_node.rb +32 -0
- data/lib/graphql/schema/member/has_deprecation_reason.rb +24 -0
- data/lib/graphql/schema/member/has_directives.rb +118 -0
- data/lib/graphql/schema/member/has_fields.rb +166 -44
- data/lib/graphql/schema/member/has_interfaces.rb +129 -0
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
- data/lib/graphql/schema/member/has_validators.rb +57 -0
- data/lib/graphql/schema/member/relay_shortcuts.rb +47 -2
- data/lib/graphql/schema/member/type_system_helpers.rb +20 -3
- data/lib/graphql/schema/member/validates_input.rb +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 +36 -60
- data/lib/graphql/schema/printer.rb +16 -35
- data/lib/graphql/schema/relay_classic_mutation.rb +91 -44
- data/lib/graphql/schema/resolver/has_payload_type.rb +51 -11
- data/lib/graphql/schema/resolver.rb +147 -94
- data/lib/graphql/schema/scalar.rb +40 -15
- data/lib/graphql/schema/subscription.rb +60 -31
- data/lib/graphql/schema/timeout.rb +45 -35
- data/lib/graphql/schema/type_expression.rb +21 -13
- data/lib/graphql/schema/type_membership.rb +23 -6
- data/lib/graphql/schema/union.rb +49 -15
- 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 +213 -35
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +857 -884
- data/lib/graphql/static_validation/all_rules.rb +3 -0
- data/lib/graphql/static_validation/base_visitor.rb +21 -31
- data/lib/graphql/static_validation/definition_dependencies.rb +7 -2
- data/lib/graphql/static_validation/error.rb +3 -1
- data/lib/graphql/static_validation/literal_validator.rb +69 -26
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +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 +12 -6
- 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 +15 -7
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +96 -53
- 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/one_of_input_objects_are_valid.rb +66 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -2
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +9 -10
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +13 -7
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +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 +32 -20
- data/lib/graphql/static_validation.rb +1 -2
- data/lib/graphql/string_encoding_error.rb +13 -3
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +129 -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 +84 -35
- data/lib/graphql/subscriptions/instrumentation.rb +0 -47
- data/lib/graphql/subscriptions/serialize.rb +53 -6
- data/lib/graphql/subscriptions.rb +137 -57
- data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +8 -17
- data/lib/graphql/tracing/appoptics_trace.rb +231 -0
- data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
- data/lib/graphql/tracing/appsignal_trace.rb +77 -0
- data/lib/graphql/tracing/appsignal_tracing.rb +23 -0
- data/lib/graphql/tracing/data_dog_trace.rb +148 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +34 -2
- data/lib/graphql/tracing/legacy_trace.rb +65 -0
- data/lib/graphql/tracing/new_relic_trace.rb +75 -0
- data/lib/graphql/tracing/new_relic_tracing.rb +9 -12
- data/lib/graphql/tracing/notifications_trace.rb +42 -0
- data/lib/graphql/tracing/notifications_tracing.rb +59 -0
- data/lib/graphql/tracing/platform_trace.rb +109 -0
- data/lib/graphql/tracing/platform_tracing.rb +76 -35
- data/lib/graphql/tracing/prometheus_trace.rb +89 -0
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +5 -2
- data/lib/graphql/tracing/prometheus_tracing.rb +11 -3
- data/lib/graphql/tracing/scout_trace.rb +72 -0
- data/lib/graphql/tracing/scout_tracing.rb +19 -0
- data/lib/graphql/tracing/statsd_trace.rb +56 -0
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing/trace.rb +75 -0
- data/lib/graphql/tracing.rb +23 -67
- data/lib/graphql/type_kinds.rb +6 -3
- data/lib/graphql/types/big_int.rb +5 -1
- data/lib/graphql/types/int.rb +10 -3
- data/lib/graphql/types/iso_8601_date.rb +20 -9
- data/lib/graphql/types/iso_8601_date_time.rb +36 -10
- data/lib/graphql/types/relay/base_connection.rb +18 -90
- data/lib/graphql/types/relay/base_edge.rb +2 -34
- data/lib/graphql/types/relay/connection_behaviors.rb +176 -0
- data/lib/graphql/types/relay/edge_behaviors.rb +75 -0
- data/lib/graphql/types/relay/has_node_field.rb +41 -0
- data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
- data/lib/graphql/types/relay/node.rb +2 -4
- data/lib/graphql/types/relay/node_behaviors.rb +25 -0
- data/lib/graphql/types/relay/page_info.rb +2 -14
- data/lib/graphql/types/relay/page_info_behaviors.rb +30 -0
- data/lib/graphql/types/relay.rb +10 -5
- data/lib/graphql/types/string.rb +8 -2
- data/lib/graphql/unauthorized_error.rb +2 -2
- data/lib/graphql/unresolved_type_error.rb +2 -2
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +63 -65
- data/readme.md +3 -6
- metadata +127 -236
- data/lib/graphql/analysis/analyze_query.rb +0 -91
- data/lib/graphql/analysis/field_usage.rb +0 -45
- data/lib/graphql/analysis/max_query_complexity.rb +0 -26
- data/lib/graphql/analysis/max_query_depth.rb +0 -26
- data/lib/graphql/analysis/query_complexity.rb +0 -88
- data/lib/graphql/analysis/query_depth.rb +0 -43
- data/lib/graphql/analysis/reducer_state.rb +0 -48
- data/lib/graphql/argument.rb +0 -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 -50
- data/lib/graphql/define/instance_definable.rb +0 -300
- 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/instrumentation.rb +0 -92
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
- data/lib/graphql/execution/lazy/resolve.rb +0 -91
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -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/language/lexer.rl +0 -258
- data/lib/graphql/list_type.rb +0 -80
- data/lib/graphql/literal_validation_error.rb +0 -6
- data/lib/graphql/non_null_type.rb +0 -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/literal_input.rb +0 -116
- 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 -66
- 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 -128
- 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
|
|
@@ -143,9 +75,9 @@ module GraphQL
|
|
143
75
|
# Make a new context which delegates key lookup to `values`
|
144
76
|
# @param query [GraphQL::Query] the query who owns this context
|
145
77
|
# @param values [Hash] A hash of arbitrary values which will be accessible at query-time
|
146
|
-
def initialize(query:,
|
78
|
+
def initialize(query:, schema: query.schema, values:, object:)
|
147
79
|
@query = query
|
148
|
-
@schema =
|
80
|
+
@schema = schema
|
149
81
|
@provided_values = values || {}
|
150
82
|
@object = object
|
151
83
|
# Namespaced storage, where user-provided values are in `nil` namespace:
|
@@ -154,8 +86,115 @@ module GraphQL
|
|
154
86
|
@errors = []
|
155
87
|
@path = []
|
156
88
|
@value = nil
|
157
|
-
@context = self # for SharedMethods
|
158
|
-
@scoped_context =
|
89
|
+
@context = self # for SharedMethods TODO delete sharedmethods
|
90
|
+
@scoped_context = ScopedContext.new(self)
|
91
|
+
end
|
92
|
+
|
93
|
+
class ScopedContext
|
94
|
+
NO_PATH = GraphQL::EmptyObjects::EMPTY_ARRAY
|
95
|
+
NO_CONTEXT = GraphQL::EmptyObjects::EMPTY_HASH
|
96
|
+
|
97
|
+
def initialize(query_context)
|
98
|
+
@query_context = query_context
|
99
|
+
@scoped_contexts = nil
|
100
|
+
@all_keys = nil
|
101
|
+
end
|
102
|
+
|
103
|
+
def merged_context
|
104
|
+
if @scoped_contexts.nil?
|
105
|
+
NO_CONTEXT
|
106
|
+
else
|
107
|
+
merged_ctx = {}
|
108
|
+
each_present_path_ctx do |path_ctx|
|
109
|
+
merged_ctx = path_ctx.merge(merged_ctx)
|
110
|
+
end
|
111
|
+
merged_ctx
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def merge!(hash)
|
116
|
+
@all_keys ||= Set.new
|
117
|
+
@all_keys.merge(hash.keys)
|
118
|
+
ctx = @scoped_contexts ||= {}
|
119
|
+
current_path.each do |path_part|
|
120
|
+
ctx = ctx[path_part] ||= { parent: ctx }
|
121
|
+
end
|
122
|
+
this_scoped_ctx = ctx[:scoped_context] ||= {}
|
123
|
+
this_scoped_ctx.merge!(hash)
|
124
|
+
end
|
125
|
+
|
126
|
+
def key?(key)
|
127
|
+
if @all_keys && @all_keys.include?(key)
|
128
|
+
each_present_path_ctx do |path_ctx|
|
129
|
+
if path_ctx.key?(key)
|
130
|
+
return true
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
false
|
135
|
+
end
|
136
|
+
|
137
|
+
def [](key)
|
138
|
+
each_present_path_ctx do |path_ctx|
|
139
|
+
if path_ctx.key?(key)
|
140
|
+
return path_ctx[key]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
nil
|
144
|
+
end
|
145
|
+
|
146
|
+
def current_path
|
147
|
+
@query_context.current_path || NO_PATH
|
148
|
+
end
|
149
|
+
|
150
|
+
def dig(key, *other_keys)
|
151
|
+
each_present_path_ctx do |path_ctx|
|
152
|
+
if path_ctx.key?(key)
|
153
|
+
found_value = path_ctx[key]
|
154
|
+
if other_keys.any?
|
155
|
+
return found_value.dig(*other_keys)
|
156
|
+
else
|
157
|
+
return found_value
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
nil
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
|
166
|
+
# Start at the current location,
|
167
|
+
# but look up the tree for previously-assigned scoped values
|
168
|
+
def each_present_path_ctx
|
169
|
+
ctx = @scoped_contexts
|
170
|
+
if ctx.nil?
|
171
|
+
# no-op
|
172
|
+
else
|
173
|
+
current_path.each do |path_part|
|
174
|
+
if ctx.key?(path_part)
|
175
|
+
ctx = ctx[path_part]
|
176
|
+
else
|
177
|
+
break
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
while ctx
|
182
|
+
if (scoped_ctx = ctx[:scoped_context])
|
183
|
+
yield(scoped_ctx)
|
184
|
+
end
|
185
|
+
ctx = ctx[:parent]
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# @return [Hash] A hash that will be added verbatim to the result hash, as `"extensions" => { ... }`
|
192
|
+
def response_extensions
|
193
|
+
namespace(:__query_result_extensions__)
|
194
|
+
end
|
195
|
+
|
196
|
+
def dataloader
|
197
|
+
@dataloader ||= self[:dataloader] || (query.multiplex ? query.multiplex.dataloader : schema.dataloader_class.new)
|
159
198
|
end
|
160
199
|
|
161
200
|
# @api private
|
@@ -165,24 +204,96 @@ module GraphQL
|
|
165
204
|
attr_writer :value
|
166
205
|
|
167
206
|
# @api private
|
168
|
-
|
207
|
+
attr_reader :scoped_context
|
208
|
+
|
209
|
+
def []=(key, value)
|
210
|
+
@provided_values[key] = value
|
211
|
+
end
|
169
212
|
|
170
|
-
def_delegators :@provided_values, :[]=
|
171
|
-
def_delegators :to_h, :fetch, :dig
|
172
213
|
def_delegators :@query, :trace, :interpreter?
|
173
214
|
|
215
|
+
RUNTIME_METADATA_KEYS = Set.new([:current_object, :current_arguments, :current_field, :current_path])
|
174
216
|
# @!method []=(key, value)
|
175
217
|
# Reassign `key` to the hash passed to {Schema#execute} as `context:`
|
176
218
|
|
177
219
|
# Lookup `key` from the hash passed to {Schema#execute} as `context:`
|
178
220
|
def [](key)
|
179
|
-
|
180
|
-
|
221
|
+
if @scoped_context.key?(key)
|
222
|
+
@scoped_context[key]
|
223
|
+
elsif @provided_values.key?(key)
|
224
|
+
@provided_values[key]
|
225
|
+
elsif RUNTIME_METADATA_KEYS.include?(key)
|
226
|
+
if key == :current_path
|
227
|
+
current_path
|
228
|
+
else
|
229
|
+
(current_runtime_state = Thread.current[:__graphql_runtime_info]) &&
|
230
|
+
(current_runtime_state.public_send(key))
|
231
|
+
end
|
232
|
+
else
|
233
|
+
# not found
|
234
|
+
nil
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def current_path
|
239
|
+
current_runtime_state = Thread.current[:__graphql_runtime_info]
|
240
|
+
path = current_runtime_state &&
|
241
|
+
(result = current_runtime_state.current_result) &&
|
242
|
+
(result.path)
|
243
|
+
if path && (rn = current_runtime_state.current_result_name)
|
244
|
+
path = path.dup
|
245
|
+
path.push(rn)
|
246
|
+
end
|
247
|
+
path
|
248
|
+
end
|
249
|
+
|
250
|
+
def delete(key)
|
251
|
+
if @scoped_context.key?(key)
|
252
|
+
@scoped_context.delete(key)
|
253
|
+
else
|
254
|
+
@provided_values.delete(key)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
UNSPECIFIED_FETCH_DEFAULT = Object.new
|
259
|
+
|
260
|
+
def fetch(key, default = UNSPECIFIED_FETCH_DEFAULT)
|
261
|
+
if RUNTIME_METADATA_KEYS.include?(key)
|
262
|
+
(runtime = Thread.current[:__graphql_runtime_info]) &&
|
263
|
+
(runtime.public_send(key))
|
264
|
+
elsif @scoped_context.key?(key)
|
265
|
+
scoped_context[key]
|
266
|
+
elsif @provided_values.key?(key)
|
267
|
+
@provided_values[key]
|
268
|
+
elsif default != UNSPECIFIED_FETCH_DEFAULT
|
269
|
+
default
|
270
|
+
elsif block_given?
|
271
|
+
yield(self, key)
|
272
|
+
else
|
273
|
+
raise KeyError.new(key: key)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
def dig(key, *other_keys)
|
278
|
+
if RUNTIME_METADATA_KEYS.include?(key)
|
279
|
+
(current_runtime_state = Thread.current[:__graphql_runtime_info]) &&
|
280
|
+
(obj = current_runtime_state.public_send(key)) &&
|
281
|
+
obj.dig(*other_keys)
|
282
|
+
elsif @scoped_context.key?(key)
|
283
|
+
@scoped_context.dig(key, *other_keys)
|
284
|
+
else
|
285
|
+
@provided_values.dig(key, *other_keys)
|
286
|
+
end
|
181
287
|
end
|
182
288
|
|
183
289
|
def to_h
|
184
|
-
|
290
|
+
if (current_scoped_context = @scoped_context.merged_context)
|
291
|
+
@provided_values.merge(current_scoped_context)
|
292
|
+
else
|
293
|
+
@provided_values
|
294
|
+
end
|
185
295
|
end
|
296
|
+
|
186
297
|
alias :to_hash :to_h
|
187
298
|
|
188
299
|
def key?(key)
|
@@ -191,149 +302,40 @@ module GraphQL
|
|
191
302
|
|
192
303
|
# @return [GraphQL::Schema::Warden]
|
193
304
|
def warden
|
194
|
-
@warden ||= @query.warden
|
305
|
+
@warden ||= (@query && @query.warden)
|
195
306
|
end
|
196
307
|
|
308
|
+
# @api private
|
309
|
+
attr_writer :warden
|
310
|
+
|
197
311
|
# Get an isolated hash for `ns`. Doesn't affect user-provided storage.
|
198
312
|
# @param ns [Object] a usage-specific namespace identifier
|
199
313
|
# @return [Hash] namespaced storage
|
200
314
|
def namespace(ns)
|
201
|
-
|
315
|
+
if ns == :interpreter
|
316
|
+
self
|
317
|
+
else
|
318
|
+
@storage[ns]
|
319
|
+
end
|
202
320
|
end
|
203
321
|
|
204
|
-
|
205
|
-
|
322
|
+
# @return [Boolean] true if this namespace was accessed before
|
323
|
+
def namespace?(ns)
|
324
|
+
@storage.key?(ns)
|
206
325
|
end
|
207
326
|
|
208
|
-
|
209
|
-
|
210
|
-
@invalid_null = true
|
211
|
-
@value = nil
|
327
|
+
def inspect
|
328
|
+
"#<Query::Context ...>"
|
212
329
|
end
|
213
330
|
|
214
331
|
def scoped_merge!(hash)
|
215
|
-
@scoped_context
|
332
|
+
@scoped_context.merge!(hash)
|
216
333
|
end
|
217
334
|
|
218
335
|
def scoped_set!(key, value)
|
219
336
|
scoped_merge!(key => value)
|
220
337
|
nil
|
221
338
|
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
339
|
end
|
335
340
|
end
|
336
341
|
end
|
337
|
-
|
338
|
-
|
339
|
-
GraphQL::Schema::Context = GraphQL::Query::Context
|
@@ -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,23 +4,49 @@ module GraphQL
|
|
4
4
|
class InputValidationResult
|
5
5
|
attr_accessor :problems
|
6
6
|
|
7
|
+
def self.from_problem(explanation, path = nil, extensions: nil, message: nil)
|
8
|
+
result = self.new
|
9
|
+
result.add_problem(explanation, path, extensions: extensions, message: message)
|
10
|
+
result
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(valid: true, problems: nil)
|
14
|
+
@valid = valid
|
15
|
+
@problems = problems
|
16
|
+
end
|
17
|
+
|
7
18
|
def valid?
|
8
|
-
@
|
19
|
+
@valid
|
9
20
|
end
|
10
21
|
|
11
|
-
def add_problem(explanation, path = nil)
|
22
|
+
def add_problem(explanation, path = nil, extensions: nil, message: nil)
|
12
23
|
@problems ||= []
|
13
|
-
@
|
24
|
+
@valid = false
|
25
|
+
problem = { "path" => path || [], "explanation" => explanation }
|
26
|
+
if extensions
|
27
|
+
problem["extensions"] = extensions
|
28
|
+
end
|
29
|
+
if message
|
30
|
+
problem["message"] = message
|
31
|
+
end
|
32
|
+
@problems.push(problem)
|
14
33
|
end
|
15
34
|
|
16
35
|
def merge_result!(path, inner_result)
|
17
|
-
return if inner_result.valid?
|
36
|
+
return if inner_result.nil? || inner_result.valid?
|
18
37
|
|
19
|
-
inner_result.problems
|
20
|
-
|
21
|
-
|
38
|
+
if inner_result.problems
|
39
|
+
inner_result.problems.each do |p|
|
40
|
+
item_path = [path, *p["path"]]
|
41
|
+
add_problem(p["explanation"], item_path, message: p["message"], extensions: p["extensions"])
|
42
|
+
end
|
22
43
|
end
|
44
|
+
# It could have been explicitly set on inner_result (if it had no problems)
|
45
|
+
@valid = false
|
23
46
|
end
|
47
|
+
|
48
|
+
VALID = self.new
|
49
|
+
VALID.freeze
|
24
50
|
end
|
25
51
|
end
|
26
52
|
end
|
@@ -4,18 +4,27 @@ 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
|
+
end
|
16
|
+
|
17
|
+
class NullSchema < GraphQL::Schema
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :schema, :query, :warden, :dataloader
|
13
21
|
|
14
22
|
def initialize
|
15
|
-
@query =
|
16
|
-
@
|
23
|
+
@query = NullQuery.new
|
24
|
+
@dataloader = GraphQL::Dataloader::NullDataloader.new
|
25
|
+
@schema = NullSchema
|
17
26
|
@warden = NullWarden.new(
|
18
|
-
GraphQL::Filter.new,
|
27
|
+
GraphQL::Filter.new(silence_deprecation_warning: true),
|
19
28
|
context: self,
|
20
29
|
schema: @schema,
|
21
30
|
)
|
@@ -23,16 +32,20 @@ module GraphQL
|
|
23
32
|
|
24
33
|
def [](key); end
|
25
34
|
|
35
|
+
def interpreter?
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
26
39
|
class << self
|
27
40
|
extend Forwardable
|
28
41
|
|
29
42
|
def [](key); end
|
30
43
|
|
31
44
|
def instance
|
32
|
-
@instance
|
45
|
+
@instance ||= self.new
|
33
46
|
end
|
34
47
|
|
35
|
-
def_delegators :instance, :query, :schema, :
|
48
|
+
def_delegators :instance, :query, :warden, :schema, :interpreter?, :dataloader
|
36
49
|
end
|
37
50
|
end
|
38
51
|
end
|