graphql 1.11.5 → 1.11.6

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 003526dc3efe3c95425607d76c4beffa6777cb71458e7b5ddbc1deecfc5973df
4
- data.tar.gz: 0aa562c5b69dd2a8294bc90540af71cc4b6e7b8f701f71b3f18a0f47dcf9594b
3
+ metadata.gz: 1b6e1d6fb5063c843becb61784cb776964a380af5a2fc5a98054d2554ddf4caa
4
+ data.tar.gz: c41027cdf69f8c07bed157075c70e95936f3d26922f0b1d38f7759352a35ab43
5
5
  SHA512:
6
- metadata.gz: 8563c973af0d9060ae1a90e39affb7b2b8afec3233181f4cb00277d3c754a9446c3f994b8bb9c81689a1d1db92e19f91195b8e2e14a21fec7e2c43c93fc18840
7
- data.tar.gz: 3e61b7f17cc56bb1873e4efe5b6c5b0e8142b2ec7ea211632476411acf6112876fa554f4a12b56b538480367a4f4f174dd089cd8f24a032257974f9b4079876e
6
+ metadata.gz: 3dc4e13b30d51c32775785b9ed4a11940bc2cb541866877e6eef48bc621956700ddf057c597d2bc5a9fa09ca863e01ba84295e414e488e22ee03b94c28bc4003
7
+ data.tar.gz: 70f5ba8c04e13b83af431db1e8edea297a3c43acc6f6356668094349b577fe7de4e8cdb029aaf8ce70cc243664915ac7dac38612badd0acb720ce57464769cec
@@ -2,9 +2,9 @@
2
2
  module GraphQL
3
3
  module Define
4
4
  module AssignGlobalIdField
5
- def self.call(type_defn, field_name)
5
+ def self.call(type_defn, field_name, **field_kwargs)
6
6
  resolve = GraphQL::Relay::GlobalIdResolve.new(type: type_defn)
7
- GraphQL::Define::AssignObjectField.call(type_defn, field_name, type: GraphQL::ID_TYPE.to_non_null_type, resolve: resolve)
7
+ GraphQL::Define::AssignObjectField.call(type_defn, field_name, **field_kwargs, type: GraphQL::ID_TYPE.to_non_null_type, resolve: resolve)
8
8
  end
9
9
  end
10
10
  end
@@ -63,11 +63,7 @@ module GraphQL
63
63
  all_wrappers
64
64
  end
65
65
 
66
- # Used by the runtime to wrap values in connection wrappers.
67
- # @api Private
68
- def wrap(field, parent, items, arguments, context, wrappers: all_wrappers)
69
- return items if GraphQL::Execution::Interpreter::RawValue === items
70
-
66
+ def wrapper_for(items, wrappers: all_wrappers)
71
67
  impl = nil
72
68
 
73
69
  items.class.ancestors.each { |cls|
@@ -75,6 +71,16 @@ module GraphQL
75
71
  break if impl
76
72
  }
77
73
 
74
+ impl
75
+ end
76
+
77
+ # Used by the runtime to wrap values in connection wrappers.
78
+ # @api Private
79
+ def wrap(field, parent, items, arguments, context, wrappers: all_wrappers)
80
+ return items if GraphQL::Execution::Interpreter::RawValue === items
81
+
82
+ impl = wrapper_for(items, wrappers: wrappers)
83
+
78
84
  if impl.nil?
79
85
  raise ImplementationMissingError, "Couldn't find a connection wrapper for #{items.class} during #{field.path} (#{items.inspect})"
80
86
  end
@@ -33,12 +33,21 @@ module GraphQL
33
33
  # @param item [Object] The newly-added item (will be wrapped in `edge_class`)
34
34
  # @param parent [Object] The owner of `collection`, will be passed to the connection if provided
35
35
  # @param context [GraphQL::Query::Context] The surrounding `ctx`, will be passed to the connection if provided (this is required for cursor encoders)
