graphql 2.5.21 → 2.5.23
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/graphql/execution/interpreter/runtime.rb +3 -2
- data/lib/graphql/execution/interpreter.rb +6 -9
- data/lib/graphql/execution/lazy.rb +1 -1
- data/lib/graphql/execution/next/field_resolve_step.rb +114 -61
- data/lib/graphql/execution/next/load_argument_step.rb +5 -1
- data/lib/graphql/execution/next/prepare_object_step.rb +2 -2
- data/lib/graphql/execution/next/runner.rb +48 -26
- data/lib/graphql/execution/next.rb +5 -2
- data/lib/graphql/execution.rb +7 -4
- data/lib/graphql/execution_error.rb +5 -1
- data/lib/graphql/query/context.rb +1 -1
- data/lib/graphql/schema/field.rb +8 -5
- data/lib/graphql/schema/list.rb +1 -1
- data/lib/graphql/schema/member/has_dataloader.rb +20 -0
- data/lib/graphql/schema/member/has_fields.rb +6 -1
- data/lib/graphql/schema/non_null.rb +1 -1
- data/lib/graphql/schema/resolver.rb +18 -3
- data/lib/graphql/schema/subscription.rb +0 -2
- data/lib/graphql/schema/visibility/profile.rb +68 -49
- data/lib/graphql/schema/wrapper.rb +7 -1
- data/lib/graphql/static_validation/base_visitor.rb +90 -66
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +1 -1
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +18 -6
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +5 -2
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +5 -2
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +4 -3
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +12 -2
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +322 -256
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +4 -4
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +10 -7
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +27 -7
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +12 -9
- data/lib/graphql/static_validation/validation_context.rb +1 -1
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +25 -1
- data/lib/graphql/subscriptions/event.rb +1 -0
- data/lib/graphql/subscriptions.rb +20 -0
- data/lib/graphql/tracing/perfetto_trace.rb +2 -2
- data/lib/graphql/unauthorized_error.rb +4 -0
- data/lib/graphql/version.rb +1 -1
- metadata +3 -3
|
@@ -10,9 +10,12 @@ module GraphQL
|
|
|
10
10
|
if !@types.directive_exists?(node.name)
|
|
11
11
|
@directives_are_defined_errors_by_name ||= {}
|
|
12
12
|
error = @directives_are_defined_errors_by_name[node.name] ||= begin
|
|
13
|
-
|
|
13
|
+
suggestion = if @schema.did_you_mean
|
|
14
|
+
@directive_names ||= @types.directives.map(&:graphql_name)
|
|
15
|
+
context.did_you_mean_suggestion(node.name, @directive_names)
|
|
16
|
+
end
|
|
14
17
|
err = GraphQL::StaticValidation::DirectivesAreDefinedError.new(
|
|
15
|
-
"Directive @#{node.name} is not defined#{
|
|
18
|
+
"Directive @#{node.name} is not defined#{suggestion}",
|
|
16
19
|
nodes: [],
|
|
17
20
|
directive: node.name
|
|
18
21
|
)
|
|
@@ -3,7 +3,7 @@ module GraphQL
|
|
|
3
3
|
module StaticValidation
|
|
4
4
|
module FieldsAreDefinedOnType
|
|
5
5
|
def on_field(node, parent)
|
|
6
|
-
parent_type = @
|
|
6
|
+
parent_type = @parent_object_type
|
|
7
7
|
field = context.query.types.field(parent_type, node.name)
|
|
8
8
|
|
|
9
9
|
if field.nil?
|
|
@@ -14,8 +14,9 @@ module GraphQL
|
|
|
14
14
|
node_name: parent_type.graphql_name
|
|
15
15
|
))
|
|
16
16
|
else
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
suggestion = if @schema.did_you_mean
|
|
18
|
+
context.did_you_mean_suggestion(node.name, possible_fields(context, parent_type))
|
|
19
|
+
end
|
|
19
20
|
message = "Field '#{node.name}' doesn't exist on type '#{parent_type.graphql_name}'#{suggestion}"
|
|
20
21
|
add_error(GraphQL::StaticValidation::FieldsAreDefinedOnTypeError.new(
|
|
21
22
|
message,
|
|
@@ -7,8 +7,7 @@ module GraphQL
|
|
|
7
7
|
include GraphQL::StaticValidation::Error::ErrorHelper
|
|
8
8
|
|
|
9
9
|
def on_field(node, parent)
|
|
10
|
-
|
|
11
|
-
if validate_field_selections(node, field_defn.type.unwrap)
|
|
10
|
+
if validate_field_selections(node, @current_object_type)
|
|
12
11
|
super
|
|
13
12
|
end
|
|
14
13
|
end
|
|
@@ -23,6 +22,17 @@ module GraphQL
|
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
def validate_field_selections(ast_node, resolved_type)
|
|
25
|
+
# Fast paths for the two most common cases:
|
|
26
|
+
# 1. Leaf type with no selections (scalars, enums) — most fields
|
|
27
|
+
# 2. Non-leaf type with selections (objects, interfaces)
|
|
28
|
+
if resolved_type
|
|
29
|
+
if ast_node.selections.empty?
|
|
30
|
+
return true if resolved_type.kind.leaf?
|
|
31
|
+
else
|
|
32
|
+
return true unless resolved_type.kind.leaf?
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
26
36
|
msg = if resolved_type.nil?
|
|
27
37
|
nil
|
|
28
38
|
elsif resolved_type.kind.leaf?
|