graphql 1.12.20 → 1.12.24

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: b8312601f8e51973aaa9418c4c4691b6eab97140351c91d47f6c2c4f4deb88fb
4
- data.tar.gz: 4cb698ef0a6739ceca4026b4dfaa594faf5658ac10a6005b051b70ec34af7f41
3
+ metadata.gz: fee883bb45ad2391215f85a31ceec2f69b19c07c138708f002643c2fdf4c8a19
4
+ data.tar.gz: 925fb0e6f0acbb8ceddb79ad2eec4e8cfcd73bdf5cb51ad708dd1d7ebb491e2d
5
5
  SHA512:
6
- metadata.gz: e9122ecfa0c4c28d219af2c828adb1b5e7e0ae29b10df55f543cbfa8973d8d9706ba5258c3de4f620b6cba5f16d6e6e031ebb6605193153ce5be821eaeb1adaa
7
- data.tar.gz: 4db8f3435262d72f1d0d1995407f83c76a55dc0b5f28f7b5d8c6c4a378b2da00e4119e371585bdfac847ae5661c6e91e3bfdfcde82cd232198456905dee1f1a0
6
+ metadata.gz: 480aba657ba456d83bc543132f730b56444068a8a14c054c5f7f98a3d7c87179d23d843cc862b4ba8388bdf020fcb3f231c4513a93c824cc7ce15e61a9160c67
7
+ data.tar.gz: 5744a84a14e922b2b26984986351cab87e41da464b985b1b28d53c7c42a921b5dd53cadca09c8a1679a2af1f7ee40dd42894e32bee373b88c8c2fe6fa917a1e9
@@ -12,7 +12,8 @@ module Graphql
12
12
  #
13
13
  # Add the Node interface with `--node`.
14
14
  class ObjectGenerator < TypeGeneratorBase
15
- desc "Create a GraphQL::ObjectType with the given name and fields"
15
+ desc "Create a GraphQL::ObjectType with the given name and fields." \
16
+ "If the given type name matches an existing ActiveRecord model, the generated type will automatically include fields for the models database columns."
16
17
  source_root File.expand_path('../templates', __FILE__)
17
18
 
18
19
  argument :custom_fields,
@@ -9,7 +9,7 @@ class <%= schema_name %> < GraphQL::Schema
9
9
  use GraphQL::Dataloader
10
10
  <% end %>
11
11
  # GraphQL-Ruby calls this when something goes wrong while running a query:
12
- def self.type_error(err)
12
+ def self.type_error(err, context)
13
13
  # if err.is_a?(GraphQL::InvalidNullError)
14
14
  # # report to your bug tracker here
15
15
  # return nil
@@ -19,7 +19,7 @@ class <%= schema_name %> < GraphQL::Schema
19
19
 
20
20
  # Union and Interface Resolution
21
21
  def self.resolve_type(abstract_type, obj, ctx)
22
- # TODO: Implement this function
22
+ # TODO: Implement this method
23
23
  # to return the correct GraphQL object type for `obj`
24
24
  raise(GraphQL::RequiredImplementationMissingError)
25
25
  end
@@ -15,8 +15,12 @@ module GraphQL
15
15
  field = "#{visitor.parent_type_definition.graphql_name}.#{field_defn.graphql_name}"
16
16
  @used_fields << field
17
17
  @used_deprecated_fields << field if field_defn.deprecation_reason
18
-
19
- extract_deprecated_arguments(visitor.query.arguments_for(node, visitor.field_definition).argument_values)
18
+ arguments = visitor.query.arguments_for(node, visitor.field_definition)
19
+ # If there was an error when preparing this argument object,
20
+ # then this might be an error or something:
21
+ if arguments.respond_to?(:argument_values)
22
+ extract_deprecated_arguments(arguments.argument_values)
23
+ end
20
24
  end
21
25
 
22
26
  def result
@@ -197,7 +197,16 @@ module GraphQL
197
197
  else
198
198
  module_eval <<-RUBY, __FILE__, __LINE__
199
199
  def children
