graphql_cody 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +5 -0
- data/MIT-LICENSE +20 -0
- data/lib/generators/graphql/core.rb +74 -0
- data/lib/generators/graphql/enum_generator.rb +33 -0
- data/lib/generators/graphql/install_generator.rb +190 -0
- data/lib/generators/graphql/interface_generator.rb +27 -0
- data/lib/generators/graphql/loader_generator.rb +21 -0
- data/lib/generators/graphql/mutation_generator.rb +55 -0
- data/lib/generators/graphql/object_generator.rb +79 -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 +20 -0
- data/lib/generators/graphql/templates/base_argument.erb +6 -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 +6 -0
- data/lib/generators/graphql/templates/base_field.erb +7 -0
- data/lib/generators/graphql/templates/base_input_object.erb +7 -0
- data/lib/generators/graphql/templates/base_interface.erb +9 -0
- data/lib/generators/graphql/templates/base_mutation.erb +10 -0
- data/lib/generators/graphql/templates/base_object.erb +7 -0
- data/lib/generators/graphql/templates/base_scalar.erb +6 -0
- data/lib/generators/graphql/templates/base_union.erb +6 -0
- data/lib/generators/graphql/templates/enum.erb +7 -0
- data/lib/generators/graphql/templates/graphql_controller.erb +52 -0
- data/lib/generators/graphql/templates/interface.erb +8 -0
- data/lib/generators/graphql/templates/loader.erb +19 -0
- data/lib/generators/graphql/templates/mutation.erb +16 -0
- data/lib/generators/graphql/templates/mutation_type.erb +12 -0
- data/lib/generators/graphql/templates/node_type.erb +9 -0
- data/lib/generators/graphql/templates/object.erb +8 -0
- data/lib/generators/graphql/templates/query_type.erb +15 -0
- data/lib/generators/graphql/templates/scalar.erb +15 -0
- data/lib/generators/graphql/templates/schema.erb +27 -0
- data/lib/generators/graphql/templates/union.erb +7 -0
- data/lib/generators/graphql/type_generator.rb +98 -0
- data/lib/generators/graphql/union_generator.rb +33 -0
- data/lib/graphql/analysis/analyze_query.rb +98 -0
- data/lib/graphql/analysis/ast/analyzer.rb +84 -0
- data/lib/graphql/analysis/ast/field_usage.rb +51 -0
- data/lib/graphql/analysis/ast/max_query_complexity.rb +23 -0
- data/lib/graphql/analysis/ast/max_query_depth.rb +22 -0
- data/lib/graphql/analysis/ast/query_complexity.rb +230 -0
- data/lib/graphql/analysis/ast/query_depth.rb +56 -0
- data/lib/graphql/analysis/ast/visitor.rb +268 -0
- data/lib/graphql/analysis/ast.rb +91 -0
- data/lib/graphql/analysis/field_usage.rb +45 -0
- data/lib/graphql/analysis/max_query_complexity.rb +26 -0
- data/lib/graphql/analysis/max_query_depth.rb +26 -0
- data/lib/graphql/analysis/query_complexity.rb +88 -0
- data/lib/graphql/analysis/query_depth.rb +43 -0
- data/lib/graphql/analysis/reducer_state.rb +48 -0
- data/lib/graphql/analysis.rb +9 -0
- data/lib/graphql/analysis_error.rb +5 -0
- data/lib/graphql/argument.rb +131 -0
- data/lib/graphql/authorization.rb +82 -0
- data/lib/graphql/backtrace/inspect_result.rb +50 -0
- data/lib/graphql/backtrace/legacy_tracer.rb +56 -0
- data/lib/graphql/backtrace/table.rb +159 -0
- data/lib/graphql/backtrace/traced_error.rb +54 -0
- data/lib/graphql/backtrace/tracer.rb +81 -0
- data/lib/graphql/backtrace.rb +64 -0
- data/lib/graphql/backwards_compatibility.rb +61 -0
- data/lib/graphql/base_type.rb +230 -0
- data/lib/graphql/boolean_type.rb +2 -0
- data/lib/graphql/coercion_error.rb +13 -0
- data/lib/graphql/compatibility/execution_specification/counter_schema.rb +53 -0
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +200 -0
- data/lib/graphql/compatibility/execution_specification.rb +436 -0
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +111 -0
- data/lib/graphql/compatibility/lazy_execution_specification.rb +215 -0
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +87 -0
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +79 -0
- data/lib/graphql/compatibility/query_parser_specification.rb +266 -0
- data/lib/graphql/compatibility/schema_parser_specification.rb +682 -0
- data/lib/graphql/compatibility.rb +5 -0
- 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/define/assign_argument.rb +12 -0
- data/lib/graphql/define/assign_connection.rb +13 -0
- data/lib/graphql/define/assign_enum_value.rb +18 -0
- data/lib/graphql/define/assign_global_id_field.rb +11 -0
- data/lib/graphql/define/assign_mutation_function.rb +34 -0
- data/lib/graphql/define/assign_object_field.rb +42 -0
- data/lib/graphql/define/defined_object_proxy.rb +53 -0
- data/lib/graphql/define/instance_definable.rb +240 -0
- data/lib/graphql/define/no_definition_error.rb +7 -0
- data/lib/graphql/define/non_null_with_bang.rb +16 -0
- data/lib/graphql/define/type_definer.rb +31 -0
- data/lib/graphql/define.rb +31 -0
- data/lib/graphql/deprecated_dsl.rb +55 -0
- data/lib/graphql/deprecation.rb +9 -0
- data/lib/graphql/dig.rb +19 -0
- data/lib/graphql/directive/deprecated_directive.rb +2 -0
- data/lib/graphql/directive/include_directive.rb +2 -0
- data/lib/graphql/directive/skip_directive.rb +2 -0
- data/lib/graphql/directive.rb +107 -0
- data/lib/graphql/enum_type.rb +133 -0
- data/lib/graphql/execution/directive_checks.rb +37 -0
- data/lib/graphql/execution/errors.rb +163 -0
- data/lib/graphql/execution/execute.rb +333 -0
- data/lib/graphql/execution/flatten.rb +40 -0
- data/lib/graphql/execution/instrumentation.rb +92 -0
- 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 +103 -0
- data/lib/graphql/execution/interpreter/execution_errors.rb +29 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
- data/lib/graphql/execution/interpreter/resolve.rb +70 -0
- data/lib/graphql/execution/interpreter/runtime.rb +949 -0
- data/lib/graphql/execution/interpreter.rb +122 -0
- data/lib/graphql/execution/lazy/lazy_method_map.rb +98 -0
- data/lib/graphql/execution/lazy/resolve.rb +91 -0
- data/lib/graphql/execution/lazy.rb +83 -0
- data/lib/graphql/execution/lookahead.rb +307 -0
- data/lib/graphql/execution/multiplex.rb +214 -0
- data/lib/graphql/execution/typecast.rb +50 -0
- data/lib/graphql/execution.rb +11 -0
- data/lib/graphql/execution_error.rb +58 -0
- data/lib/graphql/field/resolve.rb +59 -0
- data/lib/graphql/field.rb +226 -0
- data/lib/graphql/filter.rb +53 -0
- data/lib/graphql/float_type.rb +2 -0
- data/lib/graphql/function.rb +128 -0
- data/lib/graphql/id_type.rb +2 -0
- data/lib/graphql/input_object_type.rb +138 -0
- data/lib/graphql/int_type.rb +2 -0
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +36 -0
- data/lib/graphql/interface_type.rb +72 -0
- data/lib/graphql/internal_representation/document.rb +27 -0
- data/lib/graphql/internal_representation/node.rb +206 -0
- data/lib/graphql/internal_representation/print.rb +51 -0
- data/lib/graphql/internal_representation/rewrite.rb +184 -0
- data/lib/graphql/internal_representation/scope.rb +88 -0
- data/lib/graphql/internal_representation/visit.rb +36 -0
- data/lib/graphql/internal_representation.rb +7 -0
- data/lib/graphql/introspection/base_object.rb +13 -0
- data/lib/graphql/introspection/directive_location_enum.rb +15 -0
- data/lib/graphql/introspection/directive_type.rb +29 -0
- data/lib/graphql/introspection/dynamic_fields.rb +17 -0
- data/lib/graphql/introspection/entry_points.rb +35 -0
- data/lib/graphql/introspection/enum_value_type.rb +23 -0
- data/lib/graphql/introspection/field_type.rb +28 -0
- data/lib/graphql/introspection/input_value_type.rb +67 -0
- data/lib/graphql/introspection/introspection_query.rb +7 -0
- data/lib/graphql/introspection/schema_type.rb +44 -0
- data/lib/graphql/introspection/type_kind_enum.rb +13 -0
- data/lib/graphql/introspection/type_type.rb +95 -0
- data/lib/graphql/introspection.rb +114 -0
- data/lib/graphql/invalid_name_error.rb +11 -0
- data/lib/graphql/invalid_null_error.rb +50 -0
- data/lib/graphql/language/block_string.rb +99 -0
- data/lib/graphql/language/cache.rb +37 -0
- data/lib/graphql/language/definition_slice.rb +41 -0
- data/lib/graphql/language/document_from_schema_definition.rb +347 -0
- data/lib/graphql/language/generation.rb +24 -0
- data/lib/graphql/language/lexer.rb +1467 -0
- data/lib/graphql/language/lexer.rl +258 -0
- data/lib/graphql/language/nodes.rb +707 -0
- data/lib/graphql/language/parser.rb +1974 -0
- data/lib/graphql/language/parser.y +544 -0
- data/lib/graphql/language/printer.rb +366 -0
- data/lib/graphql/language/sanitized_printer.rb +222 -0
- data/lib/graphql/language/token.rb +34 -0
- data/lib/graphql/language/visitor.rb +242 -0
- data/lib/graphql/language.rb +36 -0
- data/lib/graphql/list_type.rb +80 -0
- data/lib/graphql/load_application_object_failed_error.rb +22 -0
- data/lib/graphql/name_validator.rb +11 -0
- data/lib/graphql/non_null_type.rb +71 -0
- data/lib/graphql/object_type.rb +130 -0
- data/lib/graphql/pagination/active_record_relation_connection.rb +48 -0
- data/lib/graphql/pagination/array_connection.rb +77 -0
- data/lib/graphql/pagination/connection.rb +226 -0
- data/lib/graphql/pagination/connections.rb +160 -0
- data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
- data/lib/graphql/pagination/relation_connection.rb +196 -0
- data/lib/graphql/pagination/sequel_dataset_connection.rb +28 -0
- data/lib/graphql/pagination.rb +6 -0
- data/lib/graphql/parse_error.rb +24 -0
- data/lib/graphql/query/arguments.rb +189 -0
- data/lib/graphql/query/arguments_cache.rb +24 -0
- data/lib/graphql/query/context.rb +371 -0
- data/lib/graphql/query/executor.rb +52 -0
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +43 -0
- data/lib/graphql/query/literal_input.rb +136 -0
- data/lib/graphql/query/null_context.rb +55 -0
- data/lib/graphql/query/result.rb +63 -0
- data/lib/graphql/query/serial_execution/field_resolution.rb +92 -0
- data/lib/graphql/query/serial_execution/operation_resolution.rb +19 -0
- data/lib/graphql/query/serial_execution/selection_resolution.rb +23 -0
- data/lib/graphql/query/serial_execution/value_resolution.rb +87 -0
- data/lib/graphql/query/serial_execution.rb +40 -0
- data/lib/graphql/query/validation_pipeline.rb +139 -0
- data/lib/graphql/query/variable_validation_error.rb +44 -0
- data/lib/graphql/query/variables.rb +78 -0
- data/lib/graphql/query.rb +454 -0
- data/lib/graphql/railtie.rb +117 -0
- data/lib/graphql/rake_task/validate.rb +63 -0
- data/lib/graphql/rake_task.rb +145 -0
- data/lib/graphql/relay/array_connection.rb +83 -0
- data/lib/graphql/relay/base_connection.rb +189 -0
- data/lib/graphql/relay/connection_instrumentation.rb +54 -0
- data/lib/graphql/relay/connection_resolve.rb +43 -0
- data/lib/graphql/relay/connection_type.rb +41 -0
- data/lib/graphql/relay/edge.rb +27 -0
- data/lib/graphql/relay/edge_type.rb +19 -0
- data/lib/graphql/relay/edges_instrumentation.rb +39 -0
- data/lib/graphql/relay/global_id_resolve.rb +18 -0
- data/lib/graphql/relay/mongo_relation_connection.rb +50 -0
- data/lib/graphql/relay/mutation/instrumentation.rb +23 -0
- data/lib/graphql/relay/mutation/resolve.rb +56 -0
- data/lib/graphql/relay/mutation/result.rb +38 -0
- data/lib/graphql/relay/mutation.rb +106 -0
- data/lib/graphql/relay/node.rb +39 -0
- data/lib/graphql/relay/page_info.rb +7 -0
- data/lib/graphql/relay/range_add.rb +59 -0
- data/lib/graphql/relay/relation_connection.rb +188 -0
- data/lib/graphql/relay/type_extensions.rb +32 -0
- data/lib/graphql/relay.rb +18 -0
- 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/runtime_type_error.rb +5 -0
- data/lib/graphql/scalar_type.rb +91 -0
- data/lib/graphql/schema/addition.rb +247 -0
- data/lib/graphql/schema/argument.rb +383 -0
- data/lib/graphql/schema/base_64_bp.rb +26 -0
- data/lib/graphql/schema/base_64_encoder.rb +21 -0
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +47 -0
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +78 -0
- data/lib/graphql/schema/build_from_definition.rb +477 -0
- data/lib/graphql/schema/built_in_types.rb +12 -0
- data/lib/graphql/schema/catchall_middleware.rb +35 -0
- data/lib/graphql/schema/default_parse_error.rb +10 -0
- data/lib/graphql/schema/default_type_error.rb +17 -0
- data/lib/graphql/schema/directive/deprecated.rb +18 -0
- data/lib/graphql/schema/directive/feature.rb +66 -0
- data/lib/graphql/schema/directive/flagged.rb +57 -0
- data/lib/graphql/schema/directive/include.rb +25 -0
- data/lib/graphql/schema/directive/skip.rb +25 -0
- data/lib/graphql/schema/directive/transform.rb +60 -0
- data/lib/graphql/schema/directive.rb +210 -0
- data/lib/graphql/schema/enum.rb +193 -0
- data/lib/graphql/schema/enum_value.rb +97 -0
- data/lib/graphql/schema/field/connection_extension.rb +76 -0
- data/lib/graphql/schema/field/scope_extension.rb +22 -0
- data/lib/graphql/schema/field.rb +880 -0
- data/lib/graphql/schema/field_extension.rb +69 -0
- data/lib/graphql/schema/find_inherited_value.rb +36 -0
- data/lib/graphql/schema/finder.rb +155 -0
- data/lib/graphql/schema/input_object.rb +253 -0
- data/lib/graphql/schema/interface.rb +136 -0
- data/lib/graphql/schema/introspection_system.rb +169 -0
- data/lib/graphql/schema/invalid_type_error.rb +7 -0
- data/lib/graphql/schema/late_bound_type.rb +33 -0
- data/lib/graphql/schema/list.rb +75 -0
- data/lib/graphql/schema/loader.rb +226 -0
- data/lib/graphql/schema/member/accepts_definition.rb +159 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +129 -0
- data/lib/graphql/schema/member/build_type.rb +180 -0
- data/lib/graphql/schema/member/cached_graphql_definition.rb +31 -0
- data/lib/graphql/schema/member/graphql_type_names.rb +21 -0
- data/lib/graphql/schema/member/has_arguments.rb +332 -0
- 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 +163 -0
- data/lib/graphql/schema/member/has_interfaces.rb +90 -0
- data/lib/graphql/schema/member/has_path.rb +25 -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/instrumentation.rb +131 -0
- data/lib/graphql/schema/member/relay_shortcuts.rb +47 -0
- data/lib/graphql/schema/member/scoped.rb +21 -0
- data/lib/graphql/schema/member/type_system_helpers.rb +38 -0
- data/lib/graphql/schema/member/validates_input.rb +33 -0
- data/lib/graphql/schema/member.rb +161 -0
- data/lib/graphql/schema/middleware_chain.rb +82 -0
- data/lib/graphql/schema/mutation.rb +94 -0
- data/lib/graphql/schema/non_null.rb +67 -0
- data/lib/graphql/schema/null_mask.rb +11 -0
- data/lib/graphql/schema/object.rb +150 -0
- data/lib/graphql/schema/possible_types.rb +44 -0
- data/lib/graphql/schema/printer.rb +100 -0
- data/lib/graphql/schema/relay_classic_mutation.rb +160 -0
- data/lib/graphql/schema/rescue_middleware.rb +60 -0
- data/lib/graphql/schema/resolver/has_payload_type.rb +96 -0
- data/lib/graphql/schema/resolver.rb +397 -0
- data/lib/graphql/schema/scalar.rb +69 -0
- data/lib/graphql/schema/subscription.rb +155 -0
- data/lib/graphql/schema/timeout.rb +123 -0
- data/lib/graphql/schema/timeout_middleware.rb +88 -0
- data/lib/graphql/schema/traversal.rb +228 -0
- data/lib/graphql/schema/type_expression.rb +43 -0
- data/lib/graphql/schema/type_membership.rb +48 -0
- data/lib/graphql/schema/union.rb +95 -0
- data/lib/graphql/schema/unique_within_type.rb +34 -0
- data/lib/graphql/schema/validation.rb +313 -0
- 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 +68 -0
- data/lib/graphql/schema/validator.rb +174 -0
- data/lib/graphql/schema/warden.rb +409 -0
- data/lib/graphql/schema/wrapper.rb +29 -0
- data/lib/graphql/schema.rb +1945 -0
- data/lib/graphql/static_validation/all_rules.rb +40 -0
- data/lib/graphql/static_validation/base_visitor.rb +217 -0
- data/lib/graphql/static_validation/default_visitor.rb +15 -0
- data/lib/graphql/static_validation/definition_dependencies.rb +198 -0
- data/lib/graphql/static_validation/error.rb +46 -0
- data/lib/graphql/static_validation/interpreter_visitor.rb +14 -0
- data/lib/graphql/static_validation/literal_validator.rb +139 -0
- data/lib/graphql/static_validation/no_validate_visitor.rb +10 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +66 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +48 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +31 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +30 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +71 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +37 -0
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +23 -0
- data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +29 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +65 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +31 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +30 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +32 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +73 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +31 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +418 -0
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +53 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +30 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +73 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +35 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +39 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +21 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +16 -0
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +26 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +37 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +30 -0
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +32 -0
- data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +29 -0
- 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/mutation_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +41 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +25 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +36 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +28 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +37 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +35 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +59 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +35 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +50 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +29 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +46 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +39 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +24 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +29 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +153 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +38 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +39 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +32 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +155 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +37 -0
- data/lib/graphql/static_validation/type_stack.rb +216 -0
- data/lib/graphql/static_validation/validation_context.rb +49 -0
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +96 -0
- data/lib/graphql/static_validation.rb +19 -0
- data/lib/graphql/string_encoding_error.rb +20 -0
- data/lib/graphql/string_type.rb +2 -0
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +245 -0
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +81 -0
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +21 -0
- data/lib/graphql/subscriptions/event.rb +144 -0
- data/lib/graphql/subscriptions/instrumentation.rb +79 -0
- data/lib/graphql/subscriptions/serialize.rb +138 -0
- data/lib/graphql/subscriptions/subscription_root.rb +76 -0
- data/lib/graphql/subscriptions.rb +299 -0
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +35 -0
- data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
- data/lib/graphql/tracing/appsignal_tracing.rb +51 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +76 -0
- data/lib/graphql/tracing/new_relic_tracing.rb +51 -0
- data/lib/graphql/tracing/platform_tracing.rb +139 -0
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +32 -0
- data/lib/graphql/tracing/prometheus_tracing.rb +67 -0
- data/lib/graphql/tracing/scout_tracing.rb +54 -0
- data/lib/graphql/tracing/skylight_tracing.rb +70 -0
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +95 -0
- data/lib/graphql/type_kinds.rb +77 -0
- data/lib/graphql/types/big_int.rb +23 -0
- data/lib/graphql/types/boolean.rb +18 -0
- data/lib/graphql/types/float.rb +19 -0
- data/lib/graphql/types/id.rb +24 -0
- data/lib/graphql/types/int.rb +36 -0
- data/lib/graphql/types/iso_8601_date.rb +34 -0
- data/lib/graphql/types/iso_8601_date_time.rb +65 -0
- data/lib/graphql/types/json.rb +25 -0
- data/lib/graphql/types/relay/base_connection.rb +39 -0
- data/lib/graphql/types/relay/base_edge.rb +29 -0
- data/lib/graphql/types/relay/connection_behaviors.rb +156 -0
- data/lib/graphql/types/relay/default_relay.rb +27 -0
- data/lib/graphql/types/relay/edge_behaviors.rb +53 -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 +15 -0
- data/lib/graphql/types/relay/node_behaviors.rb +15 -0
- data/lib/graphql/types/relay/node_field.rb +25 -0
- data/lib/graphql/types/relay/nodes_field.rb +27 -0
- data/lib/graphql/types/relay/page_info.rb +11 -0
- data/lib/graphql/types/relay/page_info_behaviors.rb +25 -0
- data/lib/graphql/types/relay.rb +41 -0
- data/lib/graphql/types/string.rb +29 -0
- data/lib/graphql/types.rb +11 -0
- data/lib/graphql/unauthorized_error.rb +29 -0
- data/lib/graphql/unauthorized_field_error.rb +23 -0
- data/lib/graphql/union_type.rb +115 -0
- data/lib/graphql/unresolved_type_error.rb +35 -0
- data/lib/graphql/upgrader/member.rb +937 -0
- data/lib/graphql/upgrader/schema.rb +38 -0
- data/lib/graphql/version.rb +4 -0
- data/lib/graphql.rb +168 -0
- data/readme.md +49 -0
- metadata +714 -0
@@ -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
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class Query
|
4
|
+
class InputValidationResult
|
5
|
+
attr_accessor :problems
|
6
|
+
|
7
|
+
def initialize(valid: true, problems: nil)
|
8
|
+
@valid = valid
|
9
|
+
@problems = problems
|
10
|
+
end
|
11
|
+
|
12
|
+
def valid?
|
13
|
+
@valid
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_problem(explanation, path = nil, extensions: nil, message: nil)
|
17
|
+
@problems ||= []
|
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)
|
27
|
+
end
|
28
|
+
|
29
|
+
def merge_result!(path, inner_result)
|
30
|
+
return if inner_result.valid?
|
31
|
+
|
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
|
37
|
+
end
|
38
|
+
# It could have been explicitly set on inner_result (if it had no problems)
|
39
|
+
@valid = false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class Query
|
4
|
+
# Turn query string values into something useful for query execution
|
5
|
+
class LiteralInput
|
6
|
+
def self.coerce(type, ast_node, variables)
|
7
|
+
case ast_node
|
8
|
+
when nil
|
9
|
+
nil
|
10
|
+
when Language::Nodes::NullValue
|
11
|
+
nil
|
12
|
+
when Language::Nodes::VariableIdentifier
|
13
|
+
variables[ast_node.name]
|
14
|
+
else
|
15
|
+
case type.kind.name
|
16
|
+
when "SCALAR"
|
17
|
+
# TODO smell
|
18
|
+
# This gets used for plain values during subscriber.trigger
|
19
|
+
if variables
|
20
|
+
type.coerce_input(ast_node, variables.context)
|
21
|
+
else
|
22
|
+
type.coerce_isolated_input(ast_node)
|
23
|
+
end
|
24
|
+
when "ENUM"
|
25
|
+
# TODO smell
|
26
|
+
# This gets used for plain values sometimes
|
27
|
+
v = ast_node.is_a?(GraphQL::Language::Nodes::Enum) ? ast_node.name : ast_node
|
28
|
+
if variables
|
29
|
+
type.coerce_input(v, variables.context)
|
30
|
+
else
|
31
|
+
type.coerce_isolated_input(v)
|
32
|
+
end
|
33
|
+
when "NON_NULL"
|
34
|
+
LiteralInput.coerce(type.of_type, ast_node, variables)
|
35
|
+
when "LIST"
|
36
|
+
if ast_node.is_a?(Array)
|
37
|
+
ast_node.map { |element_ast| LiteralInput.coerce(type.of_type, element_ast, variables) }
|
38
|
+
else
|
39
|
+
[LiteralInput.coerce(type.of_type, ast_node, variables)]
|
40
|
+
end
|
41
|
+
when "INPUT_OBJECT"
|
42
|
+
# TODO smell: handling AST vs handling plain Ruby
|
43
|
+
next_args = ast_node.is_a?(Hash) ? ast_node : ast_node.arguments
|
44
|
+
from_arguments(next_args, type, variables)
|
45
|
+
else
|
46
|
+
raise "Invariant: unexpected type to coerce to: #{type}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.from_arguments(ast_arguments, argument_owner, variables)
|
52
|
+
context = variables ? variables.context : nil
|
53
|
+
values_hash = {}
|
54
|
+
defaults_used = Set.new
|
55
|
+
|
56
|
+
indexed_arguments = case ast_arguments
|
57
|
+
when Hash
|
58
|
+
ast_arguments
|
59
|
+
when Array
|
60
|
+
ast_arguments.each_with_object({}) { |a, memo| memo[a.name] = a }
|
61
|
+
else
|
62
|
+
raise ArgumentError, "Unexpected ast_arguments: #{ast_arguments}"
|
63
|
+
end
|
64
|
+
|
65
|
+
argument_defns = argument_owner.arguments(context || GraphQL::Query::NullContext)
|
66
|
+
argument_defns.each do |arg_name, arg_defn|
|
67
|
+
ast_arg = indexed_arguments[arg_name]
|
68
|
+
# First, check the argument in the AST.
|
69
|
+
# If the value is a variable,
|
70
|
+
# only add a value if the variable is actually present.
|
71
|
+
# Otherwise, coerce the value in the AST, prepare the value and add it.
|
72
|
+
#
|
73
|
+
# TODO: since indexed_arguments can come from a plain Ruby hash,
|
74
|
+
# have to check for `false` or `nil` as hash values. This is getting smelly :S
|
75
|
+
if indexed_arguments.key?(arg_name)
|
76
|
+
arg_value = ast_arg.is_a?(GraphQL::Language::Nodes::Argument) ? ast_arg.value : ast_arg
|
77
|
+
|
78
|
+
value_is_a_variable = arg_value.is_a?(GraphQL::Language::Nodes::VariableIdentifier)
|
79
|
+
|
80
|
+
if (!value_is_a_variable || (value_is_a_variable && variables.key?(arg_value.name)))
|
81
|
+
|
82
|
+
value = coerce(arg_defn.type, arg_value, variables)
|
83
|
+
# Legacy `prepare` application
|
84
|
+
if arg_defn.is_a?(GraphQL::Argument)
|
85
|
+
value = arg_defn.prepare(value, context)
|
86
|
+
end
|
87
|
+
|
88
|
+
if value.is_a?(GraphQL::ExecutionError)
|
89
|
+
value.ast_node = ast_arg
|
90
|
+
raise value
|
91
|
+
end
|
92
|
+
|
93
|
+
values_hash[arg_name] = value
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Then, the definition for a default value.
|
98
|
+
# If the definition has a default value and
|
99
|
+
# a value wasn't provided from the AST,
|
100
|
+
# then add the default value.
|
101
|
+
if arg_defn.default_value? && !values_hash.key?(arg_name)
|
102
|
+
value = arg_defn.default_value
|
103
|
+
defaults_used << arg_name
|
104
|
+
# `context` isn't present when pre-calculating defaults
|
105
|
+
if context
|
106
|
+
if arg_defn.is_a?(GraphQL::Argument)
|
107
|
+
value = arg_defn.prepare(value, context)
|
108
|
+
end
|
109
|
+
if value.is_a?(GraphQL::ExecutionError)
|
110
|
+
value.ast_node = ast_arg
|
111
|
+
raise value
|
112
|
+
end
|
113
|
+
end
|
114
|
+
values_hash[arg_name] = value
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
if argument_owner.is_a?(Class) || argument_owner.is_a?(GraphQL::Schema::Field)
|
119
|
+
# A Schema::InputObject, Schema::GraphQL::Field, Schema::Directive, logic from Query::Arguments#to_kwargs
|
120
|
+
ruby_kwargs = {}
|
121
|
+
values_hash.each do |key, value|
|
122
|
+
ruby_kwargs[Schema::Member::BuildType.underscore(key).to_sym] = value
|
123
|
+
end
|
124
|
+
if argument_owner.is_a?(Class) && argument_owner < GraphQL::Schema::InputObject
|
125
|
+
argument_owner.new(ruby_kwargs: ruby_kwargs, context: context, defaults_used: defaults_used)
|
126
|
+
else
|
127
|
+
ruby_kwargs
|
128
|
+
end
|
129
|
+
else
|
130
|
+
result = argument_owner.arguments_class.new(values_hash, context: context, defaults_used: defaults_used)
|
131
|
+
result.prepare
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class Query
|
4
|
+
# This object can be `ctx` in places where there is no query
|
5
|
+
class NullContext
|
6
|
+
class NullWarden < GraphQL::Schema::Warden
|
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
|
12
|
+
end
|
13
|
+
|
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
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
@query = NullQuery.new
|
27
|
+
@dataloader = GraphQL::Dataloader::NullDataloader.new
|
28
|
+
@schema = NullSchema
|
29
|
+
@warden = NullWarden.new(
|
30
|
+
GraphQL::Filter.new,
|
31
|
+
context: self,
|
32
|
+
schema: @schema,
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def [](key); end
|
37
|
+
|
38
|
+
def interpreter?
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
class << self
|
43
|
+
extend Forwardable
|
44
|
+
|
45
|
+
def [](key); end
|
46
|
+
|
47
|
+
def instance
|
48
|
+
@instance ||= self.new
|
49
|
+
end
|
50
|
+
|
51
|
+
def_delegators :instance, :query, :warden, :schema, :interpreter?, :dataloader
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
class Query
|
5
|
+
# A result from {Schema#execute}.
|
6
|
+
# It provides the requested data and
|
7
|
+
# access to the {Query} and {Query::Context}.
|
8
|
+
class Result
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def initialize(query:, values:)
|
12
|
+
@query = query
|
13
|
+
@to_h = values
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [GraphQL::Query] The query that was executed
|
17
|
+
attr_reader :query
|
18
|
+
|
19
|
+
# @return [Hash] The resulting hash of "data" and/or "errors"
|
20
|
+
attr_reader :to_h
|
21
|
+
|
22
|
+
def_delegators :@query, :context, :mutation?, :query?, :subscription?
|
23
|
+
|
24
|
+
def_delegators :@to_h, :[], :keys, :values, :to_json, :as_json
|
25
|
+
|
26
|
+
# Delegate any hash-like method to the underlying hash.
|
27
|
+
def method_missing(method_name, *args, &block)
|
28
|
+
if @to_h.respond_to?(method_name)
|
29
|
+
@to_h.public_send(method_name, *args, &block)
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def respond_to_missing?(method_name, include_private = false)
|
36
|
+
@to_h.respond_to?(method_name) || super
|
37
|
+
end
|
38
|
+
|
39
|
+
def inspect
|
40
|
+
"#<GraphQL::Query::Result @query=... @to_h=#{@to_h}>"
|
41
|
+
end
|
42
|
+
|
43
|
+
# A result is equal to another object when:
|
44
|
+
#
|
45
|
+
# - The other object is a Hash whose value matches `result.to_h`
|
46
|
+
# - The other object is a Result whose value matches `result.to_h`
|
47
|
+
#
|
48
|
+
# (The query is ignored for comparing result equality.)
|
49
|
+
#
|
50
|
+
# @return [Boolean]
|
51
|
+
def ==(other)
|
52
|
+
case other
|
53
|
+
when Hash
|
54
|
+
@to_h == other
|
55
|
+
when Query::Result
|
56
|
+
@to_h == other.to_h
|
57
|
+
else
|
58
|
+
super
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class Query
|
4
|
+
class SerialExecution
|
5
|
+
class FieldResolution
|
6
|
+
attr_reader :irep_node, :parent_type, :target, :field, :arguments, :query
|
7
|
+
|
8
|
+
def initialize(selection, parent_type, target, query_ctx)
|
9
|
+
@irep_node = selection
|
10
|
+
@selection = selection
|
11
|
+
@parent_type = parent_type
|
12
|
+
@target = target
|
13
|
+
@query = query_ctx.query
|
14
|
+
@field = irep_node.definition
|
15
|
+
@field_ctx = query_ctx.spawn_child(
|
16
|
+
key: irep_node.name,
|
17
|
+
object: target,
|
18
|
+
irep_node: irep_node,
|
19
|
+
)
|
20
|
+
@arguments = @query.arguments_for(irep_node, @field)
|
21
|
+
end
|
22
|
+
|
23
|
+
def result
|
24
|
+
result_name = irep_node.name
|
25
|
+
raw_value = get_raw_value
|
26
|
+
if raw_value.is_a?(GraphQL::Execution::Execute::Skip)
|
27
|
+
{}
|
28
|
+
else
|
29
|
+
{ result_name => get_finished_value(raw_value) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# GraphQL::Batch depends on this
|
34
|
+
def execution_context
|
35
|
+
@field_ctx
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# After getting the value from the field's resolve method,
|
41
|
+
# continue by "finishing" the value, eg. executing sub-fields or coercing values
|
42
|
+
def get_finished_value(raw_value)
|
43
|
+
case raw_value
|
44
|
+
when GraphQL::ExecutionError
|
45
|
+
raw_value.ast_node = @field_ctx.ast_node
|
46
|
+
raw_value.path = @field_ctx.path
|
47
|
+
@query.context.errors.push(raw_value)
|
48
|
+
when Array
|
49
|
+
list_errors = raw_value.each_with_index.select { |value, _| value.is_a?(GraphQL::ExecutionError) }
|
50
|
+
if list_errors.any?
|
51
|
+
list_errors.each do |error, index|
|
52
|
+
error.ast_node = @field_ctx.ast_node
|
53
|
+
error.path = @field_ctx.path + [index]
|
54
|
+
@query.context.errors.push(error)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
begin
|
60
|
+
GraphQL::Query::SerialExecution::ValueResolution.resolve(
|
61
|
+
parent_type,
|
62
|
+
field,
|
63
|
+
field.type,
|
64
|
+
raw_value,
|
65
|
+
@selection,
|
66
|
+
@field_ctx,
|
67
|
+
)
|
68
|
+
rescue GraphQL::Query::Executor::PropagateNull
|
69
|
+
if field.type.kind.non_null?
|
70
|
+
raise
|
71
|
+
else
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Get the result of:
|
78
|
+
# - Any middleware on this schema
|
79
|
+
# - The field's resolve method
|
80
|
+
# If the middleware chain returns a GraphQL::ExecutionError, its message
|
81
|
+
# is added to the "errors" key.
|
82
|
+
def get_raw_value
|
83
|
+
begin
|
84
|
+
@field_ctx.schema.middleware.invoke([parent_type, target, field, arguments, @field_ctx]) # rubocop:disable Development/ContextIsPassedCop -- unrelated
|
85
|
+
rescue GraphQL::ExecutionError => err
|
86
|
+
err
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class Query
|
4
|
+
class SerialExecution
|
5
|
+
module OperationResolution
|
6
|
+
def self.resolve(selection, target, query)
|
7
|
+
result = query.context.execution_strategy.selection_resolution.resolve(
|
8
|
+
query.root_value,
|
9
|
+
target,
|
10
|
+
selection,
|
11
|
+
query.context,
|
12
|
+
)
|
13
|
+
|
14
|
+
result
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class Query
|
4
|
+
class SerialExecution
|
5
|
+
module SelectionResolution
|
6
|
+
def self.resolve(target, current_type, selection, query_ctx)
|
7
|
+
selection_result = {}
|
8
|
+
|
9
|
+
selection.typed_children[current_type].each do |name, subselection|
|
10
|
+
selection_result.merge!(query_ctx.execution_strategy.field_resolution.new(
|
11
|
+
subselection,
|
12
|
+
current_type,
|
13
|
+
target,
|
14
|
+
query_ctx
|
15
|
+
).result)
|
16
|
+
end
|
17
|
+
|
18
|
+
selection_result
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class Query
|
4
|
+
class SerialExecution
|
5
|
+
module ValueResolution
|
6
|
+
def self.resolve(parent_type, field_defn, field_type, value, selection, query_ctx)
|
7
|
+
if value.nil? || value.is_a?(GraphQL::ExecutionError)
|
8
|
+
if field_type.kind.non_null?
|
9
|
+
if value.nil?
|
10
|
+
type_error = GraphQL::InvalidNullError.new(parent_type, field_defn, value)
|
11
|
+
query_ctx.schema.type_error(type_error, query_ctx)
|
12
|
+
end
|
13
|
+
raise GraphQL::Query::Executor::PropagateNull
|
14
|
+
else
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
else
|
18
|
+
case field_type.kind
|
19
|
+
when GraphQL::TypeKinds::SCALAR, GraphQL::TypeKinds::ENUM
|
20
|
+
field_type.coerce_result(value, query_ctx)
|
21
|
+
when GraphQL::TypeKinds::LIST
|
22
|
+
wrapped_type = field_type.of_type
|
23
|
+
result = []
|
24
|
+
i = 0
|
25
|
+
value.each do |inner_value|
|
26
|
+
inner_ctx = query_ctx.spawn_child(
|
27
|
+
key: i,
|
28
|
+
object: inner_value,
|
29
|
+
irep_node: selection,
|
30
|
+
)
|
31
|
+
|
32
|
+
result << resolve(
|
33
|
+
parent_type,
|
34
|
+
field_defn,
|
35
|
+
wrapped_type,
|
36
|
+
inner_value,
|
37
|
+
selection,
|
38
|
+
inner_ctx,
|
39
|
+
)
|
40
|
+
i += 1
|
41
|
+
end
|
42
|
+
result
|
43
|
+
when GraphQL::TypeKinds::NON_NULL
|
44
|
+
wrapped_type = field_type.of_type
|
45
|
+
resolve(
|
46
|
+
parent_type,
|
47
|
+
field_defn,
|
48
|
+
wrapped_type,
|
49
|
+
value,
|
50
|
+
selection,
|
51
|
+
query_ctx,
|
52
|
+
)
|
53
|
+
when GraphQL::TypeKinds::OBJECT
|
54
|
+
query_ctx.execution_strategy.selection_resolution.resolve(
|
55
|
+
value,
|
56
|
+
field_type,
|
57
|
+
selection,
|
58
|
+
query_ctx
|
59
|
+
)
|
60
|
+
when GraphQL::TypeKinds::UNION, GraphQL::TypeKinds::INTERFACE
|
61
|
+
query = query_ctx.query
|
62
|
+
resolved_type = query.resolve_type(value)
|
63
|
+
possible_types = query.possible_types(field_type)
|
64
|
+
|
65
|
+
if !possible_types.include?(resolved_type)
|
66
|
+
type_error = GraphQL::UnresolvedTypeError.new(value, field_defn, parent_type, resolved_type, possible_types)
|
67
|
+
query.schema.type_error(type_error, query_ctx)
|
68
|
+
raise GraphQL::Query::Executor::PropagateNull
|
69
|
+
else
|
70
|
+
resolve(
|
71
|
+
parent_type,
|
72
|
+
field_defn,
|
73
|
+
resolved_type,
|
74
|
+
value,
|
75
|
+
selection,
|
76
|
+
query_ctx,
|
77
|
+
)
|
78
|
+
end
|
79
|
+
else
|
80
|
+
raise("Unknown type kind: #{field_type.kind}")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "graphql/query/serial_execution/value_resolution"
|
3
|
+
require "graphql/query/serial_execution/field_resolution"
|
4
|
+
require "graphql/query/serial_execution/operation_resolution"
|
5
|
+
require "graphql/query/serial_execution/selection_resolution"
|
6
|
+
|
7
|
+
module GraphQL
|
8
|
+
class Query
|
9
|
+
class SerialExecution
|
10
|
+
# This is the only required method for an Execution strategy.
|
11
|
+
# You could create a custom execution strategy and configure your schema to
|
12
|
+
# use that custom strategy instead.
|
13
|
+
#
|
14
|
+
# @param ast_operation [GraphQL::Language::Nodes::OperationDefinition] The operation definition to run
|
15
|
+
# @param root_type [GraphQL::ObjectType] either the query type or the mutation type
|
16
|
+
# @param query_object [GraphQL::Query] the query object for this execution
|
17
|
+
# @return [Hash] a spec-compliant GraphQL result, as a hash
|
18
|
+
def execute(ast_operation, root_type, query_object)
|
19
|
+
GraphQL::Deprecation.warn "#{self.class} will be removed in GraphQL-Ruby 2.0, please upgrade to the Interpreter: https://graphql-ruby.org/queries/interpreter.html"
|
20
|
+
operation_resolution.resolve(
|
21
|
+
query_object.irep_selection,
|
22
|
+
root_type,
|
23
|
+
query_object
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def field_resolution
|
28
|
+
self.class::FieldResolution
|
29
|
+
end
|
30
|
+
|
31
|
+
def operation_resolution
|
32
|
+
self.class::OperationResolution
|
33
|
+
end
|
34
|
+
|
35
|
+
def selection_resolution
|
36
|
+
self.class::SelectionResolution
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|