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
@@ -1,48 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::ArgumentsAreDefined do
|
4
|
-
let(:query_string) {"
|
5
|
-
query getCheese {
|
6
|
-
cheese(id: 1) { source }
|
7
|
-
cheese(silly: false) { source }
|
8
|
-
searchDairy(product: [{wacky: 1}])
|
9
|
-
}
|
10
|
-
|
11
|
-
fragment cheeseFields on Cheese {
|
12
|
-
similarCheese(source: SHEEP, nonsense: 1)
|
13
|
-
id @skip(something: 3.4)
|
14
|
-
}
|
15
|
-
"}
|
16
|
-
|
17
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::ArgumentsAreDefined]) }
|
18
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
19
|
-
let(:errors) { validator.validate(query)[:errors] }
|
20
|
-
|
21
|
-
it "finds undefined arguments to fields and directives" do
|
22
|
-
assert_equal(4, errors.length)
|
23
|
-
|
24
|
-
query_root_error = {
|
25
|
-
"message"=>"Field 'cheese' doesn't accept argument 'silly'",
|
26
|
-
"locations"=>[{"line"=>4, "column"=>7}]
|
27
|
-
}
|
28
|
-
assert_includes(errors, query_root_error)
|
29
|
-
|
30
|
-
input_obj_record = {
|
31
|
-
"message"=>"InputObject 'DairyProductInput' doesn't accept argument 'wacky'",
|
32
|
-
"locations"=>[{"line"=>5, "column"=>29}]
|
33
|
-
}
|
34
|
-
assert_includes(errors, input_obj_record)
|
35
|
-
|
36
|
-
fragment_error = {
|
37
|
-
"message"=>"Field 'similarCheese' doesn't accept argument 'nonsense'",
|
38
|
-
"locations"=>[{"line"=>9, "column"=>7}]
|
39
|
-
}
|
40
|
-
assert_includes(errors, fragment_error)
|
41
|
-
|
42
|
-
directive_error = {
|
43
|
-
"message"=>"Directive 'skip' doesn't accept argument 'something'",
|
44
|
-
"locations"=>[{"line"=>10, "column"=>10}]
|
45
|
-
}
|
46
|
-
assert_includes(errors, directive_error)
|
47
|
-
end
|
48
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::DirectivesAreDefined do
|
4
|
-
let(:query_string) {"
|
5
|
-
query getCheese {
|
6
|
-
okCheese: cheese(id: 1) {
|
7
|
-
id @skip(if: true),
|
8
|
-
source @nonsense(if: false)
|
9
|
-
... on Cheese {
|
10
|
-
flavor @moreNonsense
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
14
|
-
"}
|
15
|
-
|
16
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::DirectivesAreDefined]) }
|
17
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
18
|
-
let(:errors) { validator.validate(query)[:errors] }
|
19
|
-
|
20
|
-
describe "non-existent directives" do
|
21
|
-
it "makes errors for them" do
|
22
|
-
expected = [
|
23
|
-
{
|
24
|
-
"message"=>"Directive @nonsense is not defined",
|
25
|
-
"locations"=>[{"line"=>5, "column"=>16}]
|
26
|
-
}, {
|
27
|
-
"message"=>"Directive @moreNonsense is not defined",
|
28
|
-
"locations"=>[{"line"=>7, "column"=>18}]
|
29
|
-
}
|
30
|
-
]
|
31
|
-
assert_equal(expected, errors)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::DirectivesAreInValidLocations do
|
4
|
-
let(:query_string) {"
|
5
|
-
query getCheese @skip(if: true) {
|
6
|
-
okCheese: cheese(id: 1) {
|
7
|
-
id @skip(if: true),
|
8
|
-
source
|
9
|
-
... on Cheese @skip(if: true) {
|
10
|
-
flavor
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
14
|
-
|
15
|
-
fragment whatever on Cheese @skip(if: true) {
|
16
|
-
id
|
17
|
-
}
|
18
|
-
"}
|
19
|
-
|
20
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::DirectivesAreInValidLocations]) }
|
21
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
22
|
-
let(:errors) { validator.validate(query)[:errors] }
|
23
|
-
|
24
|
-
describe "invalid directive locations" do
|
25
|
-
it "makes errors for them" do
|
26
|
-
expected = [
|
27
|
-
{
|
28
|
-
"message"=> "'@skip' can't be applied to queries (allowed: fields, fragment spreads, inline fragments)",
|
29
|
-
"locations"=>[{"line"=>2, "column"=>21}]
|
30
|
-
},
|
31
|
-
{
|
32
|
-
"message"=>"'@skip' can't be applied to fragment definitions (allowed: fields, fragment spreads, inline fragments)",
|
33
|
-
"locations"=>[{"line"=>12, "column"=>33}]
|
34
|
-
},
|
35
|
-
]
|
36
|
-
assert_equal(expected, errors)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::FieldsAreDefinedOnType do
|
4
|
-
let(:query_string) { "
|
5
|
-
query getCheese($sourceVar: DairyAnimal!) {
|
6
|
-
notDefinedField { name }
|
7
|
-
cheese(id: 1) { nonsenseField, flavor }
|
8
|
-
fromSource(source: COW) { bogusField }
|
9
|
-
}
|
10
|
-
|
11
|
-
fragment cheeseFields on Cheese { fatContent, hogwashField }
|
12
|
-
"}
|
13
|
-
|
14
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FieldsAreDefinedOnType]) }
|
15
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
16
|
-
let(:errors) { validator.validate(query)[:errors] }
|
17
|
-
let(:error_messages) { errors.map { |e| e["message"] } }
|
18
|
-
|
19
|
-
it "finds fields that are requested on types that don't have that field" do
|
20
|
-
expected_errors = [
|
21
|
-
"Field 'notDefinedField' doesn't exist on type 'Query'", # from query root
|
22
|
-
"Field 'nonsenseField' doesn't exist on type 'Cheese'", # from another field
|
23
|
-
"Field 'bogusField' doesn't exist on type 'Cheese'", # from a list
|
24
|
-
"Field 'hogwashField' doesn't exist on type 'Cheese'", # from a fragment
|
25
|
-
]
|
26
|
-
assert_equal(expected_errors, error_messages)
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "on interfaces" do
|
30
|
-
let(:query_string) { "query getStuff { favoriteEdible { amountThatILikeIt } }"}
|
31
|
-
|
32
|
-
it "finds invalid fields" do
|
33
|
-
expected_errors = [
|
34
|
-
{"message"=>"Field 'amountThatILikeIt' doesn't exist on type 'Edible'", "locations"=>[{"line"=>1, "column"=>18}]}
|
35
|
-
]
|
36
|
-
assert_equal(expected_errors, errors)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "on unions" do
|
41
|
-
let(:query_string) { "
|
42
|
-
query notOnUnion { favoriteEdible { ...dpFields } }
|
43
|
-
fragment dbFields on DairyProduct { source }
|
44
|
-
fragment dbIndirectFields on DairyProduct { ... on Cheese { source } }
|
45
|
-
"}
|
46
|
-
|
47
|
-
|
48
|
-
it "doesnt allow selections on unions" do
|
49
|
-
expected_errors = [
|
50
|
-
{
|
51
|
-
"message"=>"Selections can't be made directly on unions (see selections on DairyProduct)",
|
52
|
-
"locations"=>[
|
53
|
-
{"line"=>3, "column"=>7}
|
54
|
-
]
|
55
|
-
}
|
56
|
-
]
|
57
|
-
assert_equal(expected_errors, errors)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::FieldsHaveAppropriateSelections do
|
4
|
-
let(:query_string) {"
|
5
|
-
query getCheese {
|
6
|
-
okCheese: cheese(id: 1) { fatContent, similarCheese(source: YAK) { source } }
|
7
|
-
missingFieldsCheese: cheese(id: 1)
|
8
|
-
illegalSelectionCheese: cheese(id: 1) { id { something, ... someFields } }
|
9
|
-
}
|
10
|
-
"}
|
11
|
-
|
12
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FieldsHaveAppropriateSelections]) }
|
13
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
14
|
-
let(:errors) { validator.validate(query)[:errors] }
|
15
|
-
|
16
|
-
it "adds errors for selections on scalars" do
|
17
|
-
assert_equal(2, errors.length)
|
18
|
-
|
19
|
-
illegal_selection_error = {
|
20
|
-
"message"=>"Selections can't be made on scalars (field 'id' returns Int but has selections [something, someFields])",
|
21
|
-
"locations"=>[{"line"=>5, "column"=>47}]
|
22
|
-
}
|
23
|
-
assert_includes(errors, illegal_selection_error, "finds illegal selections on scalarss")
|
24
|
-
|
25
|
-
selection_required_error = {
|
26
|
-
"message"=>"Objects must have selections (field 'cheese' returns Cheese but has no selections)",
|
27
|
-
"locations"=>[{"line"=>4, "column"=>7}]
|
28
|
-
}
|
29
|
-
assert_includes(errors, selection_required_error, "finds objects without selections")
|
30
|
-
end
|
31
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::FieldsWillMerge do
|
4
|
-
let(:query_string) {"
|
5
|
-
query getCheese($sourceVar: DairyAnimal!) {
|
6
|
-
cheese(id: 1) {
|
7
|
-
id,
|
8
|
-
nickname: name,
|
9
|
-
nickname: fatContent,
|
10
|
-
fatContent
|
11
|
-
differentLevel: fatContent
|
12
|
-
similarCheese(source: $sourceVar)
|
13
|
-
|
14
|
-
similarCow: similarCheese(source: COW) {
|
15
|
-
similarCowSource: source,
|
16
|
-
differentLevel: fatContent
|
17
|
-
}
|
18
|
-
...cheeseFields
|
19
|
-
... on Cheese {
|
20
|
-
fatContent: name
|
21
|
-
similarCheese(source: SHEEP)
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
25
|
-
fragment cheeseFields on Cheese {
|
26
|
-
fatContent,
|
27
|
-
similarCow: similarCheese(source: COW) { similarCowSource: id, id }
|
28
|
-
id @someFlag
|
29
|
-
}
|
30
|
-
"}
|
31
|
-
|
32
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FieldsWillMerge]) }
|
33
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
34
|
-
let(:errors) { validator.validate(query)[:errors] }
|
35
|
-
let(:error_messages) { errors.map { |e| e["message" ] }}
|
36
|
-
|
37
|
-
it "finds field naming conflicts" do
|
38
|
-
expected_errors = [
|
39
|
-
"Field 'id' has a directive conflict: [] or [someFlag]?", # different directives
|
40
|
-
"Field 'id' has a directive argument conflict: [] or [{}]?", # not sure this is a great way to handle it but here we are!
|
41
|
-
"Field 'nickname' has a field conflict: name or fatContent?", # alias conflict in query
|
42
|
-
"Field 'fatContent' has a field conflict: fatContent or name?", # alias/name conflict in query and fragment
|
43
|
-
"Field 'similarCheese' has an argument conflict: {\"source\":\"sourceVar\"} or {\"source\":\"SHEEP\"}?", # different arguments
|
44
|
-
"Field 'similarCowSource' has a field conflict: source or id?", # nested conflict
|
45
|
-
]
|
46
|
-
assert_equal(expected_errors, error_messages)
|
47
|
-
end
|
48
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::FragmentSpreadsArePossible do
|
4
|
-
let(:query_string) {%|
|
5
|
-
query getCheese {
|
6
|
-
cheese(id: 1) {
|
7
|
-
... milkFields
|
8
|
-
... cheeseFields
|
9
|
-
... on Milk { fatContent }
|
10
|
-
... on AnimalProduct { source }
|
11
|
-
... on DairyProduct {
|
12
|
-
fatContent
|
13
|
-
... on Edible { fatContent }
|
14
|
-
}
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
fragment milkFields on Milk { fatContent }
|
19
|
-
fragment cheeseFields on Cheese {
|
20
|
-
fatContent
|
21
|
-
... milkFields
|
22
|
-
}
|
23
|
-
|}
|
24
|
-
|
25
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FragmentSpreadsArePossible]) }
|
26
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
27
|
-
let(:errors) { validator.validate(query)[:errors] }
|
28
|
-
|
29
|
-
it "doesnt allow spreads where they'll never apply" do
|
30
|
-
# TODO: more negative, abstract examples here, add stuff to the schema
|
31
|
-
expected = [
|
32
|
-
{
|
33
|
-
"message"=>"Fragment on Milk can't be spread inside Cheese",
|
34
|
-
"locations"=>[{"line"=>6, "column"=>9}]
|
35
|
-
},
|
36
|
-
{
|
37
|
-
"message"=>"Fragment milkFields on Milk can't be spread inside Cheese",
|
38
|
-
"locations"=>[{"line"=>4, "column"=>9}]
|
39
|
-
},
|
40
|
-
{
|
41
|
-
"message"=>"Fragment milkFields on Milk can't be spread inside Cheese",
|
42
|
-
"locations"=>[{"line"=>18, "column"=>7}]
|
43
|
-
}
|
44
|
-
]
|
45
|
-
assert_equal(expected, errors)
|
46
|
-
end
|
47
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::FragmentTypesExist do
|
4
|
-
let(:query_string) {"
|
5
|
-
query getCheese {
|
6
|
-
cheeese(id: 1) {
|
7
|
-
... on Cheese { source }
|
8
|
-
... on Nothing { whatever }
|
9
|
-
... somethingFields
|
10
|
-
... cheeseFields
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
fragment somethingFields on Something {
|
15
|
-
something
|
16
|
-
}
|
17
|
-
fragment cheeseFields on Cheese {
|
18
|
-
fatContent
|
19
|
-
}
|
20
|
-
"}
|
21
|
-
|
22
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FragmentTypesExist]) }
|
23
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
24
|
-
let(:errors) { validator.validate(query)[:errors] }
|
25
|
-
|
26
|
-
it "finds non-existent types on fragments" do
|
27
|
-
assert_equal(2, errors.length)
|
28
|
-
inline_fragment_error = {
|
29
|
-
"message"=>"No such type Something, so it can't be a fragment condition",
|
30
|
-
"locations"=>[{"line"=>11, "column"=>5}]
|
31
|
-
}
|
32
|
-
assert_includes(errors, inline_fragment_error, "on inline fragments")
|
33
|
-
fragment_def_error = {
|
34
|
-
"message"=>"No such type Nothing, so it can't be a fragment condition",
|
35
|
-
"locations"=>[{"line"=>5, "column"=>9}]
|
36
|
-
}
|
37
|
-
assert_includes(errors, fragment_def_error, "on fragment definitions")
|
38
|
-
end
|
39
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::FragmentsAreFinite do
|
4
|
-
let(:query_string) {%|
|
5
|
-
query getCheese {
|
6
|
-
cheese(id: 1) {
|
7
|
-
... idField
|
8
|
-
... sourceField
|
9
|
-
... flavorField
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
fragment sourceField on Cheese {
|
14
|
-
source,
|
15
|
-
... flavorField
|
16
|
-
... idField
|
17
|
-
}
|
18
|
-
fragment flavorField on Cheese {
|
19
|
-
flavor,
|
20
|
-
... sourceField
|
21
|
-
}
|
22
|
-
fragment idField on Cheese {
|
23
|
-
id
|
24
|
-
}
|
25
|
-
|}
|
26
|
-
|
27
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FragmentsAreFinite]) }
|
28
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
29
|
-
let(:errors) { validator.validate(query)[:errors] }
|
30
|
-
|
31
|
-
it "doesnt allow infinite loops" do
|
32
|
-
expected = [
|
33
|
-
{
|
34
|
-
"message"=>"Fragment sourceField contains an infinite loop",
|
35
|
-
"locations"=>[{"line"=>10, "column"=>5}]
|
36
|
-
},
|
37
|
-
{
|
38
|
-
"message"=>"Fragment flavorField contains an infinite loop",
|
39
|
-
"locations"=>[{"line"=>15, "column"=>5}]
|
40
|
-
}
|
41
|
-
]
|
42
|
-
assert_equal(expected, errors)
|
43
|
-
end
|
44
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::FragmentsAreOnCompositeTypes do
|
4
|
-
let(:query_string) {%|
|
5
|
-
query getCheese {
|
6
|
-
cheese(id: 1) {
|
7
|
-
... on Cheese {
|
8
|
-
source
|
9
|
-
... on Boolean {
|
10
|
-
something
|
11
|
-
}
|
12
|
-
}
|
13
|
-
... intFields
|
14
|
-
... on DairyProduct {
|
15
|
-
name
|
16
|
-
}
|
17
|
-
... on DairyProductInput {
|
18
|
-
something
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
fragment intFields on Int {
|
24
|
-
something
|
25
|
-
}
|
26
|
-
|}
|
27
|
-
|
28
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FragmentsAreOnCompositeTypes]) }
|
29
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
30
|
-
let(:errors) { validator.validate(query)[:errors] }
|
31
|
-
|
32
|
-
it "requires Object/Union/Interface fragment types" do
|
33
|
-
expected = [
|
34
|
-
{
|
35
|
-
"message"=>"Invalid fragment on type Boolean (must be Union, Interface or Object)",
|
36
|
-
"locations"=>[{"line"=>6, "column"=>11}]
|
37
|
-
},
|
38
|
-
{
|
39
|
-
"message"=>"Invalid fragment on type DairyProductInput (must be Union, Interface or Object)",
|
40
|
-
"locations"=>[{"line"=>14, "column"=>9}],
|
41
|
-
},
|
42
|
-
{
|
43
|
-
"message"=>"Invalid fragment on type Int (must be Union, Interface or Object)",
|
44
|
-
"locations"=>[{"line"=>20, "column"=>5}]
|
45
|
-
},
|
46
|
-
]
|
47
|
-
assert_equal(expected, errors)
|
48
|
-
end
|
49
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::FragmentsAreUsed do
|
4
|
-
let(:query_string) {"
|
5
|
-
query getCheese {
|
6
|
-
name,
|
7
|
-
...cheeseFields
|
8
|
-
...undefinedFields
|
9
|
-
}
|
10
|
-
fragment cheeseFields on Cheese { fatContent }
|
11
|
-
fragment unusedFields on Cheese { is, not, used }
|
12
|
-
"}
|
13
|
-
|
14
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FragmentsAreUsed]) }
|
15
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
16
|
-
let(:errors) { validator.validate(query)[:errors] }
|
17
|
-
|
18
|
-
it "adds errors for unused fragment definitions" do
|
19
|
-
assert_includes(errors, {"message"=>"Fragment unusedFields was defined, but not used", "locations"=>[{"line"=>8, "column"=>5}]})
|
20
|
-
end
|
21
|
-
|
22
|
-
it "adds errors for undefined fragment spreads" do
|
23
|
-
assert_includes(errors, {"message"=>"Fragment undefinedFields was used, but not defined", "locations"=>[{"line"=>5, "column"=>7}]})
|
24
|
-
end
|
25
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::RequiredArgumentsArePresent do
|
4
|
-
let(:query_string) {"
|
5
|
-
query getCheese {
|
6
|
-
cheese(id: 1) { source }
|
7
|
-
cheese { source }
|
8
|
-
}
|
9
|
-
|
10
|
-
fragment cheeseFields on Cheese {
|
11
|
-
similarCheese(id: 1)
|
12
|
-
flavor @include(if: true)
|
13
|
-
id @skip
|
14
|
-
}
|
15
|
-
"}
|
16
|
-
|
17
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::RequiredArgumentsArePresent]) }
|
18
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
19
|
-
let(:errors) { validator.validate(query)[:errors] }
|
20
|
-
|
21
|
-
it "finds undefined arguments to fields and directives" do
|
22
|
-
assert_equal(3, errors.length)
|
23
|
-
|
24
|
-
query_root_error = {
|
25
|
-
"message"=>"Field 'cheese' is missing required arguments: id",
|
26
|
-
"locations"=>[{"line"=>4, "column"=>7}]
|
27
|
-
}
|
28
|
-
assert_includes(errors, query_root_error)
|
29
|
-
|
30
|
-
fragment_error = {
|
31
|
-
"message"=>"Field 'similarCheese' is missing required arguments: source",
|
32
|
-
"locations"=>[{"line"=>8, "column"=>7}]
|
33
|
-
}
|
34
|
-
assert_includes(errors, fragment_error)
|
35
|
-
|
36
|
-
directive_error = {
|
37
|
-
"message"=>"Directive 'skip' is missing required arguments: if",
|
38
|
-
"locations"=>[{"line"=>10, "column"=>10}]
|
39
|
-
}
|
40
|
-
assert_includes(errors, directive_error)
|
41
|
-
end
|
42
|
-
end
|
data/spec/graphql/static_validation/rules/variable_default_values_are_correctly_typed_spec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTyped do
|
4
|
-
let(:query_string) {%|
|
5
|
-
query getCheese(
|
6
|
-
$id: Int = 1,
|
7
|
-
$int: Int = 3.4e24, # can be coerced
|
8
|
-
$str: String!,
|
9
|
-
$badFloat: Float = true,
|
10
|
-
$badInt: Int = "abc",
|
11
|
-
$input: DairyProductInput = {source: YAK, fatContent: 1},
|
12
|
-
$badInput: DairyProductInput = {source: YAK, fatContent: true},
|
13
|
-
$nonNull: Int! = 1,
|
14
|
-
) {
|
15
|
-
cheese(id: $id) { source }
|
16
|
-
}
|
17
|
-
|}
|
18
|
-
|
19
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTyped]) }
|
20
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
21
|
-
let(:errors) { validator.validate(query)[:errors] }
|
22
|
-
|
23
|
-
it "finds default values that don't match their types" do
|
24
|
-
expected = [
|
25
|
-
{
|
26
|
-
"message"=>"Default value for $badFloat doesn't match type Float",
|
27
|
-
"locations"=>[{"line"=>6, "column"=>7}]
|
28
|
-
},
|
29
|
-
{
|
30
|
-
"message"=>"Default value for $badInt doesn't match type Int",
|
31
|
-
"locations"=>[{"line"=>7, "column"=>7}]
|
32
|
-
},
|
33
|
-
{
|
34
|
-
"message"=>"Default value for $badInput doesn't match type DairyProductInput",
|
35
|
-
"locations"=>[{"line"=>9, "column"=>7}]
|
36
|
-
},
|
37
|
-
{
|
38
|
-
"message"=>"Non-null variable $nonNull can't have a default value",
|
39
|
-
"locations"=>[{"line"=>10, "column"=>7}]
|
40
|
-
}
|
41
|
-
]
|
42
|
-
assert_equal(expected, errors)
|
43
|
-
end
|
44
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::VariableUsagesAreAllowed do
|
4
|
-
let(:query_string) {'
|
5
|
-
query getCheese(
|
6
|
-
$goodInt: Int = 1,
|
7
|
-
$okInt: Int!,
|
8
|
-
$badInt: Int,
|
9
|
-
$badStr: String!,
|
10
|
-
$goodAnimals: [DairyAnimal!]!,
|
11
|
-
$badAnimals: [DairyAnimal]!,
|
12
|
-
$deepAnimals: [[DairyAnimal!]!]!,
|
13
|
-
$goodSource: DairyAnimal!,
|
14
|
-
) {
|
15
|
-
goodCheese: cheese(id: $goodInt) { source }
|
16
|
-
okCheese: cheese(id: $okInt) { source }
|
17
|
-
badCheese: cheese(id: $badInt) { source }
|
18
|
-
badStrCheese: cheese(id: $badStr) { source }
|
19
|
-
cheese(id: 1) {
|
20
|
-
similarCheese(source: $goodAnimals)
|
21
|
-
other: similarCheese(source: $badAnimals)
|
22
|
-
tooDeep: similarCheese(source: $deepAnimals)
|
23
|
-
nullableCheese(source: $goodAnimals)
|
24
|
-
deeplyNullableCheese(source: $deepAnimals)
|
25
|
-
}
|
26
|
-
|
27
|
-
milk(id: 1) {
|
28
|
-
flavors(limit: $okInt)
|
29
|
-
}
|
30
|
-
|
31
|
-
searchDairy(product: [{source: $goodSource}]) {
|
32
|
-
... on Cheese { id }
|
33
|
-
}
|
34
|
-
}
|
35
|
-
'}
|
36
|
-
|
37
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::VariableUsagesAreAllowed]) }
|
38
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
39
|
-
let(:errors) { validator.validate(query)[:errors] }
|
40
|
-
|
41
|
-
it "finds variables used as arguments but don't match the argument's type" do
|
42
|
-
assert_equal(4, errors.length)
|
43
|
-
expected = [
|
44
|
-
{
|
45
|
-
"message"=>"Nullability mismatch on variable $badInt and argument id (Int / Int!)",
|
46
|
-
"locations"=>[{"line"=>14, "column"=>28}]
|
47
|
-
},
|
48
|
-
{
|
49
|
-
"message"=>"Type mismatch on variable $badStr and argument id (String! / Int!)",
|
50
|
-
"locations"=>[{"line"=>15, "column"=>28}]
|
51
|
-
},
|
52
|
-
{
|
53
|
-
"message"=>"Nullability mismatch on variable $badAnimals and argument source ([DairyAnimal]! / [DairyAnimal!]!)",
|
54
|
-
"locations"=>[{"line"=>18, "column"=>30}]
|
55
|
-
},
|
56
|
-
{
|
57
|
-
"message"=>"List dimension mismatch on variable $deepAnimals and argument source ([[DairyAnimal!]!]! / [DairyAnimal!]!)",
|
58
|
-
"locations"=>[{"line"=>19, "column"=>32}]
|
59
|
-
}
|
60
|
-
]
|
61
|
-
assert_equal(expected, errors)
|
62
|
-
end
|
63
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe GraphQL::StaticValidation::VariablesAreInputTypes do
|
4
|
-
let(:query_string) {'
|
5
|
-
query getCheese(
|
6
|
-
$id: Int = 1,
|
7
|
-
$str: [String!],
|
8
|
-
$interface: AnimalProduct!,
|
9
|
-
$object: Milk = 1,
|
10
|
-
$objects: [Cheese]!,
|
11
|
-
) {
|
12
|
-
cheese(id: $id) { source }
|
13
|
-
}
|
14
|
-
'}
|
15
|
-
|
16
|
-
let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::VariablesAreInputTypes]) }
|
17
|
-
let(:query) { GraphQL::Query.new(DummySchema, query_string) }
|
18
|
-
let(:errors) { validator.validate(query)[:errors] }
|
19
|
-
|
20
|
-
it "finds variables whose types are invalid" do
|
21
|
-
expected = [
|
22
|
-
{
|
23
|
-
"message"=>"AnimalProduct isn't a valid input type (on $interface)",
|
24
|
-
"locations"=>[{"line"=>5, "column"=>7}]
|
25
|
-
},
|
26
|
-
{
|
27
|
-
"message"=>"Milk isn't a valid input type (on $object)",
|
28
|
-
"locations"=>[{"line"=>6, "column"=>7}]
|
29
|
-
},
|
30
|
-
{
|
31
|
-
"message"=>"Cheese isn't a valid input type (on $objects)",
|
32
|
-
"locations"=>[{"line"=>7, "column"=>7}]
|
33
|
-
}
|
34
|
-
]
|
35
|
-
assert_equal(expected, errors)
|
36
|
-
end
|
37
|
-
end
|