graphql 2.5.21 → 2.5.22
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/next/field_resolve_step.rb +21 -0
- data/lib/graphql/execution/next.rb +2 -1
- data/lib/graphql/schema/field.rb +5 -1
- data/lib/graphql/schema/member/has_dataloader.rb +20 -0
- data/lib/graphql/schema/member/has_fields.rb +1 -0
- data/lib/graphql/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 453860aab49f87d8b8771b00cc50b34a4567e7c80d7ce15b95c1b4fa82b23286
|
|
4
|
+
data.tar.gz: f33d534cbbccfcfb89ba8e6f553ea17d71199ca3fc898ab75c5f3ace08aba820
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c2c8b87e60b9312ce5fb3848cb9a8112b6d050b6ee9c31eee5720932a2cf754f97f6f7bef273b491199aaa46c7551348e07294270585e79a1e35d176126bdfb
|
|
7
|
+
data.tar.gz: b679a8434d195d513f97963b2fe70b296cb2106ceda4ae2b7c756d1127d8ee4c56f2e3106b4a01c609498904622ada5d569f489bf97a13f8627e7b6a6a1d83fd
|
|
@@ -644,6 +644,27 @@ module GraphQL
|
|
|
644
644
|
end
|
|
645
645
|
when :dig
|
|
646
646
|
objects.map { |o| o.dig(*@field_definition.execution_next_mode_key) }
|
|
647
|
+
when :dataload
|
|
648
|
+
if (k = @field_definition.execution_next_mode_key).is_a?(Class)
|
|
649
|
+
context.dataload_all(k, objects)
|
|
650
|
+
elsif (source_class = k[:with])
|
|
651
|
+
if (batch_args = k[:by])
|
|
652
|
+
context.dataload_all(source_class, *batch_args, objects)
|
|
653
|
+
else
|
|
654
|
+
context.dataload_all(source_class, objects)
|
|
655
|
+
end
|
|
656
|
+
elsif (model = k[:model])
|
|
657
|
+
value_method = k[:using]
|
|
658
|
+
values = objects.map(&value_method)
|
|
659
|
+
context.dataload_all_records(model, values, find_by: k[:find_by])
|
|
660
|
+
elsif (assoc = k[:association])
|
|
661
|
+
if assoc == true
|
|
662
|
+
assoc = @field_definition.original_name
|
|
663
|
+
end
|
|
664
|
+
context.dataload_all_associations(objects, assoc, scope: k[:scope])
|
|
665
|
+
else
|
|
666
|
+
raise ArgumentError, "Unexpected `dataload: ...` configuration: #{k.inspect}"
|
|
667
|
+
end
|
|
647
668
|
when :resolver_class
|
|
648
669
|
results = Array.new(objects.size, nil)
|
|
649
670
|
ps = @pending_steps ||= []
|
|
@@ -8,7 +8,7 @@ module GraphQL
|
|
|
8
8
|
module Execution
|
|
9
9
|
module Next
|
|
10
10
|
module SchemaExtension
|
|
11
|
-
def execute_next(query_str = nil, context: nil, document: nil, variables: nil, root_value: nil, validate: true, visibility_profile: nil)
|
|
11
|
+
def execute_next(query_str = nil, context: nil, document: nil, operation_name: nil, variables: nil, root_value: nil, validate: true, visibility_profile: nil)
|
|
12
12
|
multiplex_context = if context
|
|
13
13
|
{
|
|
14
14
|
backtrace: context[:backtrace],
|
|
@@ -27,6 +27,7 @@ module GraphQL
|
|
|
27
27
|
validate: validate,
|
|
28
28
|
variables: variables,
|
|
29
29
|
root_value: root_value,
|
|
30
|
+
operation_name: operation_name,
|
|
30
31
|
visibility_profile: visibility_profile,
|
|
31
32
|
}
|
|
32
33
|
m_results = multiplex_next([query_opts], context: multiplex_context, max_complexity: nil)
|
data/lib/graphql/schema/field.rb
CHANGED
|
@@ -197,6 +197,7 @@ module GraphQL
|
|
|
197
197
|
# @param resolve_batch [Symbol, true, nil] Used by {Schema.execute_next} map `objects` to a same-sized Array of results. Called on the owner type class with `objects, context, **arguments`.
|
|
198
198
|
# @param resolve_each [Symbol, true, nil] Used by {Schema.execute_next} to get a value value for each item. Called on the owner type class with `object, context, **arguments`.
|
|
199
199
|
# @param resolve_legacy_instance_method [Symbol, true, nil] Used by {Schema.execute_next} to get a value value for each item. Calls an instance method on the object type class.
|
|
200
|
+
# @param dataload [Class, Hash] Shorthand for making dataloader calls
|
|
200
201
|
# @param max_page_size [Integer, nil] For connections, the maximum number of items to return from this field, or `nil` to allow unlimited results.
|
|
201
202
|
# @param default_page_size [Integer, nil] For connections, the default number of items to return from this field, or `nil` to return unlimited results.
|
|
202
203
|
# @param introspection [Boolean] If true, this field will be marked as `#introspection?` and the name may begin with `__`
|
|
@@ -219,7 +220,7 @@ module GraphQL
|
|
|
219
220
|
# @param relay_nodes_field [Boolean] (Private, used by GraphQL-Ruby)
|
|
220
221
|
# @param extras [Array<:ast_node, :parent, :lookahead, :owner, :execution_errors, :graphql_name, :argument_details, Symbol>] Extra arguments to be injected into the resolver for this field
|
|
221
222
|
# @param definition_block [Proc] an additional block for configuring the field. Receive the field as a block param, or, if no block params are defined, then the block is `instance_eval`'d on the new {Field}.
|
|
222
|
-
def initialize(type: nil, name: nil, owner: nil, null: nil, description: NOT_CONFIGURED, comment: NOT_CONFIGURED, deprecation_reason: nil, method: nil, resolve_legacy_instance_method: nil, resolve_static: nil, resolve_each: nil, resolve_batch: nil, hash_key: nil, dig: nil, resolver_method: nil, connection: nil, max_page_size: NOT_CONFIGURED, default_page_size: NOT_CONFIGURED, scope: nil, introspection: false, camelize: true, trace: nil, complexity: nil, ast_node: nil, extras: EMPTY_ARRAY, extensions: EMPTY_ARRAY, connection_extension: self.class.connection_extension, resolver_class: nil, subscription_scope: nil, relay_node_field: false, relay_nodes_field: false, method_conflict_warning: true, broadcastable: NOT_CONFIGURED, arguments: EMPTY_HASH, directives: EMPTY_HASH, validates: EMPTY_ARRAY, fallback_value: NOT_CONFIGURED, dynamic_introspection: false, &definition_block)
|
|
223
|
+
def initialize(type: nil, name: nil, owner: nil, null: nil, description: NOT_CONFIGURED, comment: NOT_CONFIGURED, deprecation_reason: nil, method: nil, resolve_legacy_instance_method: nil, resolve_static: nil, resolve_each: nil, resolve_batch: nil, hash_key: nil, dig: nil, resolver_method: nil, connection: nil, max_page_size: NOT_CONFIGURED, default_page_size: NOT_CONFIGURED, scope: nil, introspection: false, camelize: true, trace: nil, complexity: nil, dataload: nil, ast_node: nil, extras: EMPTY_ARRAY, extensions: EMPTY_ARRAY, connection_extension: self.class.connection_extension, resolver_class: nil, subscription_scope: nil, relay_node_field: false, relay_nodes_field: false, method_conflict_warning: true, broadcastable: NOT_CONFIGURED, arguments: EMPTY_HASH, directives: EMPTY_HASH, validates: EMPTY_ARRAY, fallback_value: NOT_CONFIGURED, dynamic_introspection: false, &definition_block)
|
|
223
224
|
if name.nil?
|
|
224
225
|
raise ArgumentError, "missing first `name` argument or keyword `name:`"
|
|
225
226
|
end
|
|
@@ -289,6 +290,9 @@ module GraphQL
|
|
|
289
290
|
elsif resolve_legacy_instance_method
|
|
290
291
|
@execution_next_mode = :resolve_legacy_instance_method
|
|
291
292
|
@execution_next_mode_key = resolve_legacy_instance_method == true ? @method_sym : resolve_legacy_instance_method
|
|
293
|
+
elsif dataload
|
|
294
|
+
@execution_next_mode = :dataload
|
|
295
|
+
@execution_next_mode_key = dataload
|
|
292
296
|
else
|
|
293
297
|
@execution_next_mode = :direct_send
|
|
294
298
|
@execution_next_mode_key = @method_sym
|
|
@@ -56,6 +56,16 @@ module GraphQL
|
|
|
56
56
|
source.load(find_by_value)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
# @see dataload_record Like `dataload_record`, but accepts an Array of `find_by_values`
|
|
60
|
+
def dataload_all_records(model, find_by_values, find_by: nil)
|
|
61
|
+
source = if find_by
|
|
62
|
+
dataloader.with(Dataloader::ActiveRecordSource, model, find_by: find_by)
|
|
63
|
+
else
|
|
64
|
+
dataloader.with(Dataloader::ActiveRecordSource, model)
|
|
65
|
+
end
|
|
66
|
+
source.load_all(find_by_values)
|
|
67
|
+
end
|
|
68
|
+
|
|
59
69
|
# Look up an associated record using a Rails association (via {Dataloader::ActiveRecordAssociationSource})
|
|
60
70
|
# @param association_name [Symbol] A `belongs_to` or `has_one` association. (If a `has_many` association is named here, it will be selected without pagination.)
|
|
61
71
|
# @param record [ActiveRecord::Base] The object that the association belongs to.
|
|
@@ -73,6 +83,16 @@ module GraphQL
|
|
|
73
83
|
end
|
|
74
84
|
source.load(record)
|
|
75
85
|
end
|
|
86
|
+
|
|
87
|
+
# @see dataload_association Like `dataload_assocation` but accepts an Array of records (required param)
|
|
88
|
+
def dataload_all_associations(records, association_name, scope: nil)
|
|
89
|
+
source = if scope
|
|
90
|
+
dataloader.with(Dataloader::ActiveRecordAssociationSource, association_name, scope)
|
|
91
|
+
else
|
|
92
|
+
dataloader.with(Dataloader::ActiveRecordAssociationSource, association_name)
|
|
93
|
+
end
|
|
94
|
+
source.load_all(records)
|
|
95
|
+
end
|
|
76
96
|
end
|
|
77
97
|
end
|
|
78
98
|
end
|
|
@@ -48,6 +48,7 @@ module GraphQL
|
|
|
48
48
|
# @option kwargs [Boolean] :dynamic_introspection (Private, used by GraphQL-Ruby)
|
|
49
49
|
# @option kwargs [Boolean] :relay_node_field (Private, used by GraphQL-Ruby)
|
|
50
50
|
# @option kwargs [Boolean] :relay_nodes_field (Private, used by GraphQL-Ruby)
|
|
51
|
+
# @option kwargs [Class, Hash] :dataload Shorthand for dataloader lookups
|
|
51
52
|
# @option kwargs [Array<:ast_node, :parent, :lookahead, :owner, :execution_errors, :graphql_name, :argument_details, Symbol>] :extras Extra arguments to be injected into the resolver for this field
|
|
52
53
|
# @param kwargs [Hash] Keywords for defining the field. Any not documented here will be passed to your base field class where they must be handled.
|
|
53
54
|
# @param definition_block [Proc] an additional block for configuring the field. Receive the field as a block param, or, if no block params are defined, then the block is `instance_eval`'d on the new {Field}.
|
data/lib/graphql/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: graphql
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.5.
|
|
4
|
+
version: 2.5.22
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Mosolgo
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-03-
|
|
10
|
+
date: 2026-03-23 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: base64
|
|
@@ -831,7 +831,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
831
831
|
- !ruby/object:Gem::Version
|
|
832
832
|
version: '0'
|
|
833
833
|
requirements: []
|
|
834
|
-
rubygems_version:
|
|
834
|
+
rubygems_version: 4.0.8
|
|
835
835
|
specification_version: 4
|
|
836
836
|
summary: A GraphQL language and runtime for Ruby
|
|
837
837
|
test_files: []
|