graphql 1.10.1 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/core.rb +18 -2
- data/lib/generators/graphql/install_generator.rb +36 -6
- data/lib/generators/graphql/loader_generator.rb +1 -0
- data/lib/generators/graphql/mutation_generator.rb +2 -1
- data/lib/generators/graphql/object_generator.rb +54 -9
- data/lib/generators/graphql/relay.rb +63 -0
- data/lib/generators/graphql/relay_generator.rb +21 -0
- 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_mutation.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 +2 -0
- data/lib/generators/graphql/templates/graphql_controller.erb +16 -12
- data/lib/generators/graphql/templates/interface.erb +2 -0
- data/lib/generators/graphql/templates/loader.erb +2 -0
- data/lib/generators/graphql/templates/mutation.erb +2 -0
- data/lib/generators/graphql/templates/mutation_type.erb +2 -0
- data/lib/generators/graphql/templates/node_type.erb +9 -0
- data/lib/generators/graphql/templates/object.erb +3 -1
- data/lib/generators/graphql/templates/query_type.erb +3 -3
- data/lib/generators/graphql/templates/scalar.erb +2 -0
- data/lib/generators/graphql/templates/schema.erb +21 -33
- data/lib/generators/graphql/templates/union.erb +3 -1
- data/lib/generators/graphql/type_generator.rb +1 -1
- data/lib/graphql/analysis/analyze_query.rb +7 -0
- data/lib/graphql/analysis/ast/field_usage.rb +24 -1
- data/lib/graphql/analysis/ast/query_complexity.rb +126 -109
- data/lib/graphql/analysis/ast/visitor.rb +13 -5
- data/lib/graphql/analysis/ast.rb +11 -2
- data/lib/graphql/argument.rb +3 -3
- data/lib/graphql/backtrace/inspect_result.rb +0 -1
- data/lib/graphql/backtrace/legacy_tracer.rb +56 -0
- data/lib/graphql/backtrace/table.rb +34 -3
- 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 +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.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/define/assign_global_id_field.rb +2 -2
- data/lib/graphql/define/defined_object_proxy.rb +1 -1
- data/lib/graphql/define/instance_definable.rb +34 -4
- 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.rb +4 -4
- data/lib/graphql/enum_type.rb +7 -1
- data/lib/graphql/execution/errors.rb +110 -7
- 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 +103 -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 +685 -421
- data/lib/graphql/execution/interpreter.rb +42 -13
- data/lib/graphql/execution/lazy.rb +5 -1
- data/lib/graphql/execution/lookahead.rb +25 -110
- data/lib/graphql/execution/multiplex.rb +37 -25
- data/lib/graphql/field.rb +5 -1
- data/lib/graphql/function.rb +4 -0
- data/lib/graphql/input_object_type.rb +6 -0
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +18 -2
- data/lib/graphql/interface_type.rb +7 -0
- 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/directive_type.rb +8 -4
- data/lib/graphql/introspection/entry_points.rb +2 -2
- 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 +15 -3
- data/lib/graphql/introspection/introspection_query.rb +6 -92
- data/lib/graphql/introspection/schema_type.rb +4 -4
- data/lib/graphql/introspection/type_type.rb +16 -12
- data/lib/graphql/introspection.rb +96 -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/document_from_schema_definition.rb +73 -25
- data/lib/graphql/language/lexer.rb +4 -3
- data/lib/graphql/language/lexer.rl +3 -3
- data/lib/graphql/language/nodes.rb +51 -89
- data/lib/graphql/language/parser.rb +552 -530
- data/lib/graphql/language/parser.y +114 -99
- data/lib/graphql/language/printer.rb +7 -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 +2 -0
- data/lib/graphql/name_validator.rb +2 -7
- data/lib/graphql/object_type.rb +44 -35
- data/lib/graphql/pagination/active_record_relation_connection.rb +14 -1
- data/lib/graphql/pagination/array_connection.rb +2 -2
- data/lib/graphql/pagination/connection.rb +75 -20
- data/lib/graphql/pagination/connections.rb +83 -31
- data/lib/graphql/pagination/relation_connection.rb +34 -14
- data/lib/graphql/parse_error.rb +0 -1
- data/lib/graphql/query/arguments.rb +4 -3
- data/lib/graphql/query/arguments_cache.rb +1 -2
- data/lib/graphql/query/context.rb +42 -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 +23 -6
- data/lib/graphql/query/literal_input.rb +1 -1
- 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 +5 -2
- data/lib/graphql/query/variable_validation_error.rb +1 -1
- data/lib/graphql/query/variables.rb +14 -4
- data/lib/graphql/query.rb +68 -13
- data/lib/graphql/railtie.rb +9 -1
- data/lib/graphql/rake_task.rb +12 -9
- data/lib/graphql/relay/array_connection.rb +10 -12
- data/lib/graphql/relay/base_connection.rb +26 -13
- data/lib/graphql/relay/connection_instrumentation.rb +4 -4
- data/lib/graphql/relay/connection_type.rb +1 -1
- data/lib/graphql/relay/edges_instrumentation.rb +0 -1
- data/lib/graphql/relay/mutation.rb +1 -0
- data/lib/graphql/relay/node.rb +3 -0
- data/lib/graphql/relay/range_add.rb +23 -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 +16 -1
- data/lib/graphql/schema/addition.rb +247 -0
- data/lib/graphql/schema/argument.rb +210 -12
- data/lib/graphql/schema/base_64_encoder.rb +2 -0
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +3 -1
- data/lib/graphql/schema/build_from_definition.rb +213 -86
- data/lib/graphql/schema/default_type_error.rb +2 -0
- data/lib/graphql/schema/directive/deprecated.rb +1 -1
- 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 +1 -1
- data/lib/graphql/schema/directive/skip.rb +1 -1
- data/lib/graphql/schema/directive/transform.rb +14 -2
- data/lib/graphql/schema/directive.rb +78 -2
- data/lib/graphql/schema/enum.rb +80 -9
- data/lib/graphql/schema/enum_value.rb +17 -6
- data/lib/graphql/schema/field/connection_extension.rb +46 -30
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +285 -133
- data/lib/graphql/schema/find_inherited_value.rb +4 -1
- data/lib/graphql/schema/finder.rb +5 -5
- data/lib/graphql/schema/input_object.rb +97 -89
- data/lib/graphql/schema/interface.rb +24 -19
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/list.rb +7 -1
- data/lib/graphql/schema/loader.rb +137 -103
- data/lib/graphql/schema/member/accepts_definition.rb +8 -1
- data/lib/graphql/schema/member/base_dsl_methods.rb +15 -19
- data/lib/graphql/schema/member/build_type.rb +14 -7
- data/lib/graphql/schema/member/has_arguments.rb +205 -12
- data/lib/graphql/schema/member/has_ast_node.rb +4 -1
- 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 +95 -30
- data/lib/graphql/schema/member/has_interfaces.rb +90 -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.rb +6 -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 +5 -0
- data/lib/graphql/schema/object.rb +47 -46
- data/lib/graphql/schema/possible_types.rb +9 -4
- data/lib/graphql/schema/printer.rb +16 -34
- data/lib/graphql/schema/relay_classic_mutation.rb +32 -4
- data/lib/graphql/schema/resolver/has_payload_type.rb +34 -4
- data/lib/graphql/schema/resolver.rb +123 -63
- data/lib/graphql/schema/scalar.rb +11 -1
- 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/type_expression.rb +1 -1
- data/lib/graphql/schema/type_membership.rb +18 -4
- data/lib/graphql/schema/union.rb +41 -1
- data/lib/graphql/schema/unique_within_type.rb +1 -2
- data/lib/graphql/schema/validation.rb +12 -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 +68 -0
- data/lib/graphql/schema/validator.rb +174 -0
- data/lib/graphql/schema/warden.rb +153 -28
- data/lib/graphql/schema.rb +364 -330
- data/lib/graphql/static_validation/all_rules.rb +1 -0
- data/lib/graphql/static_validation/base_visitor.rb +8 -5
- 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 +44 -87
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +22 -6
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +28 -22
- 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/fields_will_merge.rb +79 -43
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +25 -4
- 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/required_arguments_are_present.rb +1 -1
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +6 -7
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +9 -10
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +8 -8
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +4 -2
- data/lib/graphql/static_validation/validation_context.rb +9 -3
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +42 -8
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/string_encoding_error.rb +13 -3
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +118 -19
- 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 +81 -30
- data/lib/graphql/subscriptions/instrumentation.rb +0 -1
- data/lib/graphql/subscriptions/serialize.rb +33 -6
- data/lib/graphql/subscriptions/subscription_root.rb +15 -4
- data/lib/graphql/subscriptions.rb +88 -45
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +2 -1
- data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
- data/lib/graphql/tracing/appsignal_tracing.rb +15 -0
- data/lib/graphql/tracing/new_relic_tracing.rb +1 -12
- data/lib/graphql/tracing/platform_tracing.rb +43 -17
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +4 -1
- data/lib/graphql/tracing/scout_tracing.rb +11 -0
- data/lib/graphql/tracing/skylight_tracing.rb +1 -1
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +9 -33
- 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 +3 -3
- data/lib/graphql/types/iso_8601_date_time.rb +25 -10
- data/lib/graphql/types/relay/base_connection.rb +6 -90
- data/lib/graphql/types/relay/base_edge.rb +2 -34
- data/lib/graphql/types/relay/connection_behaviors.rb +156 -0
- data/lib/graphql/types/relay/default_relay.rb +27 -0
- data/lib/graphql/types/relay/edge_behaviors.rb +53 -0
- data/lib/graphql/types/relay/has_node_field.rb +41 -0
- data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
- data/lib/graphql/types/relay/node.rb +2 -4
- data/lib/graphql/types/relay/node_behaviors.rb +15 -0
- data/lib/graphql/types/relay/node_field.rb +2 -20
- data/lib/graphql/types/relay/nodes_field.rb +2 -20
- 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 +2 -0
- 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 +65 -31
- data/readme.md +3 -6
- metadata +77 -112
- 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
@@ -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
|
@@ -6,7 +6,7 @@ module GraphQL
|
|
6
6
|
# or use it for inspiration for your own field definition.
|
7
7
|
#
|
8
8
|
# @example Adding this field directly
|
9
|
-
#
|
9
|
+
# include GraphQL::Types::Relay::HasNodeField
|
10
10
|
#
|
11
11
|
# @example Implementing a similar field in your own Query root
|
12
12
|
#
|
@@ -19,25 +19,7 @@ module GraphQL
|
|
19
19
|
# context.schema.object_from_id(id, context)
|
20
20
|
# end
|
21
21
|
#
|
22
|
-
NodeField = GraphQL::Schema::Field.new(
|
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
|
22
|
+
NodeField = GraphQL::Schema::Field.new(owner: nil, **HasNodeField.field_options, &HasNodeField.field_block)
|
41
23
|
end
|
42
24
|
end
|
43
25
|
end
|
@@ -6,7 +6,7 @@ module GraphQL
|
|
6
6
|
# or use it for inspiration for your own field definition.
|
7
7
|
#
|
8
8
|
# @example Adding this field directly
|
9
|
-
#
|
9
|
+
# include GraphQL::Types::Relay::HasNodesField
|
10
10
|
#
|
11
11
|
# @example Implementing a similar field in your own Query root
|
12
12
|
#
|
@@ -21,25 +21,7 @@ module GraphQL
|
|
21
21
|
# end
|
22
22
|
# end
|
23
23
|
#
|
24
|
-
NodesField = GraphQL::Schema::Field.new(
|
25
|
-
name: "nodes",
|
26
|
-
owner: nil,
|
27
|
-
type: [GraphQL::Types::Relay::Node, null: true],
|
28
|
-
null: false,
|
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."
|
34
|
-
|
35
|
-
def resolve(obj, args, ctx)
|
36
|
-
args[:ids].map { |id| ctx.schema.object_from_id(id, ctx) }
|
37
|
-
end
|
38
|
-
|
39
|
-
def resolve_field(obj, args, ctx)
|
40
|
-
resolve(obj, args, ctx)
|
41
|
-
end
|
42
|
-
end
|
24
|
+
NodesField = GraphQL::Schema::Field.new(owner: nil, **HasNodesField.field_options, &HasNodesField.field_block)
|
43
25
|
end
|
44
26
|
end
|
45
27
|
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.encoding == Encoding::UTF_8
|
10
|
+
if 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
@@ -2,6 +2,8 @@
|
|
2
2
|
module GraphQL
|
3
3
|
# @api deprecated
|
4
4
|
class UnionType < GraphQL::BaseType
|
5
|
+
extend Define::InstanceDefinable::DeprecatedDefine
|
6
|
+
|
5
7
|
# Rubocop was unhappy about the syntax when this was a proc literal
|
6
8
|
class AcceptPossibleTypesDefinition
|
7
9
|
def self.call(target, possible_types, options = {})
|
@@ -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,7 +4,6 @@ require "json"
|
|
4
4
|
require "set"
|
5
5
|
require "singleton"
|
6
6
|
require "forwardable"
|
7
|
-
require_relative "./graphql/railtie" if defined? Rails::Railtie
|
8
7
|
|
9
8
|
module GraphQL
|
10
9
|
# forwards-compat for argument handling
|
@@ -21,6 +20,14 @@ module GraphQL
|
|
21
20
|
class RequiredImplementationMissingError < Error
|
22
21
|
end
|
23
22
|
|
23
|
+
class << self
|
24
|
+
def default_parser
|
25
|
+
@default_parser ||= GraphQL::Language::Parser
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_writer :default_parser
|
29
|
+
end
|
30
|
+
|
24
31
|
# Turn a query string or schema definition into an AST
|
25
32
|
# @param graphql_string [String] a GraphQL query string or schema definition
|
26
33
|
# @return [GraphQL::Language::Nodes::Document]
|
@@ -48,28 +55,24 @@ module GraphQL
|
|
48
55
|
def self.scan_with_ragel(graphql_string)
|
49
56
|
GraphQL::Language::Lexer.tokenize(graphql_string)
|
50
57
|
end
|
51
|
-
|
52
|
-
# Support Ruby 2.2 by implementing `-"str"`. If we drop 2.2 support, we can remove this backport.
|
53
|
-
module StringDedupBackport
|
54
|
-
refine String do
|
55
|
-
def -@
|
56
|
-
if frozen?
|
57
|
-
self
|
58
|
-
else
|
59
|
-
self.dup.freeze
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
58
|
end
|
65
59
|
|
66
60
|
# Order matters for these:
|
67
61
|
|
68
62
|
require "graphql/execution_error"
|
63
|
+
require "graphql/runtime_type_error"
|
64
|
+
require "graphql/unresolved_type_error"
|
65
|
+
require "graphql/invalid_null_error"
|
66
|
+
require "graphql/analysis_error"
|
67
|
+
require "graphql/coercion_error"
|
68
|
+
require "graphql/invalid_name_error"
|
69
|
+
require "graphql/integer_decoding_error"
|
70
|
+
require "graphql/integer_encoding_error"
|
71
|
+
require "graphql/string_encoding_error"
|
72
|
+
|
69
73
|
require "graphql/define"
|
70
74
|
require "graphql/base_type"
|
71
75
|
require "graphql/object_type"
|
72
|
-
|
73
76
|
require "graphql/enum_type"
|
74
77
|
require "graphql/input_object_type"
|
75
78
|
require "graphql/interface_type"
|
@@ -87,16 +90,23 @@ require "graphql/scalar_type"
|
|
87
90
|
require "graphql/name_validator"
|
88
91
|
|
89
92
|
require "graphql/language"
|
93
|
+
|
94
|
+
require_relative "./graphql/railtie" if defined? Rails::Railtie
|
95
|
+
|
90
96
|
require "graphql/analysis"
|
91
97
|
require "graphql/tracing"
|
92
|
-
require "graphql/execution"
|
93
98
|
require "graphql/dig"
|
99
|
+
require "graphql/execution"
|
100
|
+
require "graphql/pagination"
|
94
101
|
require "graphql/schema"
|
95
102
|
require "graphql/query"
|
103
|
+
require "graphql/types"
|
104
|
+
require "graphql/dataloader"
|
105
|
+
require "graphql/filter"
|
106
|
+
require "graphql/internal_representation"
|
96
107
|
require "graphql/directive"
|
108
|
+
require "graphql/static_validation"
|
97
109
|
require "graphql/execution"
|
98
|
-
require "graphql/types"
|
99
|
-
require "graphql/relay"
|
100
110
|
require "graphql/boolean_type"
|
101
111
|
require "graphql/float_type"
|
102
112
|
require "graphql/id_type"
|
@@ -106,22 +116,11 @@ require "graphql/schema/built_in_types"
|
|
106
116
|
require "graphql/schema/loader"
|
107
117
|
require "graphql/schema/printer"
|
108
118
|
require "graphql/introspection"
|
119
|
+
require "graphql/relay"
|
109
120
|
|
110
|
-
require "graphql/analysis_error"
|
111
|
-
require "graphql/coercion_error"
|
112
|
-
require "graphql/literal_validation_error"
|
113
|
-
require "graphql/runtime_type_error"
|
114
|
-
require "graphql/invalid_null_error"
|
115
|
-
require "graphql/invalid_name_error"
|
116
|
-
require "graphql/unresolved_type_error"
|
117
|
-
require "graphql/integer_encoding_error"
|
118
|
-
require "graphql/string_encoding_error"
|
119
|
-
require "graphql/internal_representation"
|
120
|
-
require "graphql/static_validation"
|
121
121
|
require "graphql/version"
|
122
122
|
require "graphql/compatibility"
|
123
123
|
require "graphql/function"
|
124
|
-
require "graphql/filter"
|
125
124
|
require "graphql/subscriptions"
|
126
125
|
require "graphql/parse_error"
|
127
126
|
require "graphql/backtrace"
|
@@ -131,4 +130,39 @@ require "graphql/authorization"
|
|
131
130
|
require "graphql/unauthorized_error"
|
132
131
|
require "graphql/unauthorized_field_error"
|
133
132
|
require "graphql/load_application_object_failed_error"
|
134
|
-
require "graphql/
|
133
|
+
require "graphql/deprecation"
|
134
|
+
require "graphql/directive/include_directive"
|
135
|
+
require "graphql/directive/skip_directive"
|
136
|
+
require "graphql/directive/deprecated_directive"
|
137
|
+
|
138
|
+
module GraphQL
|
139
|
+
# Ruby has `deprecate_constant`,
|
140
|
+
# but I don't see a way to give a nice error message in that case,
|
141
|
+
# so I'm doing this instead.
|
142
|
+
DEPRECATED_INT_TYPE = INT_TYPE
|
143
|
+
DEPRECATED_FLOAT_TYPE = FLOAT_TYPE
|
144
|
+
DEPRECATED_STRING_TYPE = STRING_TYPE
|
145
|
+
DEPRECATED_BOOLEAN_TYPE = BOOLEAN_TYPE
|
146
|
+
DEPRECATED_ID_TYPE = ID_TYPE
|
147
|
+
|
148
|
+
remove_const :INT_TYPE
|
149
|
+
remove_const :FLOAT_TYPE
|
150
|
+
remove_const :STRING_TYPE
|
151
|
+
remove_const :BOOLEAN_TYPE
|
152
|
+
remove_const :ID_TYPE
|
153
|
+
|
154
|
+
def self.const_missing(const_name)
|
155
|
+
deprecated_const_name = :"DEPRECATED_#{const_name}"
|
156
|
+
if const_defined?(deprecated_const_name)
|
157
|
+
deprecated_type = const_get(deprecated_const_name)
|
158
|
+
deprecated_caller = caller(1, 1).first
|
159
|
+
# Don't warn about internal uses, like `types.Int`
|
160
|
+
if !deprecated_caller.include?("lib/graphql")
|
161
|
+
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})"
|
162
|
+
end
|
163
|
+
deprecated_type
|
164
|
+
else
|
165
|
+
super
|
166
|
+
end
|
167
|
+
end
|
168
|
+
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
|
-
[![
|
3
|
+
[![CI Suite](https://github.com/rmosolgo/graphql-ruby/actions/workflows/ci.yaml/badge.svg)](https://github.com/rmosolgo/graphql-ruby/actions/workflows/ci.yaml)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/graphql.svg)](https://rubygems.org/gems/graphql)
|
5
|
-
[![Code Climate](https://codeclimate.com/github/rmosolgo/graphql-ruby/badges/gpa.svg)](https://codeclimate.com/github/rmosolgo/graphql-ruby)
|
6
|
-
[![Test Coverage](https://codeclimate.com/github/rmosolgo/graphql-ruby/badges/coverage.svg)](https://codeclimate.com/github/rmosolgo/graphql-ruby)
|
7
|
-
[![built with love](https://cloud.githubusercontent.com/assets/2231765/6766607/d07992c6-cfc9-11e4-813f-d9240714dd50.png)](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).
|