graphql 1.11.2 → 1.11.3
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/schema/argument.rb +0 -5
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +3 -1
- data/lib/graphql/schema/field/connection_extension.rb +42 -36
- data/lib/graphql/schema/member/has_fields.rb +15 -5
- data/lib/graphql/schema/mutation.rb +4 -0
- data/lib/graphql/schema/resolver.rb +6 -0
- data/lib/graphql/schema/resolver/has_payload_type.rb +2 -1
- data/lib/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f64724e3b46476cf0a622ef5d5d1beb4360c7d5de031907d5173cb462928ee4
|
4
|
+
data.tar.gz: 9b8098bab2bfdc704bf98dc011a452f1bce8c480c9435f1b37a79430ee81bc06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dabc15fe0688fc37233e23f5bc5647bf55ad176456257c088e15a87f7fabc07b6da43e86efcd9e982ecfc8b47c6eca331a0ced9a82f20076c21aa4ccf20f223
|
7
|
+
data.tar.gz: d98a3193ab5759d206aabf9db378c38c669cbc2752f4b8908484fcf2cbee9012f00721403ffe999cd19e43016a6b27bd2c0f5f1dc602b93543772f1e7a4791b5
|
@@ -61,11 +61,6 @@ module GraphQL
|
|
61
61
|
@from_resolver = from_resolver
|
62
62
|
@method_access = method_access
|
63
63
|
|
64
|
-
if !@null && default_value?
|
65
|
-
raise ArgumentError, "Argument '#{@name}' has conflicting params, " \
|
66
|
-
"either use `required: false` or remove `default_value:`."
|
67
|
-
end
|
68
|
-
|
69
64
|
if definition_block
|
70
65
|
if definition_block.arity == 1
|
71
66
|
instance_exec(self, &definition_block)
|
@@ -45,8 +45,10 @@ module GraphQL
|
|
45
45
|
@resolve_hash[type_name_s][field_name.to_s] = resolve_fn
|
46
46
|
end
|
47
47
|
when Proc
|
48
|
-
# for example,
|
48
|
+
# for example, "resolve_type"
|
49
49
|
@resolve_hash[type_name_s] = fields
|
50
|
+
else
|
51
|
+
raise ArgumentError, "Unexpected resolve hash value for #{type_name.inspect}: #{fields.inspect} (#{fields.class})"
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -22,43 +22,49 @@ module GraphQL
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def after_resolve(value:, object:, arguments:, context:, memo:)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
value.
|
35
|
-
|
36
|
-
value.
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
value.
|
25
|
+
# rename some inputs to avoid conflicts inside the block
|
26
|
+
maybe_lazy = value
|
27
|
+
value = nil
|
28
|
+
context.schema.after_lazy(maybe_lazy) do |resolved_value|
|
29
|
+
value = resolved_value
|
30
|
+
if value.is_a? GraphQL::ExecutionError
|
31
|
+
# This isn't even going to work because context doesn't have ast_node anymore
|
32
|
+
context.add_error(value)
|
33
|
+
nil
|
34
|
+
elsif value.nil?
|
35
|
+
nil
|
36
|
+
elsif value.is_a?(GraphQL::Pagination::Connection)
|
37
|
+
# update the connection with some things that may not have been provided
|
38
|
+
value.context ||= context
|
39
|
+
value.parent ||= object.object
|
40
|
+
value.first_value ||= arguments[:first]
|
41
|
+
value.after_value ||= arguments[:after]
|
42
|
+
value.last_value ||= arguments[:last]
|
43
|
+
value.before_value ||= arguments[:before]
|
44
|
+
if field.has_max_page_size? && !value.has_max_page_size_override?
|
45
|
+
value.max_page_size = field.max_page_size
|
46
|
+
end
|
47
|
+
if (custom_t = context.schema.connections.edge_class_for_field(@field))
|
48
|
+
value.edge_class = custom_t
|
49
|
+
end
|
50
|
+
value
|
51
|
+
elsif context.schema.new_connections?
|
52
|
+
wrappers = context.namespace(:connections)[:all_wrappers] ||= context.schema.connections.all_wrappers
|
53
|
+
context.schema.connections.wrap(field, object.object, value, arguments, context, wrappers: wrappers)
|
54
|
+
else
|
55
|
+
if object.is_a?(GraphQL::Schema::Object)
|
56
|
+
object = object.object
|
57
|
+
end
|
58
|
+
connection_class = GraphQL::Relay::BaseConnection.connection_for_nodes(value)
|
59
|
+
connection_class.new(
|
60
|
+
value,
|
61
|
+
arguments,
|
62
|
+
field: field,
|
63
|
+
max_page_size: field.max_page_size,
|
64
|
+
parent: object,
|
65
|
+
context: context,
|
66
|
+
)
|
41
67
|
end
|
42
|
-
if (custom_t = context.schema.connections.edge_class_for_field(@field))
|
43
|
-
value.edge_class = custom_t
|
44
|
-
end
|
45
|
-
value
|
46
|
-
elsif context.schema.new_connections?
|
47
|
-
wrappers = context.namespace(:connections)[:all_wrappers] ||= context.schema.connections.all_wrappers
|
48
|
-
context.schema.connections.wrap(field, object.object, value, arguments, context, wrappers: wrappers)
|
49
|
-
else
|
50
|
-
if object.is_a?(GraphQL::Schema::Object)
|
51
|
-
object = object.object
|
52
|
-
end
|
53
|
-
connection_class = GraphQL::Relay::BaseConnection.connection_for_nodes(value)
|
54
|
-
connection_class.new(
|
55
|
-
value,
|
56
|
-
arguments,
|
57
|
-
field: field,
|
58
|
-
max_page_size: field.max_page_size,
|
59
|
-
parent: object,
|
60
|
-
context: context,
|
61
|
-
)
|
62
68
|
end
|
63
69
|
end
|
64
70
|
end
|
@@ -47,20 +47,22 @@ module GraphQL
|
|
47
47
|
# A list of GraphQL-Ruby keywords.
|
48
48
|
#
|
49
49
|
# @api private
|
50
|
-
GRAPHQL_RUBY_KEYWORDS = [:context, :object, :
|
50
|
+
GRAPHQL_RUBY_KEYWORDS = [:context, :object, :raw_value]
|
51
51
|
|
52
52
|
# A list of field names that we should advise users to pick a different
|
53
53
|
# resolve method name.
|
54
54
|
#
|
55
55
|
# @api private
|
56
|
-
CONFLICT_FIELD_NAMES = Set.new(GRAPHQL_RUBY_KEYWORDS + RUBY_KEYWORDS)
|
56
|
+
CONFLICT_FIELD_NAMES = Set.new(GRAPHQL_RUBY_KEYWORDS + RUBY_KEYWORDS + Object.instance_methods)
|
57
57
|
|
58
58
|
# Register this field with the class, overriding a previous one if needed.
|
59
59
|
# @param field_defn [GraphQL::Schema::Field]
|
60
60
|
# @return [void]
|
61
|
-
def add_field(field_defn)
|
62
|
-
|
63
|
-
|
61
|
+
def add_field(field_defn, method_conflict_warning: field_defn.method_conflict_warning?)
|
62
|
+
# Check that `field_defn.original_name` equals `resolver_method` and `method_sym` --
|
63
|
+
# that shows that no override value was given manually.
|
64
|
+
if method_conflict_warning && CONFLICT_FIELD_NAMES.include?(field_defn.resolver_method) && field_defn.original_name == field_defn.resolver_method && field_defn.original_name == field_defn.method_sym
|
65
|
+
warn(conflict_field_name_warning(field_defn))
|
64
66
|
end
|
65
67
|
own_fields[field_defn.name] = field_defn
|
66
68
|
nil
|
@@ -92,6 +94,14 @@ module GraphQL
|
|
92
94
|
def own_fields
|
93
95
|
@own_fields ||= {}
|
94
96
|
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
# @param [GraphQL::Schema::Field]
|
101
|
+
# @return [String] A warning to give when this field definition might conflict with a built-in method
|
102
|
+
def conflict_field_name_warning(field_defn)
|
103
|
+
"#{self.graphql_name}'s `field :#{field_defn.original_name}` conflicts with a built-in method, use `resolver_method:` to pick a different resolver method for this field (for example, `resolver_method: :resolve_#{field_defn.resolver_method}` and `def resolve_#{field_defn.resolver_method}`). Or use `method_conflict_warning: false` to suppress this warning."
|
104
|
+
end
|
95
105
|
end
|
96
106
|
end
|
97
107
|
end
|
@@ -78,6 +78,10 @@ module GraphQL
|
|
78
78
|
|
79
79
|
private
|
80
80
|
|
81
|
+
def conflict_field_name_warning(field_defn)
|
82
|
+
"#{self.graphql_name}'s `field :#{field_defn.name}` conflicts with a built-in method, use `hash_key:` or `method:` to pick a different resolve behavior for this field (for example, `hash_key: :#{field_defn.resolver_method}_value`, and modify the return hash). Or use `method_conflict_warning: false` to suppress this warning."
|
83
|
+
end
|
84
|
+
|
81
85
|
# Override this to attach self as `mutation`
|
82
86
|
def generate_payload_type
|
83
87
|
payload_class = super
|
@@ -40,6 +40,7 @@ module GraphQL
|
|
40
40
|
@arguments_by_keyword[arg.keyword] = arg
|
41
41
|
end
|
42
42
|
@arguments_loads_as_type = self.class.arguments_loads_as_type
|
43
|
+
@prepared_arguments = nil
|
43
44
|
end
|
44
45
|
|
45
46
|
# @return [Object] The application object this field is being resolved on
|
@@ -51,6 +52,10 @@ module GraphQL
|
|
51
52
|
# @return [GraphQL::Schema::Field]
|
52
53
|
attr_reader :field
|
53
54
|
|
55
|
+
def arguments
|
56
|
+
@prepared_arguments || raise("Arguments have not been prepared yet, still waiting for #load_arguments to resolve. (Call `.arguments` later in the code.)")
|
57
|
+
end
|
58
|
+
|
54
59
|
# This method is _actually_ called by the runtime,
|
55
60
|
# it does some preparation and then eventually calls
|
56
61
|
# the user-defined `#resolve` method.
|
@@ -74,6 +79,7 @@ module GraphQL
|
|
74
79
|
# for that argument, or may return a lazy object
|
75
80
|
load_arguments_val = load_arguments(args)
|
76
81
|
context.schema.after_lazy(load_arguments_val) do |loaded_args|
|
82
|
+
@prepared_arguments = loaded_args
|
77
83
|
# Then call `authorized?`, which may raise or may return a lazy object
|
78
84
|
authorized_val = if loaded_args.any?
|
79
85
|
authorized?(**loaded_args)
|
@@ -58,7 +58,8 @@ module GraphQL
|
|
58
58
|
resolver_fields.each do |name, f|
|
59
59
|
# Reattach the already-defined field here
|
60
60
|
# (The field's `.owner` will still point to the mutation, not the object type, I think)
|
61
|
-
|
61
|
+
# Don't re-warn about a method conflict. Since this type is generated, it should be fixed in the resolver instead.
|
62
|
+
add_field(f, method_conflict_warning: false)
|
62
63
|
end
|
63
64
|
end
|
64
65
|
end
|
data/lib/graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|