graphql 0.16.0 → 2.0.15
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 +5 -5
- data/.yardopts +5 -0
- data/lib/generators/graphql/core.rb +69 -0
- data/lib/generators/graphql/enum_generator.rb +27 -0
- 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/install/templates/base_mutation.erb +10 -0
- data/lib/generators/graphql/install/templates/mutation_type.erb +12 -0
- data/lib/generators/graphql/install_generator.rb +197 -0
- data/lib/generators/graphql/interface_generator.rb +27 -0
- data/lib/generators/graphql/loader_generator.rb +21 -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 +30 -0
- data/lib/generators/graphql/mutation_update_generator.rb +22 -0
- data/lib/generators/graphql/object_generator.rb +50 -0
- 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 +22 -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_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 +11 -0
- data/lib/generators/graphql/templates/graphql_controller.erb +52 -0
- data/lib/generators/graphql/templates/input.erb +9 -0
- data/lib/generators/graphql/templates/interface.erb +10 -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_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 +10 -0
- data/lib/generators/graphql/templates/query_type.erb +15 -0
- data/lib/generators/graphql/templates/scalar.erb +17 -0
- data/lib/generators/graphql/templates/schema.erb +30 -0
- data/lib/generators/graphql/templates/union.erb +9 -0
- data/lib/generators/graphql/type_generator.rb +135 -0
- data/lib/generators/graphql/union_generator.rb +33 -0
- data/lib/graphql/analysis/ast/analyzer.rb +84 -0
- data/lib/graphql/analysis/ast/field_usage.rb +57 -0
- data/lib/graphql/analysis/ast/max_query_complexity.rb +22 -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 +55 -0
- data/lib/graphql/analysis/ast/visitor.rb +269 -0
- data/lib/graphql/analysis/ast.rb +81 -0
- data/lib/graphql/analysis.rb +2 -5
- data/lib/graphql/analysis_error.rb +1 -0
- data/lib/graphql/backtrace/inspect_result.rb +50 -0
- data/lib/graphql/backtrace/table.rb +141 -0
- data/lib/graphql/backtrace/traced_error.rb +54 -0
- data/lib/graphql/backtrace/tracer.rb +80 -0
- data/lib/graphql/backtrace.rb +58 -0
- data/lib/graphql/coercion_error.rb +13 -0
- 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 +19 -0
- data/lib/graphql/execution/directive_checks.rb +37 -0
- data/lib/graphql/execution/errors.rb +93 -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 +105 -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 +77 -0
- data/lib/graphql/execution/interpreter/runtime.rb +994 -0
- data/lib/graphql/execution/interpreter.rb +226 -0
- data/lib/graphql/execution/lazy/lazy_method_map.rb +98 -0
- data/lib/graphql/execution/lazy.rb +75 -0
- data/lib/graphql/execution/lookahead.rb +311 -0
- data/lib/graphql/execution/multiplex.rb +45 -0
- data/lib/graphql/execution.rb +18 -0
- data/lib/graphql/execution_error.rb +34 -1
- data/lib/graphql/filter.rb +53 -0
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +36 -0
- data/lib/graphql/introspection/base_object.rb +13 -0
- data/lib/graphql/introspection/directive_location_enum.rb +12 -5
- data/lib/graphql/introspection/directive_type.rb +30 -10
- data/lib/graphql/introspection/dynamic_fields.rb +12 -0
- data/lib/graphql/introspection/entry_points.rb +22 -0
- data/lib/graphql/introspection/enum_value_type.rb +21 -8
- data/lib/graphql/introspection/field_type.rb +26 -10
- data/lib/graphql/introspection/input_value_type.rb +64 -14
- data/lib/graphql/introspection/introspection_query.rb +7 -76
- data/lib/graphql/introspection/schema_type.rb +42 -17
- data/lib/graphql/introspection/type_kind_enum.rb +11 -5
- data/lib/graphql/introspection/type_type.rb +104 -16
- data/lib/graphql/introspection.rb +104 -13
- data/lib/graphql/invalid_name_error.rb +11 -0
- data/lib/graphql/invalid_null_error.rb +36 -8
- 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 +335 -0
- data/lib/graphql/language/generation.rb +16 -86
- data/lib/graphql/language/lexer.rb +1436 -705
- data/lib/graphql/language/lexer.rl +172 -64
- data/lib/graphql/language/nodes.rb +617 -105
- data/lib/graphql/language/parser.rb +1524 -430
- data/lib/graphql/language/parser.y +348 -73
- data/lib/graphql/language/printer.rb +386 -0
- data/lib/graphql/language/sanitized_printer.rb +222 -0
- data/lib/graphql/language/token.rb +16 -3
- data/lib/graphql/language/visitor.rb +169 -25
- data/lib/graphql/language.rb +30 -0
- data/lib/graphql/load_application_object_failed_error.rb +22 -0
- data/lib/graphql/name_validator.rb +11 -0
- data/lib/graphql/pagination/active_record_relation_connection.rb +85 -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 +24 -0
- data/lib/graphql/query/context.rb +266 -12
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +34 -7
- data/lib/graphql/query/null_context.rb +52 -0
- data/lib/graphql/query/result.rb +63 -0
- data/lib/graphql/query/validation_pipeline.rb +114 -0
- data/lib/graphql/query/variable_validation_error.rb +27 -3
- data/lib/graphql/query/variables.rb +75 -24
- data/lib/graphql/query.rb +359 -92
- data/lib/graphql/railtie.rb +13 -0
- data/lib/graphql/rake_task/validate.rb +63 -0
- data/lib/graphql/rake_task.rb +146 -0
- data/lib/graphql/relay/range_add.rb +52 -0
- data/lib/graphql/relay.rb +3 -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/schema/addition.rb +245 -0
- data/lib/graphql/schema/argument.rb +395 -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 +492 -0
- data/lib/graphql/schema/built_in_types.rb +12 -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/one_of.rb +12 -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 +212 -0
- data/lib/graphql/schema/enum.rb +176 -0
- data/lib/graphql/schema/enum_value.rb +77 -0
- data/lib/graphql/schema/field/connection_extension.rb +80 -0
- data/lib/graphql/schema/field/scope_extension.rb +22 -0
- data/lib/graphql/schema/field.rb +862 -0
- data/lib/graphql/schema/field_extension.rb +156 -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 +258 -0
- data/lib/graphql/schema/interface.rb +113 -0
- data/lib/graphql/schema/introspection_system.rb +164 -0
- data/lib/graphql/schema/invalid_type_error.rb +1 -0
- data/lib/graphql/schema/late_bound_type.rb +37 -0
- data/lib/graphql/schema/list.rb +86 -0
- data/lib/graphql/schema/loader.rb +228 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +124 -0
- data/lib/graphql/schema/member/build_type.rb +178 -0
- data/lib/graphql/schema/member/graphql_type_names.rb +21 -0
- data/lib/graphql/schema/member/has_arguments.rb +376 -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 +113 -0
- data/lib/graphql/schema/member/has_fields.rb +163 -0
- data/lib/graphql/schema/member/has_interfaces.rb +88 -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/relay_shortcuts.rb +73 -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 +39 -0
- data/lib/graphql/schema/mutation.rb +85 -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 +117 -0
- data/lib/graphql/schema/printer.rb +72 -128
- data/lib/graphql/schema/relay_classic_mutation.rb +179 -0
- data/lib/graphql/schema/resolver/has_payload_type.rb +106 -0
- data/lib/graphql/schema/resolver.rb +402 -0
- data/lib/graphql/schema/scalar.rb +68 -0
- data/lib/graphql/schema/subscription.rb +148 -0
- data/lib/graphql/schema/timeout.rb +123 -0
- data/lib/graphql/schema/type_expression.rb +29 -5
- data/lib/graphql/schema/type_membership.rb +51 -0
- data/lib/graphql/schema/union.rb +81 -0
- data/lib/graphql/schema/unique_within_type.rb +34 -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 +82 -0
- data/lib/graphql/schema/validator.rb +171 -0
- data/lib/graphql/schema/warden.rb +413 -0
- data/lib/graphql/schema/wrapper.rb +24 -0
- data/lib/graphql/schema.rb +1179 -104
- data/lib/graphql/static_validation/all_rules.rb +14 -0
- data/lib/graphql/static_validation/base_visitor.rb +200 -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 +113 -22
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +59 -11
- 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 +62 -8
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +37 -0
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +20 -13
- 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 +32 -26
- 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 +21 -23
- 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 +55 -18
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +31 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +390 -70
- 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 +54 -37
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +35 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +26 -16
- data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +13 -19
- 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 +25 -20
- 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 +22 -33
- 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/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/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/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 +22 -21
- 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 +56 -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 +36 -18
- 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 +103 -39
- 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 +22 -14
- 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 +92 -70
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +37 -0
- data/lib/graphql/static_validation/type_stack.rb +85 -24
- data/lib/graphql/static_validation/validation_context.rb +25 -46
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +46 -15
- data/lib/graphql/static_validation.rb +6 -3
- data/lib/graphql/string_encoding_error.rb +20 -0
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +247 -0
- 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 +144 -0
- data/lib/graphql/subscriptions/instrumentation.rb +28 -0
- data/lib/graphql/subscriptions/serialize.rb +158 -0
- data/lib/graphql/subscriptions.rb +306 -0
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +21 -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 +100 -0
- data/lib/graphql/tracing/instrumentation_tracing.rb +83 -0
- data/lib/graphql/tracing/new_relic_tracing.rb +51 -0
- data/lib/graphql/tracing/notifications_tracing.rb +59 -0
- data/lib/graphql/tracing/platform_tracing.rb +122 -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/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +94 -0
- data/lib/graphql/type_kinds.rb +50 -22
- 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 +45 -0
- data/lib/graphql/types/iso_8601_date_time.rb +76 -0
- data/lib/graphql/types/json.rb +25 -0
- data/lib/graphql/types/relay/base_connection.rb +49 -0
- data/lib/graphql/types/relay/base_edge.rb +29 -0
- data/lib/graphql/types/relay/connection_behaviors.rb +154 -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 +15 -0
- data/lib/graphql/types/relay/node_behaviors.rb +19 -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 +39 -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/unresolved_type_error.rb +35 -0
- data/lib/graphql/version.rb +2 -1
- data/lib/graphql.rb +86 -41
- data/readme.md +15 -101
- metadata +394 -279
- data/lib/graphql/analysis/analyze_query.rb +0 -73
- data/lib/graphql/analysis/max_query_complexity.rb +0 -25
- data/lib/graphql/analysis/max_query_depth.rb +0 -25
- data/lib/graphql/analysis/query_complexity.rb +0 -122
- data/lib/graphql/analysis/query_depth.rb +0 -54
- data/lib/graphql/argument.rb +0 -25
- data/lib/graphql/base_type.rb +0 -115
- data/lib/graphql/boolean_type.rb +0 -9
- data/lib/graphql/define/assign_argument.rb +0 -20
- data/lib/graphql/define/assign_enum_value.rb +0 -16
- data/lib/graphql/define/assign_object_field.rb +0 -21
- data/lib/graphql/define/assignment_dictionary.rb +0 -26
- data/lib/graphql/define/defined_object_proxy.rb +0 -32
- data/lib/graphql/define/instance_definable.rb +0 -79
- data/lib/graphql/define/non_null_with_bang.rb +0 -15
- data/lib/graphql/define/type_definer.rb +0 -30
- data/lib/graphql/define.rb +0 -8
- data/lib/graphql/directive/include_directive.rb +0 -10
- data/lib/graphql/directive/skip_directive.rb +0 -11
- data/lib/graphql/directive.rb +0 -49
- data/lib/graphql/enum_type.rb +0 -95
- data/lib/graphql/field.rb +0 -131
- data/lib/graphql/float_type.rb +0 -5
- data/lib/graphql/id_type.rb +0 -12
- data/lib/graphql/input_object_type.rb +0 -71
- data/lib/graphql/int_type.rb +0 -5
- data/lib/graphql/interface_type.rb +0 -38
- data/lib/graphql/internal_representation/node.rb +0 -81
- data/lib/graphql/internal_representation/rewrite.rb +0 -177
- data/lib/graphql/internal_representation.rb +0 -2
- data/lib/graphql/introspection/arguments_field.rb +0 -5
- data/lib/graphql/introspection/enum_values_field.rb +0 -13
- data/lib/graphql/introspection/fields_field.rb +0 -13
- data/lib/graphql/introspection/input_fields_field.rb +0 -12
- data/lib/graphql/introspection/interfaces_field.rb +0 -5
- data/lib/graphql/introspection/of_type_field.rb +0 -6
- data/lib/graphql/introspection/possible_types_field.rb +0 -11
- data/lib/graphql/introspection/schema_field.rb +0 -15
- data/lib/graphql/introspection/type_by_name_field.rb +0 -16
- data/lib/graphql/introspection/typename_field.rb +0 -15
- data/lib/graphql/list_type.rb +0 -46
- data/lib/graphql/non_null_type.rb +0 -43
- data/lib/graphql/object_type.rb +0 -93
- data/lib/graphql/query/arguments.rb +0 -76
- data/lib/graphql/query/directive_resolution.rb +0 -16
- data/lib/graphql/query/executor.rb +0 -45
- data/lib/graphql/query/literal_input.rb +0 -90
- data/lib/graphql/query/serial_execution/execution_context.rb +0 -31
- data/lib/graphql/query/serial_execution/field_resolution.rb +0 -82
- data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -27
- data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -42
- data/lib/graphql/query/serial_execution/value_resolution.rb +0 -107
- data/lib/graphql/query/serial_execution.rb +0 -41
- data/lib/graphql/query/type_resolver.rb +0 -25
- data/lib/graphql/scalar_type.rb +0 -53
- data/lib/graphql/schema/catchall_middleware.rb +0 -34
- data/lib/graphql/schema/middleware_chain.rb +0 -28
- data/lib/graphql/schema/possible_types.rb +0 -34
- data/lib/graphql/schema/reduce_types.rb +0 -68
- data/lib/graphql/schema/rescue_middleware.rb +0 -53
- data/lib/graphql/schema/timeout_middleware.rb +0 -67
- data/lib/graphql/schema/type_map.rb +0 -30
- data/lib/graphql/schema/validation.rb +0 -164
- data/lib/graphql/static_validation/arguments_validator.rb +0 -48
- data/lib/graphql/static_validation/message.rb +0 -36
- data/lib/graphql/string_type.rb +0 -5
- data/lib/graphql/union_type.rb +0 -38
- data/spec/graphql/analysis/analyze_query_spec.rb +0 -50
- data/spec/graphql/analysis/max_query_complexity_spec.rb +0 -62
- data/spec/graphql/analysis/max_query_depth_spec.rb +0 -100
- data/spec/graphql/analysis/query_complexity_spec.rb +0 -235
- data/spec/graphql/analysis/query_depth_spec.rb +0 -80
- data/spec/graphql/argument_spec.rb +0 -20
- data/spec/graphql/base_type_spec.rb +0 -24
- data/spec/graphql/boolean_type_spec.rb +0 -20
- data/spec/graphql/define/instance_definable_spec.rb +0 -55
- data/spec/graphql/directive_spec.rb +0 -77
- data/spec/graphql/enum_type_spec.rb +0 -31
- data/spec/graphql/execution_error_spec.rb +0 -61
- data/spec/graphql/field_spec.rb +0 -92
- data/spec/graphql/float_type_spec.rb +0 -15
- data/spec/graphql/id_type_spec.rb +0 -32
- data/spec/graphql/input_object_type_spec.rb +0 -162
- data/spec/graphql/int_type_spec.rb +0 -15
- data/spec/graphql/interface_type_spec.rb +0 -56
- data/spec/graphql/internal_representation/rewrite_spec.rb +0 -120
- data/spec/graphql/introspection/directive_type_spec.rb +0 -50
- data/spec/graphql/introspection/input_value_type_spec.rb +0 -42
- data/spec/graphql/introspection/introspection_query_spec.rb +0 -10
- data/spec/graphql/introspection/schema_type_spec.rb +0 -45
- data/spec/graphql/introspection/type_type_spec.rb +0 -122
- data/spec/graphql/language/generation_spec.rb +0 -42
- data/spec/graphql/language/parser_spec.rb +0 -442
- data/spec/graphql/language/visitor_spec.rb +0 -49
- data/spec/graphql/list_type_spec.rb +0 -32
- data/spec/graphql/non_null_type_spec.rb +0 -31
- data/spec/graphql/object_type_spec.rb +0 -42
- data/spec/graphql/query/arguments_spec.rb +0 -25
- data/spec/graphql/query/context_spec.rb +0 -83
- data/spec/graphql/query/executor_spec.rb +0 -273
- data/spec/graphql/query/serial_execution/execution_context_spec.rb +0 -53
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +0 -66
- data/spec/graphql/query/type_resolver_spec.rb +0 -8
- data/spec/graphql/query/variables_spec.rb +0 -28
- data/spec/graphql/query_spec.rb +0 -363
- data/spec/graphql/scalar_type_spec.rb +0 -61
- data/spec/graphql/schema/catchall_middleware_spec.rb +0 -32
- data/spec/graphql/schema/middleware_chain_spec.rb +0 -42
- data/spec/graphql/schema/printer_spec.rb +0 -190
- data/spec/graphql/schema/reduce_types_spec.rb +0 -102
- data/spec/graphql/schema/rescue_middleware_spec.rb +0 -33
- data/spec/graphql/schema/timeout_middleware_spec.rb +0 -180
- data/spec/graphql/schema/type_expression_spec.rb +0 -38
- data/spec/graphql/schema/validation_spec.rb +0 -219
- data/spec/graphql/schema_spec.rb +0 -23
- data/spec/graphql/static_validation/rules/argument_literals_are_compatible_spec.rb +0 -63
- data/spec/graphql/static_validation/rules/arguments_are_defined_spec.rb +0 -48
- data/spec/graphql/static_validation/rules/directives_are_defined_spec.rb +0 -34
- data/spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb +0 -39
- data/spec/graphql/static_validation/rules/fields_are_defined_on_type_spec.rb +0 -60
- data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +0 -31
- data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +0 -48
- data/spec/graphql/static_validation/rules/fragment_spreads_are_possible_spec.rb +0 -47
- data/spec/graphql/static_validation/rules/fragment_types_exist_spec.rb +0 -39
- data/spec/graphql/static_validation/rules/fragments_are_finite_spec.rb +0 -44
- data/spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb +0 -49
- data/spec/graphql/static_validation/rules/fragments_are_used_spec.rb +0 -25
- data/spec/graphql/static_validation/rules/required_arguments_are_present_spec.rb +0 -42
- data/spec/graphql/static_validation/rules/variable_default_values_are_correctly_typed_spec.rb +0 -44
- data/spec/graphql/static_validation/rules/variable_usages_are_allowed_spec.rb +0 -63
- data/spec/graphql/static_validation/rules/variables_are_input_types_spec.rb +0 -37
- data/spec/graphql/static_validation/rules/variables_are_used_and_defined_spec.rb +0 -53
- data/spec/graphql/static_validation/type_stack_spec.rb +0 -37
- data/spec/graphql/static_validation/validator_spec.rb +0 -69
- data/spec/graphql/string_type_spec.rb +0 -15
- data/spec/graphql/union_type_spec.rb +0 -31
- data/spec/spec_helper.rb +0 -18
- data/spec/support/dairy_app.rb +0 -309
- data/spec/support/dairy_data.rb +0 -23
- data/spec/support/minimum_input_object.rb +0 -16
- data/spec/support/star_wars_data.rb +0 -71
- data/spec/support/star_wars_schema.rb +0 -76
data/spec/graphql/query_spec.rb
DELETED
@@ -1,363 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::Query do
|
4
|
-
let(:query_string) { %|
|
5
|
-
query getFlavor($cheeseId: Int!) {
|
6
|
-
brie: cheese(id: 1) { ...cheeseFields, taste: flavor },
|
7
|
-
cheese(id: $cheeseId) {
|
8
|
-
__typename,
|
9
|
-
id,
|
10
|
-
...cheeseFields,
|
11
|
-
... edibleFields,
|
12
|
-
... on Cheese { cheeseKind: flavor },
|
13
|
-
}
|
14
|
-
fromSource(source: COW) { id }
|
15
|
-
fromSheep: fromSource(source: SHEEP) { id }
|
16
|
-
firstSheep: searchDairy(product: [{source: SHEEP}]) {
|
17
|
-
__typename,
|
18
|
-
... dairyFields,
|
19
|
-
... milkFields
|
20
|
-
}
|
21
|
-
favoriteEdible { __typename, fatContent }
|
22
|
-
}
|
23
|
-
fragment cheeseFields on Cheese { flavor }
|
24
|
-
fragment edibleFields on Edible { fatContent }
|
25
|
-
fragment milkFields on Milk { source }
|
26
|
-
fragment dairyFields on AnimalProduct {
|
27
|
-
... on Cheese { flavor }
|
28
|
-
... on Milk { source }
|
29
|
-
}
|
30
|
-
|}
|
31
|
-
let(:operation_name) { nil }
|
32
|
-
let(:max_depth) { nil }
|
33
|
-
let(:query_variables) { {"cheeseId" => 2} }
|
34
|
-
let(:schema) { DummySchema }
|
35
|
-
let(:document) { GraphQL.parse(query_string) }
|
36
|
-
|
37
|
-
let(:query) { GraphQL::Query.new(
|
38
|
-
schema,
|
39
|
-
query_string,
|
40
|
-
variables: query_variables,
|
41
|
-
operation_name: operation_name,
|
42
|
-
max_depth: max_depth,
|
43
|
-
)}
|
44
|
-
let(:result) { query.result }
|
45
|
-
|
46
|
-
describe "when passed no query string or document" do
|
47
|
-
it 'fails with an ArgumentError' do
|
48
|
-
assert_raises(ArgumentError) {
|
49
|
-
GraphQL::Query.new(
|
50
|
-
schema,
|
51
|
-
variables: query_variables,
|
52
|
-
operation_name: operation_name,
|
53
|
-
max_depth: max_depth,
|
54
|
-
)
|
55
|
-
}
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "when passed a document instance" do
|
60
|
-
let(:query) { GraphQL::Query.new(
|
61
|
-
schema,
|
62
|
-
document: document,
|
63
|
-
variables: query_variables,
|
64
|
-
operation_name: operation_name,
|
65
|
-
max_depth: max_depth,
|
66
|
-
)}
|
67
|
-
|
68
|
-
it "runs the query using the already parsed document" do
|
69
|
-
expected = {"data"=> {
|
70
|
-
"brie" => { "flavor" => "Brie", "taste" => "Brie" },
|
71
|
-
"cheese" => {
|
72
|
-
"__typename" => "Cheese",
|
73
|
-
"id" => 2,
|
74
|
-
"flavor" => "Gouda",
|
75
|
-
"fatContent" => 0.3,
|
76
|
-
"cheeseKind" => "Gouda",
|
77
|
-
},
|
78
|
-
"fromSource" => [{ "id" => 1 }, {"id" => 2}],
|
79
|
-
"fromSheep"=>[{"id"=>3}],
|
80
|
-
"firstSheep" => { "__typename" => "Cheese", "flavor" => "Manchego" },
|
81
|
-
"favoriteEdible"=>{"__typename"=>"Milk", "fatContent"=>0.04},
|
82
|
-
}}
|
83
|
-
assert_equal(expected, result)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#result' do
|
88
|
-
it "returns fields on objects" do
|
89
|
-
expected = {"data"=> {
|
90
|
-
"brie" => { "flavor" => "Brie", "taste" => "Brie" },
|
91
|
-
"cheese" => {
|
92
|
-
"__typename" => "Cheese",
|
93
|
-
"id" => 2,
|
94
|
-
"flavor" => "Gouda",
|
95
|
-
"fatContent" => 0.3,
|
96
|
-
"cheeseKind" => "Gouda",
|
97
|
-
},
|
98
|
-
"fromSource" => [{ "id" => 1 }, {"id" => 2}],
|
99
|
-
"fromSheep"=>[{"id"=>3}],
|
100
|
-
"firstSheep" => { "__typename" => "Cheese", "flavor" => "Manchego" },
|
101
|
-
"favoriteEdible"=>{"__typename"=>"Milk", "fatContent"=>0.04},
|
102
|
-
}}
|
103
|
-
assert_equal(expected, result)
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "when it hits null objects" do
|
107
|
-
let(:query_string) {%|
|
108
|
-
{
|
109
|
-
maybeNull {
|
110
|
-
cheese {
|
111
|
-
flavor,
|
112
|
-
similarCheese(source: [SHEEP]) { flavor }
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|}
|
117
|
-
|
118
|
-
it "skips null objects" do
|
119
|
-
expected = {"data"=> {
|
120
|
-
"maybeNull" => { "cheese" => nil }
|
121
|
-
}}
|
122
|
-
assert_equal(expected, result)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
it "uses root_value as the object for the root type" do
|
128
|
-
result = GraphQL::Query.new(schema, '{ root }', root_value: "I am root").result
|
129
|
-
assert_equal 'I am root', result.fetch('data').fetch('root')
|
130
|
-
end
|
131
|
-
|
132
|
-
it "exposes fragments" do
|
133
|
-
assert_equal(GraphQL::Language::Nodes::FragmentDefinition, query.fragments["cheeseFields"].class)
|
134
|
-
end
|
135
|
-
|
136
|
-
it "exposes the original string" do
|
137
|
-
assert_equal(query_string, query.query_string)
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "merging fragments with different keys" do
|
141
|
-
let(:query_string) { %|
|
142
|
-
query getCheeseFieldsThroughDairy {
|
143
|
-
... cheeseFrag3
|
144
|
-
dairy {
|
145
|
-
...flavorFragment
|
146
|
-
...fatContentFragment
|
147
|
-
}
|
148
|
-
}
|
149
|
-
fragment flavorFragment on Dairy {
|
150
|
-
cheese {
|
151
|
-
flavor
|
152
|
-
}
|
153
|
-
milks {
|
154
|
-
id
|
155
|
-
}
|
156
|
-
}
|
157
|
-
fragment fatContentFragment on Dairy {
|
158
|
-
cheese {
|
159
|
-
fatContent
|
160
|
-
}
|
161
|
-
milks {
|
162
|
-
fatContent
|
163
|
-
}
|
164
|
-
}
|
165
|
-
|
166
|
-
fragment cheeseFrag1 on Query {
|
167
|
-
cheese(id: 1) {
|
168
|
-
id
|
169
|
-
}
|
170
|
-
}
|
171
|
-
fragment cheeseFrag2 on Query {
|
172
|
-
cheese(id: 1) {
|
173
|
-
flavor
|
174
|
-
}
|
175
|
-
}
|
176
|
-
fragment cheeseFrag3 on Query {
|
177
|
-
... cheeseFrag2
|
178
|
-
... cheeseFrag1
|
179
|
-
}
|
180
|
-
|}
|
181
|
-
|
182
|
-
it "should include keys from each fragment" do
|
183
|
-
expected = {"data" => {
|
184
|
-
"dairy" => {
|
185
|
-
"cheese" => {
|
186
|
-
"flavor" => "Brie",
|
187
|
-
"fatContent" => 0.19
|
188
|
-
},
|
189
|
-
"milks" => [
|
190
|
-
{
|
191
|
-
"id" => "1",
|
192
|
-
"fatContent" => 0.04,
|
193
|
-
}
|
194
|
-
],
|
195
|
-
},
|
196
|
-
"cheese" => {
|
197
|
-
"id" => 1,
|
198
|
-
"flavor" => "Brie"
|
199
|
-
},
|
200
|
-
}}
|
201
|
-
assert_equal(expected, result)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "field argument default values" do
|
206
|
-
let(:query_string) {%|
|
207
|
-
query getCheeses(
|
208
|
-
$search: [DairyProductInput]
|
209
|
-
$searchWithDefault: [DairyProductInput] = [{source: COW}]
|
210
|
-
){
|
211
|
-
noVariable: searchDairy(product: $search) {
|
212
|
-
... cheeseFields
|
213
|
-
}
|
214
|
-
noArgument: searchDairy {
|
215
|
-
... cheeseFields
|
216
|
-
}
|
217
|
-
variableDefault: searchDairy(product: $searchWithDefault) {
|
218
|
-
... cheeseFields
|
219
|
-
}
|
220
|
-
convertedDefault: fromSource {
|
221
|
-
... cheeseFields
|
222
|
-
}
|
223
|
-
}
|
224
|
-
fragment cheeseFields on Cheese { flavor }
|
225
|
-
|}
|
226
|
-
|
227
|
-
it "has a default value" do
|
228
|
-
default_source = schema.query.fields["searchDairy"].arguments["product"].default_value[0]["source"]
|
229
|
-
assert_equal("SHEEP", default_source)
|
230
|
-
end
|
231
|
-
|
232
|
-
describe "when a variable is used, but not provided" do
|
233
|
-
it "uses the default_value" do
|
234
|
-
assert_equal("Manchego", result["data"]["noVariable"]["flavor"])
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
describe "when the argument isn't passed at all" do
|
239
|
-
it "uses the default value" do
|
240
|
-
assert_equal("Manchego", result["data"]["noArgument"]["flavor"])
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
describe "when the variable has a default" do
|
245
|
-
it "uses the variable default" do
|
246
|
-
assert_equal("Brie", result["data"]["variableDefault"]["flavor"])
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
describe "when the variable has a default needing conversion" do
|
251
|
-
it "uses the converted variable default" do
|
252
|
-
assert_equal([{"flavor" => "Brie"}, {"flavor" => "Gouda"}], result["data"]["convertedDefault"])
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
describe "query variables" do
|
258
|
-
let(:query_string) {%|
|
259
|
-
query getCheese($cheeseId: Int!){
|
260
|
-
cheese(id: $cheeseId) { flavor }
|
261
|
-
}
|
262
|
-
|}
|
263
|
-
|
264
|
-
describe "when they can be coerced" do
|
265
|
-
let(:query_variables) { {"cheeseId" => 2.0} }
|
266
|
-
|
267
|
-
it "coerces them on the way in" do
|
268
|
-
assert("Gouda", result["data"]["cheese"]["flavor"])
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
describe "when they can't be coerced" do
|
273
|
-
let(:query_variables) { {"cheeseId" => "2"} }
|
274
|
-
|
275
|
-
it "raises an error" do
|
276
|
-
expected = {
|
277
|
-
"errors" => [
|
278
|
-
{
|
279
|
-
"message" => "Variable cheeseId of type Int! was provided invalid value",
|
280
|
-
"locations"=>[{ "line" => 2, "column" => 23 }],
|
281
|
-
"value" => "2",
|
282
|
-
"problems" => [{ "path" => [], "explanation" => 'Could not coerce value "2" to Int' }]
|
283
|
-
}
|
284
|
-
]
|
285
|
-
}
|
286
|
-
assert_equal(expected, result)
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
describe "when they aren't provided" do
|
291
|
-
let(:query_variables) { {} }
|
292
|
-
|
293
|
-
it "raises an error" do
|
294
|
-
expected = {
|
295
|
-
"errors" => [
|
296
|
-
{
|
297
|
-
"message" => "Variable cheeseId of type Int! was provided invalid value",
|
298
|
-
"locations" => [{"line" => 2, "column" => 23}],
|
299
|
-
"value" => nil,
|
300
|
-
"problems" => [{ "path" => [], "explanation" => "Expected value to not be null" }]
|
301
|
-
}
|
302
|
-
]
|
303
|
-
}
|
304
|
-
assert_equal(expected, result)
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
describe "default values" do
|
309
|
-
let(:query_string) {%|
|
310
|
-
query getCheese($cheeseId: Int = 3){
|
311
|
-
cheese(id: $cheeseId) { id, flavor }
|
312
|
-
}
|
313
|
-
|}
|
314
|
-
|
315
|
-
describe "when no value is provided" do
|
316
|
-
let(:query_variables) { {} }
|
317
|
-
|
318
|
-
it "uses the default" do
|
319
|
-
assert(3, result["data"]["cheese"]["id"])
|
320
|
-
assert("Manchego", result["data"]["cheese"]["flavor"])
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
describe "when a value is provided" do
|
325
|
-
it "uses the provided variable" do
|
326
|
-
assert(2, result["data"]["cheese"]["id"])
|
327
|
-
assert("Gouda", result["data"]["cheese"]["flavor"])
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
describe "when complex values" do
|
332
|
-
let(:query_variables) { {"search" => [{"source" => "COW"}]} }
|
333
|
-
let(:query_string) {%|
|
334
|
-
query getCheeses($search: [DairyProductInput]!){
|
335
|
-
cow: searchDairy(product: $search) {
|
336
|
-
... on Cheese {
|
337
|
-
flavor
|
338
|
-
}
|
339
|
-
}
|
340
|
-
}
|
341
|
-
|}
|
342
|
-
|
343
|
-
it "coerces recursively" do
|
344
|
-
assert_equal("Brie", result["data"]["cow"]["flavor"])
|
345
|
-
end
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
describe "#max_depth" do
|
351
|
-
it "defaults to the schema's max_depth" do
|
352
|
-
assert_equal 5, query.max_depth
|
353
|
-
end
|
354
|
-
|
355
|
-
describe "overriding max_depth" do
|
356
|
-
let(:max_depth) { 12 }
|
357
|
-
|
358
|
-
it "overrides the schema's max_depth" do
|
359
|
-
assert_equal 12, query.max_depth
|
360
|
-
end
|
361
|
-
end
|
362
|
-
end
|
363
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::ScalarType do
|
4
|
-
let(:custom_scalar) {
|
5
|
-
GraphQL::ScalarType.define do
|
6
|
-
name "BigInt"
|
7
|
-
coerce_input ->(value) { value =~ /\d+/ ? Integer(value) : nil }
|
8
|
-
coerce_result ->(value) { value.to_s }
|
9
|
-
end
|
10
|
-
}
|
11
|
-
let(:bignum) { 2 ** 128 }
|
12
|
-
|
13
|
-
it "coerces nil into nil" do
|
14
|
-
assert_equal(nil, custom_scalar.coerce_input(nil))
|
15
|
-
end
|
16
|
-
|
17
|
-
it "coerces input into objects" do
|
18
|
-
assert_equal(bignum, custom_scalar.coerce_input(bignum.to_s))
|
19
|
-
end
|
20
|
-
|
21
|
-
it "coerces result value for serialization" do
|
22
|
-
assert_equal(bignum.to_s, custom_scalar.coerce_result(bignum))
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "custom scalar errors" do
|
26
|
-
let(:result) { custom_scalar.validate_input("xyz") }
|
27
|
-
|
28
|
-
it "returns an invalid result" do
|
29
|
-
assert !result.valid?
|
30
|
-
assert_equal 'Could not coerce value "xyz" to BigInt', result.problems[0]["explanation"]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "validate_input with good input" do
|
35
|
-
let(:result) { GraphQL::INT_TYPE.validate_input(150) }
|
36
|
-
|
37
|
-
it "returns a valid result" do
|
38
|
-
assert(result.valid?)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "validate_input with bad input" do
|
43
|
-
let(:result) { GraphQL::INT_TYPE.validate_input("bad num") }
|
44
|
-
|
45
|
-
it "returns an invalid result for bad input" do
|
46
|
-
assert(!result.valid?)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "has one problem" do
|
50
|
-
assert_equal(result.problems.length, 1)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "has the correct explanation" do
|
54
|
-
assert(result.problems[0]["explanation"].include?("Could not coerce value"))
|
55
|
-
end
|
56
|
-
|
57
|
-
it "has an empty path" do
|
58
|
-
assert(result.problems[0]["path"].empty?)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::Schema::CatchallMiddleware do
|
4
|
-
let(:result) { DummySchema.execute(query_string) }
|
5
|
-
let(:query_string) {%| query noMilk { error }|}
|
6
|
-
|
7
|
-
before do
|
8
|
-
DummySchema.middleware << GraphQL::Schema::CatchallMiddleware
|
9
|
-
end
|
10
|
-
|
11
|
-
after do
|
12
|
-
DummySchema.middleware.delete(GraphQL::Schema::CatchallMiddleware)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "rescuing errors" do
|
16
|
-
let(:errors) { query.context.errors }
|
17
|
-
|
18
|
-
it "turns into error messages" do
|
19
|
-
expected = {
|
20
|
-
"data" => { "error" => nil },
|
21
|
-
"errors"=> [
|
22
|
-
{
|
23
|
-
"message"=>"Internal error",
|
24
|
-
"locations"=>[{"line"=>1, "column"=>17}],
|
25
|
-
},
|
26
|
-
]
|
27
|
-
}
|
28
|
-
assert_equal(expected, result)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::Schema::MiddlewareChain do
|
4
|
-
let(:step_1) { -> (step_values, next_step) { step_values << 1; next_step.call } }
|
5
|
-
let(:step_2) { -> (step_values, next_step) { step_values << 2; next_step.call } }
|
6
|
-
let(:step_3) { -> (step_values, next_step) { step_values << 3; :return_value } }
|
7
|
-
let(:steps) { [step_1, step_2, step_3] }
|
8
|
-
let(:step_values) { [] }
|
9
|
-
let(:arguments) { [step_values] }
|
10
|
-
let(:middleware_chain) { GraphQL::Schema::MiddlewareChain.new(steps: steps, arguments: arguments)}
|
11
|
-
|
12
|
-
describe "#call" do
|
13
|
-
it "runs steps in order" do
|
14
|
-
middleware_chain.call
|
15
|
-
assert_equal([1,2,3], step_values)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns the value of the last middleware" do
|
19
|
-
assert_equal(:return_value, middleware_chain.call)
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "when a step returns early" do
|
23
|
-
let(:early_return_step) { -> (step_values, next_step) { :early_return } }
|
24
|
-
it "doesn't continue the chain" do
|
25
|
-
steps.insert(2, early_return_step)
|
26
|
-
assert_equal(:early_return, middleware_chain.call)
|
27
|
-
assert_equal([1,2], step_values)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "when a step provides alternate arguments" do
|
32
|
-
it "passes the new arguments to the next step" do
|
33
|
-
step_1 = -> (test_arg, next_step) { assert_equal(test_arg, 'HELLO'); next_step.call(['WORLD']) }
|
34
|
-
step_2 = -> (test_arg, next_step) { assert_equal(test_arg, 'WORLD'); test_arg }
|
35
|
-
|
36
|
-
chain = GraphQL::Schema::MiddlewareChain.new(steps: [step_1, step_2], arguments: ['HELLO'])
|
37
|
-
result = chain.call
|
38
|
-
assert_equal(result, 'WORLD')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,190 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::Schema::Printer do
|
4
|
-
let(:schema) {
|
5
|
-
node_type = GraphQL::InterfaceType.define do
|
6
|
-
name "Node"
|
7
|
-
|
8
|
-
field :id, !types.ID
|
9
|
-
end
|
10
|
-
|
11
|
-
choice_type = GraphQL::EnumType.define do
|
12
|
-
name "Choice"
|
13
|
-
|
14
|
-
value "FOO"
|
15
|
-
value "BAR"
|
16
|
-
end
|
17
|
-
|
18
|
-
sub_input_type = GraphQL::InputObjectType.define do
|
19
|
-
name "Sub"
|
20
|
-
input_field :string, types.String
|
21
|
-
end
|
22
|
-
|
23
|
-
variant_input_type = GraphQL::InputObjectType.define do
|
24
|
-
name "Varied"
|
25
|
-
input_field :id, types.ID
|
26
|
-
input_field :int, types.Int
|
27
|
-
input_field :float, types.Float
|
28
|
-
input_field :bool, types.Boolean
|
29
|
-
input_field :enum, choice_type
|
30
|
-
input_field :sub, types[sub_input_type]
|
31
|
-
end
|
32
|
-
|
33
|
-
comment_type = GraphQL::ObjectType.define do
|
34
|
-
name "Comment"
|
35
|
-
description "A blog comment"
|
36
|
-
interfaces [node_type]
|
37
|
-
|
38
|
-
field :id, !types.ID
|
39
|
-
end
|
40
|
-
|
41
|
-
post_type = GraphQL::ObjectType.define do
|
42
|
-
name "Post"
|
43
|
-
description "A blog post"
|
44
|
-
|
45
|
-
field :id, !types.ID
|
46
|
-
field :title, !types.String
|
47
|
-
field :body, !types.String
|
48
|
-
field :comments, types[!comment_type]
|
49
|
-
end
|
50
|
-
|
51
|
-
query_root = GraphQL::ObjectType.define do
|
52
|
-
name "Query"
|
53
|
-
description "The query root of this schema"
|
54
|
-
|
55
|
-
field :post do
|
56
|
-
type post_type
|
57
|
-
argument :id, !types.ID
|
58
|
-
argument :varied, variant_input_type, default_value: { id: "123", int: 234, float: 2.3, enum: "FOO", sub: [{ string: "str" }] }
|
59
|
-
resolve -> (obj, args, ctx) { Post.find(args["id"]) }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
GraphQL::Schema.new(query: query_root)
|
64
|
-
}
|
65
|
-
|
66
|
-
describe ".print_introspection_schema" do
|
67
|
-
it "returns the schema as a string for the introspection types" do
|
68
|
-
expected = <<SCHEMA
|
69
|
-
type __Directive {
|
70
|
-
name: String!
|
71
|
-
description: String
|
72
|
-
args: [__InputValue!]!
|
73
|
-
locations: [__DirectiveLocation!]!
|
74
|
-
onOperation: Boolean!
|
75
|
-
onFragment: Boolean!
|
76
|
-
onField: Boolean!
|
77
|
-
}
|
78
|
-
|
79
|
-
enum __DirectiveLocation {
|
80
|
-
QUERY
|
81
|
-
MUTATION
|
82
|
-
SUBSCRIPTION
|
83
|
-
FIELD
|
84
|
-
FRAGMENT_DEFINITION
|
85
|
-
FRAGMENT_SPREAD
|
86
|
-
INLINE_FRAGMENT
|
87
|
-
}
|
88
|
-
|
89
|
-
type __EnumValue {
|
90
|
-
name: String!
|
91
|
-
description: String
|
92
|
-
deprecationReason: String
|
93
|
-
isDeprecated: Boolean!
|
94
|
-
}
|
95
|
-
|
96
|
-
type __Field {
|
97
|
-
name: String!
|
98
|
-
description: String
|
99
|
-
type: __Type!
|
100
|
-
isDeprecated: Boolean!
|
101
|
-
args: [__InputValue!]!
|
102
|
-
deprecationReason: String
|
103
|
-
}
|
104
|
-
|
105
|
-
type __InputValue {
|
106
|
-
name: String!
|
107
|
-
description: String
|
108
|
-
type: __Type!
|
109
|
-
defaultValue: String
|
110
|
-
}
|
111
|
-
|
112
|
-
type __Schema {
|
113
|
-
types: [__Type!]!
|
114
|
-
directives: [__Directive!]!
|
115
|
-
queryType: __Type!
|
116
|
-
mutationType: __Type
|
117
|
-
subscriptionType: __Type
|
118
|
-
}
|
119
|
-
|
120
|
-
type __Type {
|
121
|
-
name: String
|
122
|
-
description: String
|
123
|
-
kind: __TypeKind!
|
124
|
-
fields(includeDeprecated: Boolean = false): [__Field!]
|
125
|
-
ofType: __Type
|
126
|
-
inputFields: [__InputValue!]
|
127
|
-
possibleTypes: [__Type!]
|
128
|
-
enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
|
129
|
-
interfaces: [__Type!]
|
130
|
-
}
|
131
|
-
|
132
|
-
enum __TypeKind {
|
133
|
-
SCALAR
|
134
|
-
OBJECT
|
135
|
-
INTERFACE
|
136
|
-
UNION
|
137
|
-
ENUM
|
138
|
-
INPUT_OBJECT
|
139
|
-
LIST
|
140
|
-
NON_NULL
|
141
|
-
}
|
142
|
-
SCHEMA
|
143
|
-
assert_equal expected.chomp, GraphQL::Schema::Printer.print_introspection_schema
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe ".print_schema" do
|
148
|
-
it "returns the schema as a string for the defined types" do
|
149
|
-
expected = <<SCHEMA
|
150
|
-
enum Choice {
|
151
|
-
FOO
|
152
|
-
BAR
|
153
|
-
}
|
154
|
-
|
155
|
-
type Comment implements Node {
|
156
|
-
id: ID!
|
157
|
-
}
|
158
|
-
|
159
|
-
interface Node {
|
160
|
-
id: ID!
|
161
|
-
}
|
162
|
-
|
163
|
-
type Post {
|
164
|
-
id: ID!
|
165
|
-
title: String!
|
166
|
-
body: String!
|
167
|
-
comments: [Comment!]
|
168
|
-
}
|
169
|
-
|
170
|
-
type Query {
|
171
|
-
post(id: ID!, varied: Varied = { id: \"123\", int: 234, float: 2.3, enum: FOO, sub: [{ string: \"str\" }] }): Post
|
172
|
-
}
|
173
|
-
|
174
|
-
input Sub {
|
175
|
-
string: String
|
176
|
-
}
|
177
|
-
|
178
|
-
input Varied {
|
179
|
-
id: ID
|
180
|
-
int: Int
|
181
|
-
float: Float
|
182
|
-
bool: Boolean
|
183
|
-
enum: Choice
|
184
|
-
sub: [Sub]
|
185
|
-
}
|
186
|
-
SCHEMA
|
187
|
-
assert_equal expected.chomp, GraphQL::Schema::Printer.print_schema(schema)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|