graphql 1.9.18 → 1.13.24
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.
- 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 +44 -7
- 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 +63 -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 +22 -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/analyze_query.rb +7 -0
- data/lib/graphql/analysis/ast/field_usage.rb +29 -2
- data/lib/graphql/analysis/ast/query_complexity.rb +174 -67
- data/lib/graphql/analysis/ast/visitor.rb +16 -7
- data/lib/graphql/analysis/ast.rb +21 -11
- data/lib/graphql/argument.rb +8 -36
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/legacy_tracer.rb +56 -0
- data/lib/graphql/backtrace/table.rb +44 -5
- data/lib/graphql/backtrace/traced_error.rb +0 -1
- data/lib/graphql/backtrace/tracer.rb +40 -9
- data/lib/graphql/backtrace.rb +28 -19
- data/lib/graphql/backwards_compatibility.rb +2 -1
- data/lib/graphql/base_type.rb +10 -4
- data/lib/graphql/boolean_type.rb +1 -1
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +2 -2
- data/lib/graphql/compatibility/execution_specification.rb +1 -0
- data/lib/graphql/compatibility/lazy_execution_specification.rb +2 -0
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +5 -9
- data/lib/graphql/compatibility/query_parser_specification.rb +2 -0
- data/lib/graphql/compatibility/schema_parser_specification.rb +2 -0
- data/lib/graphql/dataloader/null_dataloader.rb +22 -0
- data/lib/graphql/dataloader/request.rb +19 -0
- data/lib/graphql/dataloader/request_all.rb +19 -0
- data/lib/graphql/dataloader/source.rb +155 -0
- data/lib/graphql/dataloader.rb +308 -0
- data/lib/graphql/date_encoding_error.rb +16 -0
- data/lib/graphql/define/assign_enum_value.rb +1 -1
- data/lib/graphql/define/assign_global_id_field.rb +2 -2
- data/lib/graphql/define/assign_object_field.rb +1 -1
- data/lib/graphql/define/defined_object_proxy.rb +5 -8
- data/lib/graphql/define/instance_definable.rb +60 -110
- data/lib/graphql/define/type_definer.rb +5 -5
- data/lib/graphql/deprecated_dsl.rb +18 -5
- data/lib/graphql/deprecation.rb +9 -0
- data/lib/graphql/directive/deprecated_directive.rb +1 -12
- data/lib/graphql/directive/include_directive.rb +1 -1
- data/lib/graphql/directive/skip_directive.rb +1 -1
- data/lib/graphql/directive.rb +9 -6
- data/lib/graphql/enum_type.rb +14 -74
- data/lib/graphql/execution/directive_checks.rb +2 -2
- data/lib/graphql/execution/errors.rb +110 -8
- data/lib/graphql/execution/execute.rb +8 -1
- data/lib/graphql/execution/instrumentation.rb +1 -1
- 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 +37 -25
- data/lib/graphql/execution/interpreter/runtime.rb +721 -386
- data/lib/graphql/execution/interpreter.rb +42 -19
- data/lib/graphql/execution/lazy/lazy_method_map.rb +4 -0
- data/lib/graphql/execution/lazy.rb +5 -1
- data/lib/graphql/execution/lookahead.rb +39 -114
- data/lib/graphql/execution/multiplex.rb +50 -25
- data/lib/graphql/field.rb +15 -119
- data/lib/graphql/filter.rb +1 -1
- data/lib/graphql/float_type.rb +1 -1
- data/lib/graphql/function.rb +5 -30
- data/lib/graphql/id_type.rb +1 -1
- data/lib/graphql/input_object_type.rb +9 -25
- data/lib/graphql/int_type.rb +1 -1
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +18 -2
- data/lib/graphql/interface_type.rb +10 -24
- data/lib/graphql/internal_representation/document.rb +2 -2
- data/lib/graphql/internal_representation/rewrite.rb +1 -1
- data/lib/graphql/internal_representation/scope.rb +2 -2
- data/lib/graphql/internal_representation/visit.rb +2 -2
- data/lib/graphql/introspection/base_object.rb +2 -5
- data/lib/graphql/introspection/directive_location_enum.rb +2 -2
- data/lib/graphql/introspection/directive_type.rb +12 -6
- data/lib/graphql/introspection/entry_points.rb +9 -9
- data/lib/graphql/introspection/enum_value_type.rb +2 -2
- data/lib/graphql/introspection/field_type.rb +9 -5
- data/lib/graphql/introspection/input_value_type.rb +41 -11
- data/lib/graphql/introspection/introspection_query.rb +6 -92
- data/lib/graphql/introspection/schema_type.rb +12 -12
- data/lib/graphql/introspection/type_type.rb +27 -17
- data/lib/graphql/introspection.rb +99 -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 +116 -63
- data/lib/graphql/language/lexer.rb +53 -27
- data/lib/graphql/language/lexer.rl +5 -3
- data/lib/graphql/language/nodes.rb +67 -93
- data/lib/graphql/language/parser.rb +929 -896
- data/lib/graphql/language/parser.y +125 -102
- data/lib/graphql/language/printer.rb +11 -2
- 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/non_null_type.rb +0 -10
- data/lib/graphql/object_type.rb +47 -58
- data/lib/graphql/pagination/active_record_relation_connection.rb +85 -0
- data/lib/graphql/pagination/array_connection.rb +77 -0
- data/lib/graphql/pagination/connection.rb +226 -0
- data/lib/graphql/pagination/connections.rb +160 -0
- data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
- data/lib/graphql/pagination/relation_connection.rb +226 -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/arguments.rb +6 -4
- data/lib/graphql/query/arguments_cache.rb +1 -2
- data/lib/graphql/query/context.rb +52 -7
- data/lib/graphql/query/executor.rb +0 -1
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +32 -6
- data/lib/graphql/query/literal_input.rb +31 -11
- data/lib/graphql/query/null_context.rb +24 -8
- data/lib/graphql/query/serial_execution/field_resolution.rb +1 -1
- data/lib/graphql/query/serial_execution.rb +1 -0
- data/lib/graphql/query/validation_pipeline.rb +6 -4
- data/lib/graphql/query/variable_validation_error.rb +3 -3
- data/lib/graphql/query/variables.rb +50 -10
- data/lib/graphql/query.rb +77 -18
- data/lib/graphql/railtie.rb +9 -1
- data/lib/graphql/rake_task/validate.rb +3 -0
- data/lib/graphql/rake_task.rb +12 -9
- data/lib/graphql/relay/array_connection.rb +10 -12
- data/lib/graphql/relay/base_connection.rb +30 -13
- data/lib/graphql/relay/connection_instrumentation.rb +4 -4
- data/lib/graphql/relay/connection_type.rb +18 -4
- data/lib/graphql/relay/edge_type.rb +1 -0
- data/lib/graphql/relay/edges_instrumentation.rb +1 -2
- data/lib/graphql/relay/global_id_resolve.rb +1 -2
- data/lib/graphql/relay/mutation.rb +3 -87
- data/lib/graphql/relay/node.rb +3 -0
- data/lib/graphql/relay/page_info.rb +1 -1
- data/lib/graphql/relay/range_add.rb +27 -9
- data/lib/graphql/relay/relation_connection.rb +8 -10
- data/lib/graphql/relay/type_extensions.rb +2 -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/scalar_type.rb +18 -60
- data/lib/graphql/schema/addition.rb +247 -0
- data/lib/graphql/schema/argument.rb +274 -18
- 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 +320 -219
- data/lib/graphql/schema/built_in_types.rb +5 -5
- data/lib/graphql/schema/default_type_error.rb +2 -0
- 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/skip.rb +2 -2
- data/lib/graphql/schema/directive/transform.rb +14 -2
- data/lib/graphql/schema/directive.rb +130 -6
- data/lib/graphql/schema/enum.rb +121 -12
- data/lib/graphql/schema/enum_value.rb +24 -7
- data/lib/graphql/schema/field/connection_extension.rb +46 -20
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +465 -181
- 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 +172 -37
- data/lib/graphql/schema/interface.rb +39 -25
- data/lib/graphql/schema/introspection_system.rb +106 -38
- data/lib/graphql/schema/late_bound_type.rb +3 -2
- data/lib/graphql/schema/list.rb +65 -1
- data/lib/graphql/schema/loader.rb +145 -102
- data/lib/graphql/schema/member/accepts_definition.rb +15 -3
- data/lib/graphql/schema/member/base_dsl_methods.rb +34 -28
- data/lib/graphql/schema/member/build_type.rb +19 -8
- data/lib/graphql/schema/member/cached_graphql_definition.rb +34 -2
- data/lib/graphql/schema/member/has_arguments.rb +206 -13
- data/lib/graphql/schema/member/has_ast_node.rb +20 -0
- data/lib/graphql/schema/member/has_deprecation_reason.rb +25 -0
- data/lib/graphql/schema/member/has_directives.rb +98 -0
- data/lib/graphql/schema/member/has_fields.rb +97 -32
- data/lib/graphql/schema/member/has_interfaces.rb +100 -0
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
- data/lib/graphql/schema/member/has_validators.rb +31 -0
- data/lib/graphql/schema/member/instrumentation.rb +0 -1
- 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 -0
- data/lib/graphql/schema/middleware_chain.rb +1 -1
- data/lib/graphql/schema/mutation.rb +4 -0
- data/lib/graphql/schema/non_null.rb +37 -1
- data/lib/graphql/schema/object.rb +51 -38
- data/lib/graphql/schema/possible_types.rb +9 -4
- data/lib/graphql/schema/printer.rb +16 -35
- data/lib/graphql/schema/relay_classic_mutation.rb +40 -4
- data/lib/graphql/schema/resolver/has_payload_type.rb +34 -4
- data/lib/graphql/schema/resolver.rb +133 -79
- data/lib/graphql/schema/scalar.rb +43 -3
- data/lib/graphql/schema/subscription.rb +57 -21
- data/lib/graphql/schema/timeout.rb +29 -15
- data/lib/graphql/schema/timeout_middleware.rb +3 -1
- data/lib/graphql/schema/traversal.rb +2 -2
- data/lib/graphql/schema/type_expression.rb +21 -13
- data/lib/graphql/schema/type_membership.rb +19 -5
- data/lib/graphql/schema/union.rb +44 -3
- data/lib/graphql/schema/unique_within_type.rb +1 -2
- data/lib/graphql/schema/validation.rb +14 -4
- 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 +193 -34
- data/lib/graphql/schema.rb +882 -247
- data/lib/graphql/static_validation/all_rules.rb +2 -0
- data/lib/graphql/static_validation/base_visitor.rb +17 -10
- data/lib/graphql/static_validation/definition_dependencies.rb +0 -1
- data/lib/graphql/static_validation/error.rb +3 -1
- data/lib/graphql/static_validation/literal_validator.rb +51 -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 +1 -1
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +2 -2
- 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/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 +1 -1
- 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 +43 -9
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +13 -3
- data/lib/graphql/string_type.rb +1 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +123 -22
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +81 -0
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +21 -0
- data/lib/graphql/subscriptions/event.rb +84 -30
- data/lib/graphql/subscriptions/instrumentation.rb +10 -6
- data/lib/graphql/subscriptions/serialize.rb +53 -6
- data/lib/graphql/subscriptions/subscription_root.rb +15 -5
- data/lib/graphql/subscriptions.rb +117 -49
- 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 +32 -15
- 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 +66 -10
- 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/skylight_tracing.rb +9 -1
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +15 -35
- 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 +16 -8
- data/lib/graphql/types/iso_8601_date_time.rb +32 -10
- data/lib/graphql/types/relay/base_connection.rb +6 -88
- data/lib/graphql/types/relay/base_edge.rb +2 -34
- data/lib/graphql/types/relay/connection_behaviors.rb +174 -0
- data/lib/graphql/types/relay/default_relay.rb +31 -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 +2 -4
- data/lib/graphql/types/relay/node_behaviors.rb +15 -0
- data/lib/graphql/types/relay/node_field.rb +3 -22
- data/lib/graphql/types/relay/nodes_field.rb +16 -18
- 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 -3
- data/lib/graphql/types/string.rb +8 -2
- data/lib/graphql/unauthorized_error.rb +2 -2
- data/lib/graphql/union_type.rb +5 -25
- data/lib/graphql/unresolved_type_error.rb +2 -2
- data/lib/graphql/upgrader/member.rb +1 -0
- data/lib/graphql/upgrader/schema.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +87 -31
- data/readme.md +3 -6
- metadata +126 -124
- data/lib/graphql/execution/interpreter/hash_response.rb +0 -46
- data/lib/graphql/literal_validation_error.rb +0 -6
- 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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GraphQL
|
|
4
|
+
module Types
|
|
5
|
+
module Relay
|
|
6
|
+
# Include this module to your root Query type to get a Relay-compliant `node(id: ID!): Node` field that uses the schema's `object_from_id` hook.
|
|
7
|
+
module HasNodeField
|
|
8
|
+
def self.included(child_class)
|
|
9
|
+
child_class.field(**field_options, &field_block)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def field_options
|
|
14
|
+
{
|
|
15
|
+
name: "node",
|
|
16
|
+
type: GraphQL::Types::Relay::Node,
|
|
17
|
+
null: true,
|
|
18
|
+
description: "Fetches an object given its ID.",
|
|
19
|
+
relay_node_field: true,
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def field_block
|
|
24
|
+
Proc.new {
|
|
25
|
+
argument :id, "ID!",
|
|
26
|
+
description: "ID of the object."
|
|
27
|
+
|
|
28
|
+
def resolve(obj, args, ctx)
|
|
29
|
+
ctx.schema.object_from_id(args[:id], ctx)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def resolve_field(obj, args, ctx)
|
|
33
|
+
resolve(obj, args, ctx)
|
|
34
|
+
end
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GraphQL
|
|
4
|
+
module Types
|
|
5
|
+
module Relay
|
|
6
|
+
# Include this module to your root Query type to get a Relay-style `nodes(id: ID!): [Node]` field that uses the schema's `object_from_id` hook.
|
|
7
|
+
module HasNodesField
|
|
8
|
+
def self.included(child_class)
|
|
9
|
+
child_class.field(**field_options, &field_block)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def field_options
|
|
14
|
+
{
|
|
15
|
+
name: "nodes",
|
|
16
|
+
type: [GraphQL::Types::Relay::Node, null: true],
|
|
17
|
+
null: false,
|
|
18
|
+
description: "Fetches a list of objects given a list of IDs.",
|
|
19
|
+
relay_nodes_field: true,
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def field_block
|
|
24
|
+
Proc.new {
|
|
25
|
+
argument :ids, "[ID!]!",
|
|
26
|
+
description: "IDs of the objects."
|
|
27
|
+
|
|
28
|
+
def resolve(obj, args, ctx)
|
|
29
|
+
args[:ids].map { |id| ctx.schema.object_from_id(id, ctx) }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def resolve_field(obj, args, ctx)
|
|
33
|
+
resolve(obj, args, ctx)
|
|
34
|
+
end
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -7,10 +7,8 @@ module GraphQL
|
|
|
7
7
|
# or you can take it as inspiration for your own implementation
|
|
8
8
|
# of the `Node` interface.
|
|
9
9
|
module Node
|
|
10
|
-
include
|
|
11
|
-
|
|
12
|
-
description "An object with an ID."
|
|
13
|
-
field(:id, ID, null: false, description: "ID of the object.")
|
|
10
|
+
include GraphQL::Schema::Interface
|
|
11
|
+
include Types::Relay::NodeBehaviors
|
|
14
12
|
end
|
|
15
13
|
end
|
|
16
14
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GraphQL
|
|
4
|
+
module Types
|
|
5
|
+
module Relay
|
|
6
|
+
module NodeBehaviors
|
|
7
|
+
def self.included(child_module)
|
|
8
|
+
child_module.extend(DefaultRelay)
|
|
9
|
+
child_module.description("An object with an ID.")
|
|
10
|
+
child_module.field(:id, ID, null: false, description: "ID of the object.")
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
module GraphQL
|
|
3
3
|
module Types
|
|
4
4
|
module Relay
|
|
5
|
-
#
|
|
6
|
-
# or use it for inspiration for your own field definition.
|
|
5
|
+
# Don't use this field directly, instead, use one of these approaches:
|
|
7
6
|
#
|
|
8
7
|
# @example Adding this field directly
|
|
9
|
-
#
|
|
8
|
+
# include GraphQL::Types::Relay::HasNodeField
|
|
10
9
|
#
|
|
11
10
|
# @example Implementing a similar field in your own Query root
|
|
12
11
|
#
|
|
@@ -19,25 +18,7 @@ module GraphQL
|
|
|
19
18
|
# context.schema.object_from_id(id, context)
|
|
20
19
|
# end
|
|
21
20
|
#
|
|
22
|
-
|
|
23
|
-
name: "node",
|
|
24
|
-
owner: nil,
|
|
25
|
-
type: GraphQL::Types::Relay::Node,
|
|
26
|
-
null: true,
|
|
27
|
-
description: "Fetches an object given its ID.",
|
|
28
|
-
relay_node_field: true,
|
|
29
|
-
) do
|
|
30
|
-
argument :id, "ID!", required: true,
|
|
31
|
-
description: "ID of the object."
|
|
32
|
-
|
|
33
|
-
def resolve(obj, args, ctx)
|
|
34
|
-
ctx.schema.object_from_id(args[:id], ctx)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def resolve_field(obj, args, ctx)
|
|
38
|
-
resolve(obj, args, ctx)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
21
|
+
DeprecatedNodeField = GraphQL::Schema::Field.new(owner: nil, **HasNodeField.field_options, &HasNodeField.field_block)
|
|
41
22
|
end
|
|
42
23
|
end
|
|
43
24
|
end
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
module GraphQL
|
|
3
3
|
module Types
|
|
4
4
|
module Relay
|
|
5
|
-
#
|
|
6
|
-
# or use it for inspiration for your own field definition.
|
|
5
|
+
# Don't use this directly, instead, use one of these:
|
|
7
6
|
#
|
|
8
7
|
# @example Adding this field directly
|
|
9
|
-
#
|
|
8
|
+
# include GraphQL::Types::Relay::HasNodesField
|
|
10
9
|
#
|
|
11
10
|
# @example Implementing a similar field in your own Query root
|
|
12
11
|
#
|
|
@@ -21,25 +20,24 @@ module GraphQL
|
|
|
21
20
|
# end
|
|
22
21
|
# end
|
|
23
22
|
#
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
description: "Fetches a list of objects given a list of IDs.",
|
|
30
|
-
relay_nodes_field: true,
|
|
31
|
-
) do
|
|
32
|
-
argument :ids, "[ID!]!", required: true,
|
|
33
|
-
description: "IDs of the objects."
|
|
23
|
+
def self.const_missing(const_name)
|
|
24
|
+
if const_name == :NodesField
|
|
25
|
+
message = "NodesField is deprecated, use `include GraphQL::Types::Relay::HasNodesField` instead."
|
|
26
|
+
message += "\n(referenced from #{caller(1, 1).first})"
|
|
27
|
+
GraphQL::Deprecation.warn(message)
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
DeprecatedNodesField
|
|
30
|
+
elsif const_name == :NodeField
|
|
31
|
+
message = "NodeField is deprecated, use `include GraphQL::Types::Relay::HasNodeField` instead."
|
|
32
|
+
message += "\n(referenced from #{caller(1, 1).first})"
|
|
33
|
+
GraphQL::Deprecation.warn(message)
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
DeprecatedNodeField
|
|
36
|
+
else
|
|
37
|
+
super
|
|
41
38
|
end
|
|
42
39
|
end
|
|
40
|
+
DeprecatedNodesField = GraphQL::Schema::Field.new(owner: nil, **HasNodesField.field_options, &HasNodesField.field_block)
|
|
43
41
|
end
|
|
44
42
|
end
|
|
45
43
|
end
|
|
@@ -3,20 +3,8 @@ module GraphQL
|
|
|
3
3
|
module Types
|
|
4
4
|
module Relay
|
|
5
5
|
# The return type of a connection's `pageInfo` field
|
|
6
|
-
class PageInfo <
|
|
7
|
-
|
|
8
|
-
description "Information about pagination in a connection."
|
|
9
|
-
field :has_next_page, Boolean, null: false,
|
|
10
|
-
description: "When paginating forwards, are there more items?"
|
|
11
|
-
|
|
12
|
-
field :has_previous_page, Boolean, null: false,
|
|
13
|
-
description: "When paginating backwards, are there more items?"
|
|
14
|
-
|
|
15
|
-
field :start_cursor, String, null: true,
|
|
16
|
-
description: "When paginating backwards, the cursor to continue."
|
|
17
|
-
|
|
18
|
-
field :end_cursor, String, null: true,
|
|
19
|
-
description: "When paginating forwards, the cursor to continue."
|
|
6
|
+
class PageInfo < GraphQL::Schema::Object
|
|
7
|
+
include PageInfoBehaviors
|
|
20
8
|
end
|
|
21
9
|
end
|
|
22
10
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module GraphQL
|
|
3
|
+
module Types
|
|
4
|
+
module Relay
|
|
5
|
+
module PageInfoBehaviors
|
|
6
|
+
def self.included(child_class)
|
|
7
|
+
child_class.extend GraphQL::Types::Relay::DefaultRelay
|
|
8
|
+
|
|
9
|
+
child_class.description "Information about pagination in a connection."
|
|
10
|
+
child_class.field :has_next_page, Boolean, null: false,
|
|
11
|
+
description: "When paginating forwards, are there more items?"
|
|
12
|
+
|
|
13
|
+
child_class.field :has_previous_page, Boolean, null: false,
|
|
14
|
+
description: "When paginating backwards, are there more items?"
|
|
15
|
+
|
|
16
|
+
child_class.field :start_cursor, String, null: true,
|
|
17
|
+
description: "When paginating backwards, the cursor to continue."
|
|
18
|
+
|
|
19
|
+
child_class.field :end_cursor, String, null: true,
|
|
20
|
+
description: "When paginating forwards, the cursor to continue."
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/graphql/types/relay.rb
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
require "graphql/types/relay/
|
|
2
|
+
|
|
3
|
+
# behavior modules:
|
|
4
|
+
require "graphql/types/relay/default_relay"
|
|
5
|
+
require "graphql/types/relay/connection_behaviors"
|
|
6
|
+
require "graphql/types/relay/edge_behaviors"
|
|
7
|
+
require "graphql/types/relay/node_behaviors"
|
|
8
|
+
require "graphql/types/relay/page_info_behaviors"
|
|
9
|
+
require "graphql/types/relay/has_node_field"
|
|
10
|
+
require "graphql/types/relay/has_nodes_field"
|
|
11
|
+
|
|
12
|
+
# concrete classes based on the gem defaults:
|
|
5
13
|
require "graphql/types/relay/page_info"
|
|
6
14
|
require "graphql/types/relay/base_connection"
|
|
7
15
|
require "graphql/types/relay/base_edge"
|
data/lib/graphql/types/string.rb
CHANGED
|
@@ -7,9 +7,15 @@ module GraphQL
|
|
|
7
7
|
|
|
8
8
|
def self.coerce_result(value, ctx)
|
|
9
9
|
str = value.to_s
|
|
10
|
-
str.
|
|
10
|
+
if str.ascii_only? || str.encoding == Encoding::UTF_8
|
|
11
|
+
str
|
|
12
|
+
elsif str.frozen?
|
|
13
|
+
str.encode(Encoding::UTF_8)
|
|
14
|
+
else
|
|
15
|
+
str.encode!(Encoding::UTF_8)
|
|
16
|
+
end
|
|
11
17
|
rescue EncodingError
|
|
12
|
-
err = GraphQL::StringEncodingError.new(str)
|
|
18
|
+
err = GraphQL::StringEncodingError.new(str, context: ctx)
|
|
13
19
|
ctx.schema.type_error(err, ctx)
|
|
14
20
|
end
|
|
15
21
|
|
|
@@ -12,7 +12,7 @@ module GraphQL
|
|
|
12
12
|
attr_reader :type
|
|
13
13
|
|
|
14
14
|
# @return [GraphQL::Query::Context] the context for the current query
|
|
15
|
-
|
|
15
|
+
attr_accessor :context
|
|
16
16
|
|
|
17
17
|
def initialize(message = nil, object: nil, type: nil, context: nil)
|
|
18
18
|
if message.nil? && object.nil? && type.nil?
|
|
@@ -22,7 +22,7 @@ module GraphQL
|
|
|
22
22
|
@object = object
|
|
23
23
|
@type = type
|
|
24
24
|
@context = context
|
|
25
|
-
message ||= "An instance of #{object.class} failed #{type.
|
|
25
|
+
message ||= "An instance of #{object.class} failed #{type.graphql_name}'s authorization check"
|
|
26
26
|
super(message)
|
|
27
27
|
end
|
|
28
28
|
end
|
data/lib/graphql/union_type.rb
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
module GraphQL
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# The members of a union are declared with `possible_types`.
|
|
6
|
-
#
|
|
7
|
-
# @example A union of object types
|
|
8
|
-
# MediaUnion = GraphQL::UnionType.define do
|
|
9
|
-
# name "Media"
|
|
10
|
-
# description "Media objects which you can enjoy"
|
|
11
|
-
# possible_types [AudioType, ImageType, VideoType]
|
|
12
|
-
# end
|
|
13
|
-
#
|
|
14
|
-
# A union itself has no fields; only its members have fields.
|
|
15
|
-
# So, when you query, you must use fragment spreads to access fields.
|
|
16
|
-
#
|
|
17
|
-
# @example Querying for fields on union members
|
|
18
|
-
# {
|
|
19
|
-
# searchMedia(name: "Jens Lekman") {
|
|
20
|
-
# ... on Audio { name, duration }
|
|
21
|
-
# ... on Image { name, height, width }
|
|
22
|
-
# ... on Video { name, length, quality }
|
|
23
|
-
# }
|
|
24
|
-
# }
|
|
25
|
-
#
|
|
3
|
+
# @api deprecated
|
|
26
4
|
class UnionType < GraphQL::BaseType
|
|
5
|
+
extend Define::InstanceDefinable::DeprecatedDefine
|
|
6
|
+
|
|
27
7
|
# Rubocop was unhappy about the syntax when this was a proc literal
|
|
28
8
|
class AcceptPossibleTypesDefinition
|
|
29
9
|
def self.call(target, possible_types, options = {})
|
|
@@ -31,7 +11,7 @@ module GraphQL
|
|
|
31
11
|
end
|
|
32
12
|
end
|
|
33
13
|
|
|
34
|
-
|
|
14
|
+
deprecated_accepts_definitions :resolve_type, :type_membership_class,
|
|
35
15
|
possible_types: AcceptPossibleTypesDefinition
|
|
36
16
|
ensure_defined :possible_types, :resolve_type, :resolve_type_proc, :type_membership_class
|
|
37
17
|
|
|
@@ -96,7 +76,7 @@ module GraphQL
|
|
|
96
76
|
# @return [GraphQL::ObjectType, nil] The type named `type_name` if it exists and is a member of this {UnionType}, (else `nil`)
|
|
97
77
|
def get_possible_type(type_name, ctx)
|
|
98
78
|
type = ctx.query.get_type(type_name)
|
|
99
|
-
type if type && ctx.query.
|
|
79
|
+
type if type && ctx.query.warden.possible_types(self).include?(type)
|
|
100
80
|
end
|
|
101
81
|
|
|
102
82
|
# Check if a type is a possible type of this {UnionType}
|
|
@@ -24,8 +24,8 @@ module GraphQL
|
|
|
24
24
|
@parent_type = parent_type
|
|
25
25
|
@resolved_type = resolved_type
|
|
26
26
|
@possible_types = possible_types
|
|
27
|
-
message = "The value from \"#{field.
|
|
28
|
-
"(Received: `#{resolved_type.inspect}`, Expected: [#{possible_types.map(&:
|
|
27
|
+
message = "The value from \"#{field.graphql_name}\" on \"#{parent_type.graphql_name}\" could not be resolved to \"#{field.type.to_type_signature}\". " \
|
|
28
|
+
"(Received: `#{resolved_type.inspect}`, Expected: [#{possible_types.map(&:graphql_name).join(", ")}]) " \
|
|
29
29
|
"Make sure you have defined a `resolve_type` proc on your schema and that value `#{value.inspect}` " \
|
|
30
30
|
"gets resolved to a valid type. You may need to add your type to `orphan_types` if it implements an " \
|
|
31
31
|
"interface but isn't a return type of any other field."
|
|
@@ -771,6 +771,7 @@ module GraphQL
|
|
|
771
771
|
|
|
772
772
|
class Member
|
|
773
773
|
def initialize(member, skip: SkipOnNullKeyword, type_transforms: DEFAULT_TYPE_TRANSFORMS, field_transforms: DEFAULT_FIELD_TRANSFORMS, clean_up_transforms: DEFAULT_CLEAN_UP_TRANSFORMS)
|
|
774
|
+
GraphQL::Deprecation.warn "#{self.class} will be removed from GraphQL-Ruby 2.0 (but there's no point in using it after you've transformed your code, anyways)"
|
|
774
775
|
@member = member
|
|
775
776
|
@skip = skip
|
|
776
777
|
@type_transforms = type_transforms
|
data/lib/graphql/version.rb
CHANGED
data/lib/graphql.rb
CHANGED
|
@@ -4,15 +4,42 @@ require "json"
|
|
|
4
4
|
require "set"
|
|
5
5
|
require "singleton"
|
|
6
6
|
require "forwardable"
|
|
7
|
-
|
|
7
|
+
require "ostruct"
|
|
8
8
|
|
|
9
9
|
module GraphQL
|
|
10
|
+
# forwards-compat for argument handling
|
|
11
|
+
module Ruby2Keywords
|
|
12
|
+
if RUBY_VERSION < "2.7"
|
|
13
|
+
def ruby2_keywords(*)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
10
18
|
class Error < StandardError
|
|
11
19
|
end
|
|
12
20
|
|
|
21
|
+
# This error is raised when GraphQL-Ruby encounters a situation
|
|
22
|
+
# that it *thought* would never happen. Please report this bug!
|
|
23
|
+
class InvariantError < Error
|
|
24
|
+
def initialize(message)
|
|
25
|
+
message += "
|
|
26
|
+
|
|
27
|
+
This is probably a bug in GraphQL-Ruby, please report this error on GitHub: https://github.com/rmosolgo/graphql-ruby/issues/new?template=bug_report.md"
|
|
28
|
+
super(message)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
13
32
|
class RequiredImplementationMissingError < Error
|
|
14
33
|
end
|
|
15
34
|
|
|
35
|
+
class << self
|
|
36
|
+
def default_parser
|
|
37
|
+
@default_parser ||= GraphQL::Language::Parser
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
attr_writer :default_parser
|
|
41
|
+
end
|
|
42
|
+
|
|
16
43
|
# Turn a query string or schema definition into an AST
|
|
17
44
|
# @param graphql_string [String] a GraphQL query string or schema definition
|
|
18
45
|
# @return [GraphQL::Language::Nodes::Document]
|
|
@@ -40,28 +67,26 @@ module GraphQL
|
|
|
40
67
|
def self.scan_with_ragel(graphql_string)
|
|
41
68
|
GraphQL::Language::Lexer.tokenize(graphql_string)
|
|
42
69
|
end
|
|
43
|
-
|
|
44
|
-
# Support Ruby 2.2 by implementing `-"str"`. If we drop 2.2 support, we can remove this backport.
|
|
45
|
-
module StringDedupBackport
|
|
46
|
-
refine String do
|
|
47
|
-
def -@
|
|
48
|
-
if frozen?
|
|
49
|
-
self
|
|
50
|
-
else
|
|
51
|
-
self.dup.freeze
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
70
|
end
|
|
57
71
|
|
|
58
72
|
# Order matters for these:
|
|
59
73
|
|
|
60
74
|
require "graphql/execution_error"
|
|
75
|
+
require "graphql/runtime_type_error"
|
|
76
|
+
require "graphql/unresolved_type_error"
|
|
77
|
+
require "graphql/invalid_null_error"
|
|
78
|
+
require "graphql/analysis_error"
|
|
79
|
+
require "graphql/coercion_error"
|
|
80
|
+
require "graphql/invalid_name_error"
|
|
81
|
+
require "graphql/integer_decoding_error"
|
|
82
|
+
require "graphql/integer_encoding_error"
|
|
83
|
+
require "graphql/string_encoding_error"
|
|
84
|
+
require "graphql/date_encoding_error"
|
|
85
|
+
|
|
61
86
|
require "graphql/define"
|
|
87
|
+
require "graphql/deprecation"
|
|
62
88
|
require "graphql/base_type"
|
|
63
89
|
require "graphql/object_type"
|
|
64
|
-
|
|
65
90
|
require "graphql/enum_type"
|
|
66
91
|
require "graphql/input_object_type"
|
|
67
92
|
require "graphql/interface_type"
|
|
@@ -79,15 +104,23 @@ require "graphql/scalar_type"
|
|
|
79
104
|
require "graphql/name_validator"
|
|
80
105
|
|
|
81
106
|
require "graphql/language"
|
|
107
|
+
|
|
108
|
+
require_relative "./graphql/railtie" if defined? Rails::Railtie
|
|
109
|
+
|
|
82
110
|
require "graphql/analysis"
|
|
83
111
|
require "graphql/tracing"
|
|
84
|
-
require "graphql/execution"
|
|
85
112
|
require "graphql/dig"
|
|
113
|
+
require "graphql/execution"
|
|
114
|
+
require "graphql/pagination"
|
|
86
115
|
require "graphql/schema"
|
|
116
|
+
require "graphql/query"
|
|
117
|
+
require "graphql/types"
|
|
118
|
+
require "graphql/dataloader"
|
|
119
|
+
require "graphql/filter"
|
|
120
|
+
require "graphql/internal_representation"
|
|
87
121
|
require "graphql/directive"
|
|
122
|
+
require "graphql/static_validation"
|
|
88
123
|
require "graphql/execution"
|
|
89
|
-
require "graphql/types"
|
|
90
|
-
require "graphql/relay"
|
|
91
124
|
require "graphql/boolean_type"
|
|
92
125
|
require "graphql/float_type"
|
|
93
126
|
require "graphql/id_type"
|
|
@@ -97,23 +130,11 @@ require "graphql/schema/built_in_types"
|
|
|
97
130
|
require "graphql/schema/loader"
|
|
98
131
|
require "graphql/schema/printer"
|
|
99
132
|
require "graphql/introspection"
|
|
133
|
+
require "graphql/relay"
|
|
100
134
|
|
|
101
|
-
require "graphql/analysis_error"
|
|
102
|
-
require "graphql/coercion_error"
|
|
103
|
-
require "graphql/literal_validation_error"
|
|
104
|
-
require "graphql/runtime_type_error"
|
|
105
|
-
require "graphql/invalid_null_error"
|
|
106
|
-
require "graphql/invalid_name_error"
|
|
107
|
-
require "graphql/unresolved_type_error"
|
|
108
|
-
require "graphql/integer_encoding_error"
|
|
109
|
-
require "graphql/string_encoding_error"
|
|
110
|
-
require "graphql/query"
|
|
111
|
-
require "graphql/internal_representation"
|
|
112
|
-
require "graphql/static_validation"
|
|
113
135
|
require "graphql/version"
|
|
114
136
|
require "graphql/compatibility"
|
|
115
137
|
require "graphql/function"
|
|
116
|
-
require "graphql/filter"
|
|
117
138
|
require "graphql/subscriptions"
|
|
118
139
|
require "graphql/parse_error"
|
|
119
140
|
require "graphql/backtrace"
|
|
@@ -123,3 +144,38 @@ require "graphql/authorization"
|
|
|
123
144
|
require "graphql/unauthorized_error"
|
|
124
145
|
require "graphql/unauthorized_field_error"
|
|
125
146
|
require "graphql/load_application_object_failed_error"
|
|
147
|
+
require "graphql/directive/include_directive"
|
|
148
|
+
require "graphql/directive/skip_directive"
|
|
149
|
+
require "graphql/directive/deprecated_directive"
|
|
150
|
+
|
|
151
|
+
module GraphQL
|
|
152
|
+
# Ruby has `deprecate_constant`,
|
|
153
|
+
# but I don't see a way to give a nice error message in that case,
|
|
154
|
+
# so I'm doing this instead.
|
|
155
|
+
DEPRECATED_INT_TYPE = INT_TYPE
|
|
156
|
+
DEPRECATED_FLOAT_TYPE = FLOAT_TYPE
|
|
157
|
+
DEPRECATED_STRING_TYPE = STRING_TYPE
|
|
158
|
+
DEPRECATED_BOOLEAN_TYPE = BOOLEAN_TYPE
|
|
159
|
+
DEPRECATED_ID_TYPE = ID_TYPE
|
|
160
|
+
|
|
161
|
+
remove_const :INT_TYPE
|
|
162
|
+
remove_const :FLOAT_TYPE
|
|
163
|
+
remove_const :STRING_TYPE
|
|
164
|
+
remove_const :BOOLEAN_TYPE
|
|
165
|
+
remove_const :ID_TYPE
|
|
166
|
+
|
|
167
|
+
def self.const_missing(const_name)
|
|
168
|
+
deprecated_const_name = :"DEPRECATED_#{const_name}"
|
|
169
|
+
if const_defined?(deprecated_const_name)
|
|
170
|
+
deprecated_type = const_get(deprecated_const_name)
|
|
171
|
+
deprecated_caller = caller(1, 1).first
|
|
172
|
+
# Don't warn about internal uses, like `types.Int`
|
|
173
|
+
if !deprecated_caller.include?("lib/graphql")
|
|
174
|
+
warn "GraphQL::#{const_name} is deprecated and will be removed in GraphQL-Ruby 2.0, use GraphQL::Types::#{deprecated_type.graphql_name} instead. (from #{deprecated_caller})"
|
|
175
|
+
end
|
|
176
|
+
deprecated_type
|
|
177
|
+
else
|
|
178
|
+
super
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
data/readme.md
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
# graphql <img src="https://cloud.githubusercontent.com/assets/2231765/9094460/cb43861e-3b66-11e5-9fbf-71066ff3ab13.png" height="40" alt="graphql-ruby"/>
|
|
2
2
|
|
|
3
|
-
[](https://github.com/rmosolgo/graphql-ruby/actions/workflows/ci.yaml)
|
|
4
4
|
[](https://rubygems.org/gems/graphql)
|
|
5
|
-
[](https://codeclimate.com/github/rmosolgo/graphql-ruby)
|
|
6
|
-
[](https://codeclimate.com/github/rmosolgo/graphql-ruby)
|
|
7
|
-
[](https://rmosolgo.github.io/react-badges/)
|
|
8
5
|
|
|
9
6
|
A Ruby implementation of [GraphQL](https://graphql.org/).
|
|
10
7
|
|
|
11
8
|
- [Website](https://graphql-ruby.org/)
|
|
12
|
-
- [API Documentation](https://www.rubydoc.info/
|
|
9
|
+
- [API Documentation](https://www.rubydoc.info/github/rmosolgo/graphql-ruby)
|
|
13
10
|
- [Newsletter](https://tinyletter.com/graphql-ruby)
|
|
14
11
|
|
|
15
12
|
## Installation
|
|
@@ -47,6 +44,6 @@ I also sell [GraphQL::Pro](https://graphql.pro) which provides several features
|
|
|
47
44
|
|
|
48
45
|
## Getting Involved
|
|
49
46
|
|
|
50
|
-
- __Say hi & ask questions__ in the
|
|
47
|
+
- __Say hi & ask questions__ in the #graphql-ruby channel on [Discord](https://discord.com/invite/xud7bH9) or [on Twitter](https://twitter.com/rmosolgo)!
|
|
51
48
|
- __Report bugs__ by posting a description, full stack trace, and all relevant code in a [GitHub issue](https://github.com/rmosolgo/graphql-ruby/issues).
|
|
52
49
|
- __Start hacking__ with the [Development guide](https://graphql-ruby.org/development).
|