graphql 1.9.21 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/generators/graphql/core.rb +21 -10
- data/lib/generators/graphql/enum_generator.rb +4 -10
- data/lib/generators/graphql/field_extractor.rb +31 -0
- data/lib/generators/graphql/input_generator.rb +50 -0
- data/lib/generators/graphql/install/mutation_root_generator.rb +34 -0
- data/lib/generators/graphql/{templates → install/templates}/base_mutation.erb +2 -0
- data/lib/generators/graphql/{templates → install/templates}/mutation_type.erb +2 -0
- data/lib/generators/graphql/install_generator.rb +45 -8
- data/lib/generators/graphql/interface_generator.rb +7 -7
- data/lib/generators/graphql/loader_generator.rb +1 -0
- data/lib/generators/graphql/mutation_create_generator.rb +22 -0
- data/lib/generators/graphql/mutation_delete_generator.rb +22 -0
- data/lib/generators/graphql/mutation_generator.rb +6 -30
- data/lib/generators/graphql/mutation_update_generator.rb +22 -0
- data/lib/generators/graphql/object_generator.rb +28 -12
- data/lib/generators/graphql/orm_mutations_base.rb +40 -0
- data/lib/generators/graphql/relay.rb +49 -0
- data/lib/generators/graphql/relay_generator.rb +21 -0
- data/lib/generators/graphql/scalar_generator.rb +4 -2
- data/lib/generators/graphql/templates/base_argument.erb +2 -0
- data/lib/generators/graphql/templates/base_connection.erb +8 -0
- data/lib/generators/graphql/templates/base_edge.erb +8 -0
- data/lib/generators/graphql/templates/base_enum.erb +2 -0
- data/lib/generators/graphql/templates/base_field.erb +2 -0
- data/lib/generators/graphql/templates/base_input_object.erb +2 -0
- data/lib/generators/graphql/templates/base_interface.erb +2 -0
- data/lib/generators/graphql/templates/base_object.erb +2 -0
- data/lib/generators/graphql/templates/base_scalar.erb +2 -0
- data/lib/generators/graphql/templates/base_union.erb +2 -0
- data/lib/generators/graphql/templates/enum.erb +7 -1
- data/lib/generators/graphql/templates/graphql_controller.erb +16 -12
- data/lib/generators/graphql/templates/input.erb +9 -0
- data/lib/generators/graphql/templates/interface.erb +6 -2
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +3 -1
- data/lib/generators/graphql/templates/mutation_create.erb +20 -0
- data/lib/generators/graphql/templates/mutation_delete.erb +20 -0
- data/lib/generators/graphql/templates/mutation_update.erb +21 -0
- data/lib/generators/graphql/templates/node_type.erb +9 -0
- data/lib/generators/graphql/templates/object.erb +7 -3
- data/lib/generators/graphql/templates/query_type.erb +3 -3
- data/lib/generators/graphql/templates/scalar.erb +5 -1
- data/lib/generators/graphql/templates/schema.erb +25 -27
- data/lib/generators/graphql/templates/union.erb +6 -2
- data/lib/generators/graphql/type_generator.rb +47 -10
- data/lib/generators/graphql/union_generator.rb +5 -5
- data/lib/graphql/analysis/ast/field_usage.rb +31 -2
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -1
- data/lib/graphql/analysis/ast/query_complexity.rb +175 -68
- data/lib/graphql/analysis/ast/query_depth.rb +0 -1
- data/lib/graphql/analysis/ast/visitor.rb +17 -8
- data/lib/graphql/analysis/ast.rb +14 -14
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/table.rb +37 -16
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +39 -9
- data/lib/graphql/backtrace.rb +20 -17
- data/lib/graphql/dataloader/null_dataloader.rb +24 -0
- data/lib/graphql/dataloader/request.rb +19 -0
- data/lib/graphql/dataloader/request_all.rb +19 -0
- data/lib/graphql/dataloader/source.rb +164 -0
- data/lib/graphql/dataloader.rb +311 -0
- data/lib/graphql/date_encoding_error.rb +16 -0
- data/lib/graphql/deprecation.rb +9 -0
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/directive_checks.rb +2 -2
- data/lib/graphql/execution/errors.rb +77 -45
- data/lib/graphql/execution/interpreter/argument_value.rb +28 -0
- data/lib/graphql/execution/interpreter/arguments.rb +88 -0
- data/lib/graphql/execution/interpreter/arguments_cache.rb +105 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
- data/lib/graphql/execution/interpreter/resolve.rb +44 -25
- data/lib/graphql/execution/interpreter/runtime.rb +755 -395
- data/lib/graphql/execution/interpreter.rb +201 -74
- data/lib/graphql/execution/lazy/lazy_method_map.rb +4 -0
- data/lib/graphql/execution/lazy.rb +5 -9
- data/lib/graphql/execution/lookahead.rb +65 -136
- data/lib/graphql/execution/multiplex.rb +5 -152
- data/lib/graphql/execution.rb +11 -4
- data/lib/graphql/filter.rb +1 -1
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +18 -2
- data/lib/graphql/introspection/base_object.rb +2 -5
- data/lib/graphql/introspection/directive_location_enum.rb +2 -2
- data/lib/graphql/introspection/directive_type.rb +11 -5
- data/lib/graphql/introspection/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +5 -18
- data/lib/graphql/introspection/enum_value_type.rb +2 -2
- data/lib/graphql/introspection/field_type.rb +9 -5
- data/lib/graphql/introspection/input_value_type.rb +41 -11
- data/lib/graphql/introspection/introspection_query.rb +6 -92
- data/lib/graphql/introspection/schema_type.rb +10 -10
- data/lib/graphql/introspection/type_type.rb +34 -17
- data/lib/graphql/introspection.rb +100 -0
- data/lib/graphql/invalid_null_error.rb +18 -0
- data/lib/graphql/language/block_string.rb +20 -5
- data/lib/graphql/language/cache.rb +37 -0
- data/lib/graphql/language/definition_slice.rb +21 -10
- data/lib/graphql/language/document_from_schema_definition.rb +104 -68
- data/lib/graphql/language/lexer.rb +83 -40
- data/lib/graphql/language/lexer.rl +31 -9
- data/lib/graphql/language/nodes.rb +64 -93
- data/lib/graphql/language/parser.rb +940 -896
- data/lib/graphql/language/parser.y +130 -103
- data/lib/graphql/language/printer.rb +48 -23
- data/lib/graphql/language/sanitized_printer.rb +222 -0
- data/lib/graphql/language/token.rb +0 -4
- data/lib/graphql/language/visitor.rb +2 -2
- data/lib/graphql/language.rb +3 -1
- data/lib/graphql/name_validator.rb +2 -7
- data/lib/graphql/pagination/active_record_relation_connection.rb +85 -0
- data/lib/graphql/pagination/array_connection.rb +79 -0
- data/lib/graphql/pagination/connection.rb +253 -0
- data/lib/graphql/pagination/connections.rb +135 -0
- data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
- data/lib/graphql/pagination/relation_connection.rb +228 -0
- data/lib/graphql/pagination/sequel_dataset_connection.rb +28 -0
- data/lib/graphql/pagination.rb +6 -0
- data/lib/graphql/parse_error.rb +0 -1
- data/lib/graphql/query/context.rb +172 -198
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +33 -7
- data/lib/graphql/query/null_context.rb +21 -8
- data/lib/graphql/query/validation_pipeline.rb +16 -38
- data/lib/graphql/query/variable_validation_error.rb +3 -3
- data/lib/graphql/query/variables.rb +39 -12
- data/lib/graphql/query.rb +74 -38
- data/lib/graphql/railtie.rb +6 -102
- data/lib/graphql/rake_task/validate.rb +4 -1
- data/lib/graphql/rake_task.rb +41 -10
- data/lib/graphql/relay/range_add.rb +17 -10
- data/lib/graphql/relay.rb +0 -15
- data/lib/graphql/rubocop/graphql/base_cop.rb +36 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +43 -0
- data/lib/graphql/rubocop/graphql/default_required_true.rb +43 -0
- data/lib/graphql/rubocop.rb +4 -0
- data/lib/graphql/schema/addition.rb +245 -0
- data/lib/graphql/schema/argument.rb +286 -31
- data/lib/graphql/schema/base_64_encoder.rb +2 -0
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -1
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +13 -5
- data/lib/graphql/schema/build_from_definition.rb +334 -220
- data/lib/graphql/schema/built_in_types.rb +5 -5
- data/lib/graphql/schema/directive/deprecated.rb +18 -0
- data/lib/graphql/schema/directive/feature.rb +1 -1
- data/lib/graphql/schema/directive/flagged.rb +57 -0
- data/lib/graphql/schema/directive/include.rb +2 -2
- data/lib/graphql/schema/directive/one_of.rb +12 -0
- data/lib/graphql/schema/directive/skip.rb +2 -2
- data/lib/graphql/schema/directive/transform.rb +14 -2
- data/lib/graphql/schema/directive.rb +117 -14
- data/lib/graphql/schema/enum.rb +113 -22
- data/lib/graphql/schema/enum_value.rb +16 -21
- data/lib/graphql/schema/field/connection_extension.rb +50 -20
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +491 -329
- data/lib/graphql/schema/field_extension.rb +89 -2
- data/lib/graphql/schema/find_inherited_value.rb +17 -1
- data/lib/graphql/schema/finder.rb +16 -14
- data/lib/graphql/schema/input_object.rb +182 -60
- data/lib/graphql/schema/interface.rb +28 -43
- data/lib/graphql/schema/introspection_system.rb +101 -38
- data/lib/graphql/schema/late_bound_type.rb +7 -2
- data/lib/graphql/schema/list.rb +61 -3
- data/lib/graphql/schema/loader.rb +144 -102
- data/lib/graphql/schema/member/base_dsl_methods.rb +33 -32
- data/lib/graphql/schema/member/build_type.rb +24 -15
- data/lib/graphql/schema/member/has_arguments.rb +261 -24
- 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 +99 -34
- data/lib/graphql/schema/member/has_interfaces.rb +88 -0
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
- data/lib/graphql/schema/member/has_validators.rb +31 -0
- data/lib/graphql/schema/member/relay_shortcuts.rb +28 -2
- data/lib/graphql/schema/member/type_system_helpers.rb +3 -3
- data/lib/graphql/schema/member/validates_input.rb +33 -0
- data/lib/graphql/schema/member.rb +11 -6
- data/lib/graphql/schema/mutation.rb +4 -9
- data/lib/graphql/schema/non_null.rb +34 -4
- data/lib/graphql/schema/object.rb +38 -60
- data/lib/graphql/schema/printer.rb +16 -35
- data/lib/graphql/schema/relay_classic_mutation.rb +90 -43
- data/lib/graphql/schema/resolver/has_payload_type.rb +46 -6
- data/lib/graphql/schema/resolver.rb +146 -93
- data/lib/graphql/schema/scalar.rb +40 -15
- data/lib/graphql/schema/subscription.rb +55 -26
- data/lib/graphql/schema/timeout.rb +29 -15
- data/lib/graphql/schema/type_expression.rb +21 -13
- data/lib/graphql/schema/type_membership.rb +22 -5
- data/lib/graphql/schema/union.rb +48 -14
- data/lib/graphql/schema/unique_within_type.rb +1 -2
- data/lib/graphql/schema/validator/allow_blank_validator.rb +29 -0
- data/lib/graphql/schema/validator/allow_null_validator.rb +26 -0
- data/lib/graphql/schema/validator/exclusion_validator.rb +33 -0
- data/lib/graphql/schema/validator/format_validator.rb +48 -0
- data/lib/graphql/schema/validator/inclusion_validator.rb +35 -0
- data/lib/graphql/schema/validator/length_validator.rb +59 -0
- data/lib/graphql/schema/validator/numericality_validator.rb +82 -0
- data/lib/graphql/schema/validator/required_validator.rb +82 -0
- data/lib/graphql/schema/validator.rb +171 -0
- data/lib/graphql/schema/warden.rb +187 -33
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +773 -892
- data/lib/graphql/static_validation/all_rules.rb +3 -0
- data/lib/graphql/static_validation/base_visitor.rb +21 -31
- data/lib/graphql/static_validation/definition_dependencies.rb +7 -2
- data/lib/graphql/static_validation/error.rb +3 -1
- data/lib/graphql/static_validation/literal_validator.rb +55 -26
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +45 -83
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +22 -6
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +35 -26
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +4 -2
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +12 -6
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +14 -14
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +4 -4
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +5 -5
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +94 -51
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +25 -4
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -2
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +30 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +30 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +66 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -0
- data/lib/graphql/static_validation/rules/query_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/query_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +4 -2
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +9 -10
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +13 -7
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +12 -13
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +19 -14
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +5 -3
- data/lib/graphql/static_validation/type_stack.rb +2 -2
- data/lib/graphql/static_validation/validation_context.rb +13 -3
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +31 -19
- data/lib/graphql/static_validation.rb +1 -2
- data/lib/graphql/string_encoding_error.rb +13 -3
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +129 -22
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +81 -0
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +58 -0
- data/lib/graphql/subscriptions/event.rb +85 -31
- data/lib/graphql/subscriptions/instrumentation.rb +0 -47
- data/lib/graphql/subscriptions/serialize.rb +53 -6
- data/lib/graphql/subscriptions.rb +137 -57
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +8 -17
- data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
- data/lib/graphql/tracing/appsignal_tracing.rb +23 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +34 -2
- data/lib/graphql/tracing/new_relic_tracing.rb +9 -12
- data/lib/graphql/tracing/notifications_tracing.rb +59 -0
- data/lib/graphql/tracing/platform_tracing.rb +67 -38
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +4 -1
- data/lib/graphql/tracing/prometheus_tracing.rb +8 -0
- data/lib/graphql/tracing/scout_tracing.rb +19 -0
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +15 -36
- data/lib/graphql/types/big_int.rb +5 -1
- data/lib/graphql/types/int.rb +10 -3
- data/lib/graphql/types/iso_8601_date.rb +20 -9
- data/lib/graphql/types/iso_8601_date_time.rb +36 -10
- data/lib/graphql/types/relay/base_connection.rb +18 -90
- data/lib/graphql/types/relay/base_edge.rb +2 -34
- data/lib/graphql/types/relay/connection_behaviors.rb +158 -0
- data/lib/graphql/types/relay/default_relay.rb +27 -0
- data/lib/graphql/types/relay/edge_behaviors.rb +65 -0
- data/lib/graphql/types/relay/has_node_field.rb +41 -0
- data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
- data/lib/graphql/types/relay/node.rb +2 -4
- data/lib/graphql/types/relay/node_behaviors.rb +19 -0
- data/lib/graphql/types/relay/page_info.rb +2 -14
- data/lib/graphql/types/relay/page_info_behaviors.rb +25 -0
- data/lib/graphql/types/relay.rb +11 -5
- data/lib/graphql/types/string.rb +8 -2
- data/lib/graphql/unauthorized_error.rb +2 -2
- data/lib/graphql/unresolved_type_error.rb +2 -2
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +41 -58
- data/readme.md +3 -6
- metadata +103 -237
- data/lib/graphql/analysis/analyze_query.rb +0 -91
- data/lib/graphql/analysis/field_usage.rb +0 -45
- data/lib/graphql/analysis/max_query_complexity.rb +0 -26
- data/lib/graphql/analysis/max_query_depth.rb +0 -26
- data/lib/graphql/analysis/query_complexity.rb +0 -88
- data/lib/graphql/analysis/query_depth.rb +0 -43
- data/lib/graphql/analysis/reducer_state.rb +0 -48
- data/lib/graphql/argument.rb +0 -159
- data/lib/graphql/authorization.rb +0 -82
- data/lib/graphql/backwards_compatibility.rb +0 -60
- data/lib/graphql/base_type.rb +0 -226
- data/lib/graphql/boolean_type.rb +0 -2
- data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
- data/lib/graphql/compatibility/execution_specification.rb +0 -435
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
- data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -213
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -91
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -264
- data/lib/graphql/compatibility/schema_parser_specification.rb +0 -680
- data/lib/graphql/compatibility.rb +0 -5
- data/lib/graphql/define/assign_argument.rb +0 -12
- data/lib/graphql/define/assign_connection.rb +0 -13
- data/lib/graphql/define/assign_enum_value.rb +0 -18
- data/lib/graphql/define/assign_global_id_field.rb +0 -11
- data/lib/graphql/define/assign_mutation_function.rb +0 -34
- data/lib/graphql/define/assign_object_field.rb +0 -42
- data/lib/graphql/define/defined_object_proxy.rb +0 -53
- data/lib/graphql/define/instance_definable.rb +0 -311
- data/lib/graphql/define/no_definition_error.rb +0 -7
- data/lib/graphql/define/non_null_with_bang.rb +0 -16
- data/lib/graphql/define/type_definer.rb +0 -31
- data/lib/graphql/define.rb +0 -31
- data/lib/graphql/deprecated_dsl.rb +0 -42
- data/lib/graphql/directive/deprecated_directive.rb +0 -13
- data/lib/graphql/directive/include_directive.rb +0 -2
- data/lib/graphql/directive/skip_directive.rb +0 -2
- data/lib/graphql/directive.rb +0 -104
- data/lib/graphql/enum_type.rb +0 -193
- data/lib/graphql/execution/execute.rb +0 -326
- data/lib/graphql/execution/flatten.rb +0 -40
- data/lib/graphql/execution/instrumentation.rb +0 -92
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
- data/lib/graphql/execution/lazy/resolve.rb +0 -91
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -330
- data/lib/graphql/float_type.rb +0 -2
- data/lib/graphql/function.rb +0 -153
- data/lib/graphql/id_type.rb +0 -2
- data/lib/graphql/input_object_type.rb +0 -154
- data/lib/graphql/int_type.rb +0 -2
- data/lib/graphql/interface_type.rb +0 -86
- data/lib/graphql/internal_representation/document.rb +0 -27
- data/lib/graphql/internal_representation/node.rb +0 -206
- data/lib/graphql/internal_representation/print.rb +0 -51
- data/lib/graphql/internal_representation/rewrite.rb +0 -184
- data/lib/graphql/internal_representation/scope.rb +0 -88
- data/lib/graphql/internal_representation/visit.rb +0 -36
- data/lib/graphql/internal_representation.rb +0 -7
- data/lib/graphql/list_type.rb +0 -80
- data/lib/graphql/literal_validation_error.rb +0 -6
- data/lib/graphql/non_null_type.rb +0 -81
- data/lib/graphql/object_type.rb +0 -141
- data/lib/graphql/query/arguments.rb +0 -187
- data/lib/graphql/query/arguments_cache.rb +0 -25
- data/lib/graphql/query/executor.rb +0 -53
- data/lib/graphql/query/literal_input.rb +0 -116
- data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
- data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
- data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
- data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
- data/lib/graphql/query/serial_execution.rb +0 -39
- data/lib/graphql/relay/array_connection.rb +0 -85
- data/lib/graphql/relay/base_connection.rb +0 -172
- data/lib/graphql/relay/connection_instrumentation.rb +0 -54
- data/lib/graphql/relay/connection_resolve.rb +0 -43
- data/lib/graphql/relay/connection_type.rb +0 -40
- data/lib/graphql/relay/edge.rb +0 -27
- data/lib/graphql/relay/edge_type.rb +0 -18
- data/lib/graphql/relay/edges_instrumentation.rb +0 -40
- data/lib/graphql/relay/global_id_resolve.rb +0 -18
- data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
- data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
- data/lib/graphql/relay/mutation/resolve.rb +0 -56
- data/lib/graphql/relay/mutation/result.rb +0 -38
- data/lib/graphql/relay/mutation.rb +0 -190
- data/lib/graphql/relay/node.rb +0 -36
- data/lib/graphql/relay/page_info.rb +0 -7
- data/lib/graphql/relay/relation_connection.rb +0 -190
- data/lib/graphql/relay/type_extensions.rb +0 -30
- data/lib/graphql/scalar_type.rb +0 -133
- data/lib/graphql/schema/catchall_middleware.rb +0 -35
- data/lib/graphql/schema/default_parse_error.rb +0 -10
- data/lib/graphql/schema/default_type_error.rb +0 -15
- data/lib/graphql/schema/member/accepts_definition.rb +0 -152
- data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -26
- data/lib/graphql/schema/member/instrumentation.rb +0 -132
- data/lib/graphql/schema/middleware_chain.rb +0 -82
- data/lib/graphql/schema/possible_types.rb +0 -39
- data/lib/graphql/schema/rescue_middleware.rb +0 -60
- data/lib/graphql/schema/timeout_middleware.rb +0 -86
- data/lib/graphql/schema/traversal.rb +0 -228
- data/lib/graphql/schema/validation.rb +0 -303
- data/lib/graphql/static_validation/default_visitor.rb +0 -15
- data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
- data/lib/graphql/string_type.rb +0 -2
- data/lib/graphql/subscriptions/subscription_root.rb +0 -74
- data/lib/graphql/tracing/skylight_tracing.rb +0 -62
- data/lib/graphql/types/relay/base_field.rb +0 -22
- data/lib/graphql/types/relay/base_interface.rb +0 -29
- data/lib/graphql/types/relay/base_object.rb +0 -26
- data/lib/graphql/types/relay/node_field.rb +0 -43
- data/lib/graphql/types/relay/nodes_field.rb +0 -45
- data/lib/graphql/union_type.rb +0 -135
- data/lib/graphql/upgrader/member.rb +0 -936
- data/lib/graphql/upgrader/schema.rb +0 -37
@@ -23,170 +23,23 @@ module GraphQL
|
|
23
23
|
# @see {Schema#multiplex} for public API
|
24
24
|
# @api private
|
25
25
|
class Multiplex
|
26
|
-
# Used internally to signal that the query shouldn't be executed
|
27
|
-
# @api private
|
28
|
-
NO_OPERATION = {}.freeze
|
29
|
-
|
30
26
|
include Tracing::Traceable
|
31
27
|
|
32
|
-
attr_reader :context, :queries, :schema, :max_complexity
|
28
|
+
attr_reader :context, :queries, :schema, :max_complexity, :dataloader
|
29
|
+
|
33
30
|
def initialize(schema:, queries:, context:, max_complexity:)
|
34
31
|
@schema = schema
|
35
32
|
@queries = queries
|
33
|
+
@queries.each { |q| q.multiplex = self }
|
36
34
|
@context = context
|
37
|
-
|
38
|
-
@tracers = schema.tracers +
|
35
|
+
@dataloader = @context[:dataloader] ||= @schema.dataloader_class.new
|
36
|
+
@tracers = schema.tracers + (context[:tracers] || [])
|
39
37
|
# Support `context: {backtrace: true}`
|
40
38
|
if context[:backtrace] && !@tracers.include?(GraphQL::Backtrace::Tracer)
|
41
39
|
@tracers << GraphQL::Backtrace::Tracer
|
42
40
|
end
|
43
41
|
@max_complexity = max_complexity
|
44
42
|
end
|
45
|
-
|
46
|
-
class << self
|
47
|
-
def run_all(schema, query_options, **kwargs)
|
48
|
-
queries = query_options.map { |opts| GraphQL::Query.new(schema, nil, **opts) }
|
49
|
-
run_queries(schema, queries, **kwargs)
|
50
|
-
end
|
51
|
-
|
52
|
-
# @param schema [GraphQL::Schema]
|
53
|
-
# @param queries [Array<GraphQL::Query>]
|
54
|
-
# @param context [Hash]
|
55
|
-
# @param max_complexity [Integer, nil]
|
56
|
-
# @return [Array<Hash>] One result per query
|
57
|
-
def run_queries(schema, queries, context: {}, max_complexity: schema.max_complexity)
|
58
|
-
multiplex = self.new(schema: schema, queries: queries, context: context, max_complexity: max_complexity)
|
59
|
-
multiplex.trace("execute_multiplex", { multiplex: multiplex }) do
|
60
|
-
if supports_multiplexing?(schema)
|
61
|
-
instrument_and_analyze(multiplex) do
|
62
|
-
run_as_multiplex(multiplex)
|
63
|
-
end
|
64
|
-
else
|
65
|
-
if queries.length != 1
|
66
|
-
raise ArgumentError, "Multiplexing doesn't support custom execution strategies, run one query at a time instead"
|
67
|
-
else
|
68
|
-
instrument_and_analyze(multiplex) do
|
69
|
-
[run_one_legacy(schema, queries.first)]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
def run_as_multiplex(multiplex)
|
79
|
-
|
80
|
-
multiplex.schema.query_execution_strategy.begin_multiplex(multiplex)
|
81
|
-
queries = multiplex.queries
|
82
|
-
# Do as much eager evaluation of the query as possible
|
83
|
-
results = queries.map do |query|
|
84
|
-
begin_query(query, multiplex)
|
85
|
-
end
|
86
|
-
|
87
|
-
# Then, work through lazy results in a breadth-first way
|
88
|
-
multiplex.schema.query_execution_strategy.finish_multiplex(results, multiplex)
|
89
|
-
|
90
|
-
# Then, find all errors and assign the result to the query object
|
91
|
-
results.each_with_index.map do |data_result, idx|
|
92
|
-
query = queries[idx]
|
93
|
-
finish_query(data_result, query, multiplex)
|
94
|
-
# Get the Query::Result, not the Hash
|
95
|
-
query.result
|
96
|
-
end
|
97
|
-
rescue Exception
|
98
|
-
# Assign values here so that the query's `@executed` becomes true
|
99
|
-
queries.map { |q| q.result_values ||= {} }
|
100
|
-
raise
|
101
|
-
end
|
102
|
-
|
103
|
-
# @param query [GraphQL::Query]
|
104
|
-
# @return [Hash] The initial result (may not be finished if there are lazy values)
|
105
|
-
def begin_query(query, multiplex)
|
106
|
-
operation = query.selected_operation
|
107
|
-
if operation.nil? || !query.valid? || query.context.errors.any?
|
108
|
-
NO_OPERATION
|
109
|
-
else
|
110
|
-
begin
|
111
|
-
# These were checked to be the same in `#supports_multiplexing?`
|
112
|
-
query.schema.query_execution_strategy.begin_query(query, multiplex)
|
113
|
-
rescue GraphQL::ExecutionError => err
|
114
|
-
query.context.errors << err
|
115
|
-
NO_OPERATION
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# @param data_result [Hash] The result for the "data" key, if any
|
121
|
-
# @param query [GraphQL::Query] The query which was run
|
122
|
-
# @return [Hash] final result of this query, including all values and errors
|
123
|
-
def finish_query(data_result, query, multiplex)
|
124
|
-
# Assign the result so that it can be accessed in instrumentation
|
125
|
-
query.result_values = if data_result.equal?(NO_OPERATION)
|
126
|
-
if !query.valid? || query.context.errors.any?
|
127
|
-
# A bit weird, but `Query#static_errors` _includes_ `query.context.errors`
|
128
|
-
{ "errors" => query.static_errors.map(&:to_h) }
|
129
|
-
else
|
130
|
-
data_result
|
131
|
-
end
|
132
|
-
else
|
133
|
-
# Use `context.value` which was assigned during execution
|
134
|
-
result = query.schema.query_execution_strategy.finish_query(query, multiplex)
|
135
|
-
|
136
|
-
if query.context.errors.any?
|
137
|
-
error_result = query.context.errors.map(&:to_h)
|
138
|
-
result["errors"] = error_result
|
139
|
-
end
|
140
|
-
|
141
|
-
result
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
# use the old `query_execution_strategy` etc to run this query
|
146
|
-
def run_one_legacy(schema, query)
|
147
|
-
query.result_values = if !query.valid?
|
148
|
-
all_errors = query.validation_errors + query.analysis_errors + query.context.errors
|
149
|
-
if all_errors.any?
|
150
|
-
{ "errors" => all_errors.map(&:to_h) }
|
151
|
-
else
|
152
|
-
nil
|
153
|
-
end
|
154
|
-
else
|
155
|
-
GraphQL::Query::Executor.new(query).result
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
DEFAULT_STRATEGIES = [
|
160
|
-
GraphQL::Execution::Execute,
|
161
|
-
GraphQL::Execution::Interpreter
|
162
|
-
]
|
163
|
-
# @return [Boolean] True if the schema is only using one strategy, and it's one that supports multiplexing.
|
164
|
-
def supports_multiplexing?(schema)
|
165
|
-
schema_strategies = [schema.query_execution_strategy, schema.mutation_execution_strategy, schema.subscription_execution_strategy]
|
166
|
-
schema_strategies.uniq!
|
167
|
-
schema_strategies.size == 1 && DEFAULT_STRATEGIES.include?(schema_strategies.first)
|
168
|
-
end
|
169
|
-
|
170
|
-
# Apply multiplex & query instrumentation to `queries`.
|
171
|
-
#
|
172
|
-
# It yields when the queries should be executed, then runs teardown.
|
173
|
-
def instrument_and_analyze(multiplex)
|
174
|
-
GraphQL::Execution::Instrumentation.apply_instrumenters(multiplex) do
|
175
|
-
schema = multiplex.schema
|
176
|
-
multiplex_analyzers = schema.multiplex_analyzers
|
177
|
-
if multiplex.max_complexity
|
178
|
-
multiplex_analyzers += if schema.using_ast_analysis?
|
179
|
-
[GraphQL::Analysis::AST::MaxQueryComplexity]
|
180
|
-
else
|
181
|
-
[GraphQL::Analysis::MaxQueryComplexity.new(multiplex.max_complexity)]
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
schema.analysis_engine.analyze_multiplex(multiplex, multiplex_analyzers)
|
186
|
-
yield
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
43
|
end
|
191
44
|
end
|
192
45
|
end
|
data/lib/graphql/execution.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "graphql/execution/directive_checks"
|
3
|
-
require "graphql/execution/execute"
|
4
|
-
require "graphql/execution/flatten"
|
5
|
-
require "graphql/execution/instrumentation"
|
6
3
|
require "graphql/execution/interpreter"
|
7
4
|
require "graphql/execution/lazy"
|
8
5
|
require "graphql/execution/lookahead"
|
9
6
|
require "graphql/execution/multiplex"
|
10
|
-
require "graphql/execution/typecast"
|
11
7
|
require "graphql/execution/errors"
|
8
|
+
|
9
|
+
module GraphQL
|
10
|
+
module Execution
|
11
|
+
# @api private
|
12
|
+
class Skip < GraphQL::Error; end
|
13
|
+
|
14
|
+
# Just a singleton for implementing {Query::Context#skip}
|
15
|
+
# @api private
|
16
|
+
SKIP = Skip.new
|
17
|
+
end
|
18
|
+
end
|
data/lib/graphql/filter.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
# This error is raised when `Types::Int` is given an input value outside of 32-bit integer range.
|
4
|
+
#
|
5
|
+
# For really big integer values, consider `GraphQL::Types::BigInt`
|
6
|
+
#
|
7
|
+
# @see GraphQL::Types::Int which raises this error
|
8
|
+
class IntegerDecodingError < GraphQL::RuntimeTypeError
|
9
|
+
# The value which couldn't be decoded
|
10
|
+
attr_reader :integer_value
|
11
|
+
|
12
|
+
def initialize(value)
|
13
|
+
@integer_value = value
|
14
|
+
super("Integer out of bounds: #{value}. \nConsider using GraphQL::Types::BigInt instead.")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -12,9 +12,25 @@ module GraphQL
|
|
12
12
|
# The value which couldn't be encoded
|
13
13
|
attr_reader :integer_value
|
14
14
|
|
15
|
-
|
15
|
+
# @return [GraphQL::Schema::Field] The field that returned a too-big integer
|
16
|
+
attr_reader :field
|
17
|
+
|
18
|
+
# @return [Array<String, Integer>] Where the field appeared in the GraphQL response
|
19
|
+
attr_reader :path
|
20
|
+
|
21
|
+
def initialize(value, context:)
|
16
22
|
@integer_value = value
|
17
|
-
|
23
|
+
@field = context[:current_field]
|
24
|
+
@path = context[:current_path]
|
25
|
+
message = "Integer out of bounds: #{value}".dup
|
26
|
+
if @path
|
27
|
+
message << " @ #{@path.join(".")}"
|
28
|
+
end
|
29
|
+
if @field
|
30
|
+
message << " (#{@field.path})"
|
31
|
+
end
|
32
|
+
message << ". Consider using ID or GraphQL::Types::BigInt instead."
|
33
|
+
super(message)
|
18
34
|
end
|
19
35
|
end
|
20
36
|
end
|
@@ -2,15 +2,12 @@
|
|
2
2
|
module GraphQL
|
3
3
|
module Introspection
|
4
4
|
class BaseObject < GraphQL::Schema::Object
|
5
|
+
introspection(true)
|
6
|
+
|
5
7
|
def self.field(*args, **kwargs, &block)
|
6
8
|
kwargs[:introspection] = true
|
7
9
|
super(*args, **kwargs, &block)
|
8
10
|
end
|
9
|
-
|
10
|
-
def self.inherited(child_class)
|
11
|
-
child_class.introspection(true)
|
12
|
-
super
|
13
|
-
end
|
14
11
|
end
|
15
12
|
end
|
16
13
|
end
|
@@ -6,8 +6,8 @@ module GraphQL
|
|
6
6
|
description "A Directive can be adjacent to many parts of the GraphQL language, "\
|
7
7
|
"a __DirectiveLocation describes one such possible adjacencies."
|
8
8
|
|
9
|
-
GraphQL::Directive::LOCATIONS.each do |location|
|
10
|
-
value(location.to_s, GraphQL::Directive::LOCATION_DESCRIPTIONS[location], value: location)
|
9
|
+
GraphQL::Schema::Directive::LOCATIONS.each do |location|
|
10
|
+
value(location.to_s, GraphQL::Schema::Directive::LOCATION_DESCRIPTIONS[location], value: location)
|
11
11
|
end
|
12
12
|
introspection true
|
13
13
|
end
|
@@ -9,16 +9,22 @@ module GraphQL
|
|
9
9
|
"in ways field arguments will not suffice, such as conditionally including or "\
|
10
10
|
"skipping a field. Directives provide this by describing additional information "\
|
11
11
|
"to the executor."
|
12
|
-
field :name, String, null: false
|
13
|
-
field :description, String
|
12
|
+
field :name, String, null: false, method: :graphql_name
|
13
|
+
field :description, String
|
14
14
|
field :locations, [GraphQL::Schema::LateBoundType.new("__DirectiveLocation")], null: false
|
15
|
-
field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false
|
15
|
+
field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false do
|
16
|
+
argument :include_deprecated, Boolean, required: false, default_value: false
|
17
|
+
end
|
16
18
|
field :on_operation, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_operation?
|
17
19
|
field :on_fragment, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_fragment?
|
18
20
|
field :on_field, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_field?
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
field :is_repeatable, Boolean, method: :repeatable?
|
23
|
+
|
24
|
+
def args(include_deprecated:)
|
25
|
+
args = @context.warden.arguments(@object)
|
26
|
+
args = args.reject(&:deprecation_reason) unless include_deprecated
|
27
|
+
args
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -2,15 +2,10 @@
|
|
2
2
|
module GraphQL
|
3
3
|
module Introspection
|
4
4
|
class DynamicFields < Introspection::BaseObject
|
5
|
-
field :__typename, String, "The name of this type", null: false
|
5
|
+
field :__typename, String, "The name of this type", null: false
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
if context.interpreter?
|
10
|
-
object.class.graphql_name
|
11
|
-
else
|
12
|
-
irep_node.owner_type.name
|
13
|
-
end
|
7
|
+
def __typename
|
8
|
+
object.class.graphql_name
|
14
9
|
end
|
15
10
|
end
|
16
11
|
end
|
@@ -3,32 +3,19 @@ module GraphQL
|
|
3
3
|
module Introspection
|
4
4
|
class EntryPoints < Introspection::BaseObject
|
5
5
|
field :__schema, GraphQL::Schema::LateBoundType.new("__Schema"), "This GraphQL schema", null: false
|
6
|
-
field :__type, GraphQL::Schema::LateBoundType.new("__Type"), "A type in the GraphQL system"
|
7
|
-
argument :name, String
|
6
|
+
field :__type, GraphQL::Schema::LateBoundType.new("__Type"), "A type in the GraphQL system" do
|
7
|
+
argument :name, String
|
8
8
|
end
|
9
9
|
|
10
10
|
def __schema
|
11
11
|
# Apply wrapping manually since this field isn't wrapped by instrumentation
|
12
12
|
schema = @context.query.schema
|
13
|
-
schema_type = schema.introspection_system.
|
14
|
-
schema_type.
|
13
|
+
schema_type = schema.introspection_system.types["__Schema"]
|
14
|
+
schema_type.authorized_new(schema, @context)
|
15
15
|
end
|
16
16
|
|
17
17
|
def __type(name:)
|
18
|
-
|
19
|
-
|
20
|
-
type = context.warden.get_type(name)
|
21
|
-
if type && context.interpreter?
|
22
|
-
type = type.metadata[:type_class] || raise("Invariant: interpreter requires class-based type for #{name}")
|
23
|
-
end
|
24
|
-
|
25
|
-
# The interpreter provides this wrapping, other execution doesnt, so support both.
|
26
|
-
if type && !context.interpreter?
|
27
|
-
# Apply wrapping manually since this field isn't wrapped by instrumentation
|
28
|
-
type_type = context.schema.introspection_system.type_type
|
29
|
-
type = type_type.metadata[:type_class].authorized_new(type, context)
|
30
|
-
end
|
31
|
-
type
|
18
|
+
context.warden.reachable_type?(name) ? context.warden.get_type(name) : nil
|
32
19
|
end
|
33
20
|
end
|
34
21
|
end
|
@@ -7,9 +7,9 @@ module GraphQL
|
|
7
7
|
"placeholder for a string or numeric value. However an Enum value is returned in "\
|
8
8
|
"a JSON response as a string."
|
9
9
|
field :name, String, null: false
|
10
|
-
field :description, String
|
10
|
+
field :description, String
|
11
11
|
field :is_deprecated, Boolean, null: false
|
12
|
-
field :deprecation_reason, String
|
12
|
+
field :deprecation_reason, String
|
13
13
|
|
14
14
|
def name
|
15
15
|
object.graphql_name
|
@@ -6,18 +6,22 @@ module GraphQL
|
|
6
6
|
description "Object and Interface types are described by a list of Fields, each of which has "\
|
7
7
|
"a name, potentially a list of arguments, and a return type."
|
8
8
|
field :name, String, null: false
|
9
|
-
field :description, String
|
10
|
-
field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false
|
9
|
+
field :description, String
|
10
|
+
field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false do
|
11
|
+
argument :include_deprecated, Boolean, required: false, default_value: false
|
12
|
+
end
|
11
13
|
field :type, GraphQL::Schema::LateBoundType.new("__Type"), null: false
|
12
14
|
field :is_deprecated, Boolean, null: false
|
13
|
-
field :deprecation_reason, String
|
15
|
+
field :deprecation_reason, String
|
14
16
|
|
15
17
|
def is_deprecated
|
16
18
|
!!@object.deprecation_reason
|
17
19
|
end
|
18
20
|
|
19
|
-
def args
|
20
|
-
@context.warden.arguments(@object)
|
21
|
+
def args(include_deprecated:)
|
22
|
+
args = @context.warden.arguments(@object)
|
23
|
+
args = args.reject(&:deprecation_reason) unless include_deprecated
|
24
|
+
args
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
@@ -7,9 +7,15 @@ module GraphQL
|
|
7
7
|
"InputObject are represented as Input Values which describe their type and "\
|
8
8
|
"optionally a default value."
|
9
9
|
field :name, String, null: false
|
10
|
-
field :description, String
|
10
|
+
field :description, String
|
11
11
|
field :type, GraphQL::Schema::LateBoundType.new("__Type"), null: false
|
12
|
-
field :default_value, String, "A GraphQL-formatted string representing the default value for this input value."
|
12
|
+
field :default_value, String, "A GraphQL-formatted string representing the default value for this input value."
|
13
|
+
field :is_deprecated, Boolean, null: false
|
14
|
+
field :deprecation_reason, String
|
15
|
+
|
16
|
+
def is_deprecated
|
17
|
+
!!@object.deprecation_reason
|
18
|
+
end
|
13
19
|
|
14
20
|
def default_value
|
15
21
|
if @object.default_value?
|
@@ -17,21 +23,45 @@ module GraphQL
|
|
17
23
|
if value.nil?
|
18
24
|
'null'
|
19
25
|
else
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
coerced_default_value
|
26
|
-
end
|
27
|
-
else
|
28
|
-
GraphQL::Language.serialize(coerced_default_value)
|
26
|
+
if (@object.type.kind.list? || (@object.type.kind.non_null? && @object.type.of_type.kind.list?)) && !value.respond_to?(:map)
|
27
|
+
# This is a bit odd -- we expect the default value to be an application-style value, so we use coerce result below.
|
28
|
+
# But coerce_result doesn't wrap single-item lists, which are valid inputs to list types.
|
29
|
+
# So, apply that wrapper here if needed.
|
30
|
+
value = [value]
|
29
31
|
end
|
32
|
+
coerced_default_value = @object.type.coerce_result(value, @context)
|
33
|
+
serialize_default_value(coerced_default_value, @object.type)
|
30
34
|
end
|
31
35
|
else
|
32
36
|
nil
|
33
37
|
end
|
34
38
|
end
|
39
|
+
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# Recursively serialize, taking care not to add quotes to enum values
|
44
|
+
def serialize_default_value(value, type)
|
45
|
+
if value.nil?
|
46
|
+
'null'
|
47
|
+
elsif type.kind.list?
|
48
|
+
inner_type = type.of_type
|
49
|
+
"[" + value.map { |v| serialize_default_value(v, inner_type) }.join(", ") + "]"
|
50
|
+
elsif type.kind.non_null?
|
51
|
+
serialize_default_value(value, type.of_type)
|
52
|
+
elsif type.kind.enum?
|
53
|
+
value
|
54
|
+
elsif type.kind.input_object?
|
55
|
+
"{" +
|
56
|
+
value.map do |k, v|
|
57
|
+
arg_defn = type.get_argument(k, context)
|
58
|
+
"#{k}: #{serialize_default_value(v, arg_defn.type)}"
|
59
|
+
end.join(", ") +
|
60
|
+
"}"
|
61
|
+
else
|
62
|
+
GraphQL::Language.serialize(value)
|
63
|
+
end
|
64
|
+
end
|
35
65
|
end
|
36
66
|
end
|
37
67
|
end
|
@@ -1,93 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
mutationType { name }
|
9
|
-
subscriptionType { name }
|
10
|
-
types {
|
11
|
-
...FullType
|
12
|
-
}
|
13
|
-
directives {
|
14
|
-
name
|
15
|
-
description
|
16
|
-
locations
|
17
|
-
args {
|
18
|
-
...InputValue
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
fragment FullType on __Type {
|
24
|
-
kind
|
25
|
-
name
|
26
|
-
description
|
27
|
-
fields(includeDeprecated: true) {
|
28
|
-
name
|
29
|
-
description
|
30
|
-
args {
|
31
|
-
...InputValue
|
32
|
-
}
|
33
|
-
type {
|
34
|
-
...TypeRef
|
35
|
-
}
|
36
|
-
isDeprecated
|
37
|
-
deprecationReason
|
38
|
-
}
|
39
|
-
inputFields {
|
40
|
-
...InputValue
|
41
|
-
}
|
42
|
-
interfaces {
|
43
|
-
...TypeRef
|
44
|
-
}
|
45
|
-
enumValues(includeDeprecated: true) {
|
46
|
-
name
|
47
|
-
description
|
48
|
-
isDeprecated
|
49
|
-
deprecationReason
|
50
|
-
}
|
51
|
-
possibleTypes {
|
52
|
-
...TypeRef
|
53
|
-
}
|
54
|
-
}
|
55
|
-
fragment InputValue on __InputValue {
|
56
|
-
name
|
57
|
-
description
|
58
|
-
type { ...TypeRef }
|
59
|
-
defaultValue
|
60
|
-
}
|
61
|
-
fragment TypeRef on __Type {
|
62
|
-
kind
|
63
|
-
name
|
64
|
-
ofType {
|
65
|
-
kind
|
66
|
-
name
|
67
|
-
ofType {
|
68
|
-
kind
|
69
|
-
name
|
70
|
-
ofType {
|
71
|
-
kind
|
72
|
-
name
|
73
|
-
ofType {
|
74
|
-
kind
|
75
|
-
name
|
76
|
-
ofType {
|
77
|
-
kind
|
78
|
-
name
|
79
|
-
ofType {
|
80
|
-
kind
|
81
|
-
name
|
82
|
-
ofType {
|
83
|
-
kind
|
84
|
-
name
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
"
|
2
|
+
|
3
|
+
# This query is used by graphql-client so don't add the includeDeprecated
|
4
|
+
# argument for inputFields since the server may not support it. Two stage
|
5
|
+
# introspection queries will be required to handle this in clients.
|
6
|
+
GraphQL::Introspection::INTROSPECTION_QUERY = GraphQL::Introspection.query
|
7
|
+
|
@@ -9,18 +9,18 @@ module GraphQL
|
|
9
9
|
"query, mutation, and subscription operations."
|
10
10
|
|
11
11
|
field :types, [GraphQL::Schema::LateBoundType.new("__Type")], "A list of all types supported by this server.", null: false
|
12
|
-
field :
|
13
|
-
field :
|
14
|
-
field :
|
12
|
+
field :query_type, GraphQL::Schema::LateBoundType.new("__Type"), "The type that query operations will be rooted at.", null: false
|
13
|
+
field :mutation_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server supports mutation, the type that mutation operations will be rooted at."
|
14
|
+
field :subscription_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server support subscription, the type that subscription operations will be rooted at."
|
15
15
|
field :directives, [GraphQL::Schema::LateBoundType.new("__Directive")], "A list of all directives supported by this server.", null: false
|
16
|
+
field :description, String, resolver_method: :schema_description
|
17
|
+
|
18
|
+
def schema_description
|
19
|
+
context.schema.description
|
20
|
+
end
|
16
21
|
|
17
22
|
def types
|
18
|
-
|
19
|
-
if context.interpreter?
|
20
|
-
types.map { |t| t.metadata[:type_class] || raise("Invariant: can't introspect non-class-based type: #{t}") }
|
21
|
-
else
|
22
|
-
types
|
23
|
-
end
|
23
|
+
@context.warden.reachable_types.sort_by(&:graphql_name)
|
24
24
|
end
|
25
25
|
|
26
26
|
def query_type
|
@@ -36,7 +36,7 @@ module GraphQL
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def directives
|
39
|
-
context.
|
39
|
+
@context.warden.directives
|
40
40
|
end
|
41
41
|
|
42
42
|
private
|