36
- # @param edge_class [Class] The class to wrap `item` with
37
- def initialize(collection:, item:, parent: nil, context: nil, edge_class: Relay::Edge)
38
- connection_class = BaseConnection.connection_for_nodes(collection)
36
+ # @param edge_class [Class] The class to wrap `item` with (defaults to the connection's edge class)
37
+ def initialize(collection:, item:, parent: nil, context: nil, edge_class: nil)
38
+ if context && context.schema.new_connections?
39
+ conn_class = context.schema.connections.wrapper_for(collection)
40
+ # The rest will be added by ConnectionExtension
41
+ @connection = conn_class.new(collection, parent: parent, context: context, edge_class: edge_class)
42
+ @edge = @connection.edge_class.new(item, @connection)
43
+ else
44
+ connection_class = BaseConnection.connection_for_nodes(collection)
45
+ @connection = connection_class.new(collection, {}, parent: parent, context: context)
46
+ edge_class ||= Relay::Edge
47
+ @edge = edge_class.new(item, @connection)
48
+ end
49
+
39
50
  @parent = parent
40
- @connection = connection_class.new(collection, {}, parent: parent, context: context)
41
- @edge = edge_class.new(item, @connection)
42
51
  end
43
52
  end
44
53
  end
@@ -197,23 +197,27 @@ module GraphQL
197
197
  end
198
198
 
199
199
  def build_scalar_type(scalar_type_definition, type_resolver, default_resolve:)
200
+ builder = self
200
201
  Class.new(GraphQL::Schema::Scalar) do
201
202
  graphql_name(scalar_type_definition.name)
202
203
  description(scalar_type_definition.description)
203
204
  ast_node(scalar_type_definition)
204
205
 
205
206
  if default_resolve.respond_to?(:coerce_input)
206
- def self.coerce_input(val, ctx)
207
- ctx.schema.definition_default_resolve.coerce_input(self, val, ctx)
208
- end
209
-
210
- def self.coerce_result(val, ctx)
211
- ctx.schema.definition_default_resolve.coerce_result(self, val, ctx)
212
- end
207
+ # Put these method definitions in another method to avoid retaining `type_resolve`
208
+ # from this method's bindiing
209
+ builder.build_scalar_type_coerce_method(self, :coerce_input, default_resolve)
210
+ builder.build_scalar_type_coerce_method(self, :coerce_result, default_resolve)
213
211
  end
214
212
  end
215
213
  end
216
214
 
215
+ def build_scalar_type_coerce_method(scalar_class, method_name, default_definition_resolve)
216
+ scalar_class.define_singleton_method(method_name) do |val, ctx|
217
+ default_definition_resolve.public_send(method_name, self, val, ctx)
218
+ end
219
+ end
220
+
217
221
  def build_union_type(union_type_definition, type_resolver)
218
222
  Class.new(GraphQL::Schema::Union) do
219
223
  graphql_name(union_type_definition.name)
@@ -725,20 +725,21 @@ module GraphQL
725
725
  if @extensions.empty?
726
726
  yield(obj, args)
727
727
  else
728
- # Save these so that the originals can be re-given to `after_resolve` handlers.
729
- original_args = args
730
- original_obj = obj
728
+ extended_obj = obj
729
+ extended_args = args
731
730
 
732
731
  memos = []
733
- value = run_extensions_before_resolve(memos, obj, args, ctx) do |extended_obj, extended_args|
734
- yield(extended_obj, extended_args)
732
+ value = run_extensions_before_resolve(memos, obj, args, ctx) do |obj, args|
733
+ extended_obj = obj
734
+ extended_args = args
735
+ yield(obj, args)
735
736
  end
736
737
 
737
738
  ctx.schema.after_lazy(value) do |resolved_value|
738
739
  @extensions.each_with_index do |ext, idx|
739
740
  memo = memos[idx]
740
741
  # TODO after_lazy?