200
- @children ||= (#{children_of_type.keys.map { |k| "@#{k}" }.join(" + ")}).freeze
200
+ @children ||= begin
201
+ if #{children_of_type.keys.map { |k| "@#{k}.any?" }.join(" || ")}
202
+ new_children = []
203
+ #{children_of_type.keys.map { |k| "new_children.concat(@#{k})" }.join("; ")}
204
+ new_children.freeze
205
+ new_children
206
+ else
207
+ NO_CHILDREN
208
+ end
209
+ end
201
210
  end
202
211
  RUBY
203
212
  end
@@ -116,6 +116,10 @@ module GraphQL
116
116
  @arguments = self.class.coerce_arguments(nil, arguments, Query::NullContext)
117
117
  end
118
118
 
119
+ def graphql_name
120
+ self.class.graphql_name
121
+ end
122
+
119
123
  LOCATIONS = [
120
124
  QUERY = :QUERY,
121
125
  MUTATION = :MUTATION,
@@ -38,7 +38,9 @@ module GraphQL
38
38
  end
39
39
 
40
40
  def validate(_object, _context, value)
41
- if value.nil? ||
41
+ if permitted_empty_value?(value)
42
+ # Do nothing
43
+ elsif value.nil? ||
42
44
  (@with_pattern && !value.match?(@with_pattern)) ||
43
45
  (@without_pattern && value.match?(@without_pattern))
44
46
  @message
@@ -50,15 +50,15 @@ module GraphQL
50
50
  @arg_conflicts = nil
51
51
 
52
52
  yield
53
-
54
- field_conflicts.each_value { |error| add_error(error) }
55
- arg_conflicts.each_value { |error| add_error(error) }
53
+ # don't initialize these if they weren't initialized in the block:
54
+ @field_conflicts && @field_conflicts.each_value { |error| add_error(error) }
55
+ @arg_conflicts && @arg_conflicts.each_value { |error| add_error(error) }
56
56
  end
57
57
 
58
58
  def conflicts_within_selection_set(node, parent_type)
59
59
  return if parent_type.nil?
60
60
 
61
- fields, fragment_spreads = fields_and_fragments_from_selection(node, owner_type: parent_type, parents: [])
61
+ fields, fragment_spreads = fields_and_fragments_from_selection(node, owner_type: parent_type, parents: nil)
62
62
 
63
63
  # (A) Find find all conflicts "within" the fields of this selection set.
64
64
  find_conflicts_within(fields)
@@ -198,10 +198,14 @@ module GraphQL
198
198
  response_keys.each do |key, fields|
199
199
  next if fields.size < 2
200
200
  # find conflicts within nodes
201
- for i in 0..fields.size - 1
202
- for j in i + 1..fields.size - 1
201
+ i = 0
202
+ while i < fields.size
203
+ j = i + 1
204
+ while j < fields.size
203
205
  find_conflict(key, fields[i], fields[j])
206
+ j += 1
204
207
  end
208
+ i += 1
205
209
  end
206
210
  end
207
211
  end
@@ -243,7 +247,9 @@ module GraphQL
243
247
  end
244
248
 
245
249
  def find_conflicts_between_sub_selection_sets(field1, field2, mutually_exclusive:)
246
- return if field1.definition.nil? || field2.definition.nil?
250
+ return if field1.definition.nil? ||
251
+ field2.definition.nil? ||
252
+ (field1.node.selections.empty? && field2.node.selections.empty?)
247
253
 
248
254
  return_type1 = field1.definition.type.unwrap
249
255
  return_type2 = field2.definition.type.unwrap
@@ -323,6 +329,7 @@ module GraphQL
323
329
  if node.selections.empty?
324
330
  NO_SELECTIONS
325
331
  else
332
+ parents ||= []
326
333
  fields, fragment_spreads = find_fields_and_fragments(node.selections, owner_type: owner_type, parents: parents, fields: [], fragment_spreads: [])
327
334
  response_keys = fields.group_by { |f| f.node.alias || f.node.name }
328
335
  [response_keys, fragment_spreads]
@@ -16,6 +16,8 @@ module GraphQL
16
16
  private
17
17
 
18
18
  def assert_required_args(ast_node, defn)
19
+ args = defn.arguments
20
+ return if args.empty?
19
21
  present_argument_names = ast_node.arguments.map(&:name)
20
22
  required_argument_names = defn.arguments.each_value
21
23
  .select { |a| a.type.kind.non_null? && !a.default_value? && context.warden.get_argument(defn, a.name) }
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.12.20"
3
+ VERSION = "1.12.24"
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.12.20
4
+ version: 1.12.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-17 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -687,7 +687,7 @@ metadata:
687
687
  source_code_uri: https://github.com/rmosolgo/graphql-ruby
688
688
  bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
689
689
  mailing_list_uri: https://tinyletter.com/graphql-ruby
690
- post_install_message:
690
+ post_install_message:
691
691
  rdoc_options: []
692
692
  require_paths:
693
693
  - lib
@@ -702,8 +702,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
702
702
  - !ruby/object:Gem::Version
703
703
  version: '0'
704
704
  requirements: []
705
- rubygems_version: 3.2.22
706
- signing_key:
705
+ rubygems_version: 3.1.6
706
+ signing_key:
707
707
  specification_version: 4
708
708
  summary: A GraphQL language and runtime for Ruby
709
709
  test_files: []