741
- resolved_value = ext.after_resolve(object: original_obj, arguments: original_args, context: ctx, value: resolved_value, memo: memo)
742
+ resolved_value = ext.after_resolve(object: extended_obj, arguments: extended_args, context: ctx, value: resolved_value, memo: memo)
742
743
  end
743
744
  resolved_value
744
745
  end
@@ -18,10 +18,11 @@ module GraphQL
18
18
  next_args.delete(:last)
19
19
  next_args.delete(:before)
20
20
  next_args.delete(:after)
21
- yield(object, next_args)
21
+ yield(object, next_args, arguments)
22
22
  end
23
23
 
24
24
  def after_resolve(value:, object:, arguments:, context:, memo:)
25
+ original_arguments = memo
25
26
  # rename some inputs to avoid conflicts inside the block
26
27
  maybe_lazy = value
27
28
  value = nil
@@ -37,10 +38,10 @@ module GraphQL
37
38
  # update the connection with some things that may not have been provided
38
39
  value.context ||= context
39
40
  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]
41
+ value.first_value ||= original_arguments[:first]
42
+ value.after_value ||= original_arguments[:after]
43
+ value.last_value ||= original_arguments[:last]
44
+ value.before_value ||= original_arguments[:before]
44
45
  if field.has_max_page_size? && !value.has_max_page_size_override?
45
46
  value.max_page_size = field.max_page_size
46
47
  end
@@ -50,7 +51,7 @@ module GraphQL
50
51
  value
51
52
  elsif context.schema.new_connections?
52
53
  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
+ context.schema.connections.wrap(field, object.object, value, original_arguments, context, wrappers: wrappers)
54
55
  else
55
56
  if object.is_a?(GraphQL::Schema::Object)
56
57
  object = object.object
@@ -58,7 +59,7 @@ module GraphQL
58
59
  connection_class = GraphQL::Relay::BaseConnection.connection_for_nodes(value)
59
60
  connection_class.new(
60
61
  value,
61
- arguments,
62
+ original_arguments,
62
63
  field: field,
63
64
  max_page_size: field.max_page_size,
64
65
  parent: object,
@@ -82,9 +82,9 @@ module GraphQL
82
82
  end
83
83
  end
84
84
 
85
- def global_id_field(field_name)
85
+ def global_id_field(field_name, **kwargs)
86
86
  id_resolver = GraphQL::Relay::GlobalIdResolve.new(type: self)
87
- field field_name, "ID", null: false
87
+ field field_name, "ID", **kwargs, null: false
88
88
  define_method(field_name) do
89
89
  id_resolver.call(object, {}, context)
90
90
  end
@@ -27,8 +27,7 @@ module GraphQL
27
27
  # @param node_id [String] A unique ID generated by {.encode}
28
28
  # @return [Array<(String, String)>] The type name & value passed to {.encode}
29
29
  def decode(node_id, separator: self.default_id_separator)
30
- # urlsafe_decode64 is for forward compatibility
31
- Base64Bp.urlsafe_decode64(node_id).split(separator, 2)
30
+ GraphQL::Schema::Base64Encoder.decode(node_id).split(separator, 2)
32
31
  end
33
32
  end
34
33
  end
@@ -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.name}'s authorization check"
25
+ message ||= "An instance of #{object.class} failed #{type.graphql_name}'s authorization check"
26
26
  super(message)
27
27
  end
28
28
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.11.5"
3
+ VERSION = "1.11.6"
4
4
  end
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.5
4
+ version: 1.11.6
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-09-30 00:00:00.000000000 Z
11
+ date: 2020-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -752,7 +752,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
752
752
  - !ruby/object:Gem::Version
753
753
  version: '0'
754
754
  requirements: []
755
- rubygems_version: 3.1.2
755
+ rubygems_version: 3.0.3
756
756
  signing_key:
757
757
  specification_version: 4
758
758
  summary: A GraphQL language and runtime for Ruby