graphql 2.0.5 → 2.0.8

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.

Potentially problematic release.


This version of graphql might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 248d39942011f4175ee77643a6e8d103d17d60ac73ee95418eb25e0eee2bbb27
4
- data.tar.gz: 062c4d1402adf7f3612d888c6e00df91623340239996b6bc14db59ebbec41814
3
+ metadata.gz: a10c35ffd2541c0b387e2e7d127eea0d1e2b4559fbd637288296369c0be09d0d
4
+ data.tar.gz: 34bf4d3cc5ef08bfbc065f9cdff4690dfa4b3351d46e014422304b897b531189
5
5
  SHA512:
6
- metadata.gz: 87813bc8354e52215099b99f932b615856337649897313982e7945b9f039625fd4a788a1edba62faf4f6ee8438d87feafe39b374504561726fd7b9b5f5959d0d
7
- data.tar.gz: d58627c8387a891814bf5a362a23035f9c58f2b5959fe3857afdec66cac7a2944601cfa03311c3791cc18038fd4a1c4faf5dd1793c54b9bbab1d2bd487e4b140
6
+ metadata.gz: afed371861c1dcca740f07940d7f8239e800723623d6a9eb664592b169568ab1d92e3c2ea1286ba40625e00be0b27584f94e2493479cfd119251831d90c3f0a0
7
+ data.tar.gz: 43e8362810fb7a48fcdec9f997a2b33c599e08c1276da79480e75c6fad456328775e71dc1317e98923a88b5e3169a5f9f3b491d09b943c49805d536071e0047f
@@ -47,7 +47,7 @@ module Graphql
47
47
  #
48
48
  # Accept a `--batch` option which adds `GraphQL::Batch` setup.
49
49
  #
50
- # Use `--no-graphiql` to skip `graphiql-rails` installation.
50
+ # Use `--skip-graphiql` to skip `graphiql-rails` installation.
51
51
  #
52
52
  # TODO: also add base classes
53
53
  class InstallGenerator < Rails::Generators::Base
@@ -33,27 +33,13 @@ module Graphql
33
33
  # Return a string UUID for `object`
34
34
  def self.id_from_object(object, type_definition, query_ctx)
35
35
  # For example, use Rails' GlobalID library (https://github.com/rails/globalid):
36
- object_id = object.to_global_id.to_s
37
- # Remove this redundant prefix to make IDs shorter:
38
- object_id = object_id.sub("gid://\#{GlobalID.app}/", "")
39
- encoded_id = Base64.urlsafe_encode64(object_id)
40
- # Remove the "=" padding
41
- encoded_id = encoded_id.sub(/=+/, "")
42
- # Add a type hint
43
- type_hint = type_definition.graphql_name.first
44
- "\#{type_hint}_\#{encoded_id}"
36
+ object.to_gid_param
45
37
  end
46
38
 
47
39
  # Given a string UUID, find the object
48
- def self.object_from_id(encoded_id_with_hint, query_ctx)
40
+ def self.object_from_id(global_id, query_ctx)
49
41
  # For example, use Rails' GlobalID library (https://github.com/rails/globalid):
50
- # Split off the type hint
51
- _type_hint, encoded_id = encoded_id_with_hint.split("_", 2)
52
- # Decode the ID
53
- id = Base64.urlsafe_decode64(encoded_id)
54
- # Rebuild it for Rails then find the object:
55
- full_global_id = "gid://\#{GlobalID.app}/\#{id}"
56
- GlobalID::Locator.locate(full_global_id)
42
+ GlobalID.find(global_id)
57
43
  end
58
44
  RUBY
59
45
  inject_into_file schema_file_path, schema_code, before: /^end\n/m, force: false
@@ -59,6 +59,13 @@ module GraphQL
59
59
  end
60
60
 
61
61
  if next_results.any?
62
+ # Any pending data loader jobs may populate the
63
+ # resutl arrays or result hashes accumulated in
64
+ # `next_results``. Run those **to completion**
65
+ # before continuing to resolve `next_results`.
66
+ # (Just `.append_job` doesn't work if any pending
67
+ # jobs require multiple passes.)
68
+ dataloader.run
62
69
  dataloader.append_job { resolve(next_results, dataloader) }
63
70
  end
64
71
 
@@ -754,11 +754,16 @@ module GraphQL
754
754
  response_list = GraphQLResultArray.new(result_name, selection_result)
755
755
  response_list.graphql_non_null_list_items = inner_type.non_null?
756
756
  set_result(selection_result, result_name, response_list)
757
-
757
+ result_was_set = false
758
758
  idx = 0
759
- begin
759
+ list_value = begin
760
760
  value.each do |inner_value|
761
761
  break if dead_result?(response_list)
762
+ if !result_was_set
763
+ # Don't set the result unless `.each` is successful
764
+ set_result(selection_result, result_name, response_list)
765
+ result_was_set = true
766
+ end
762
767
  next_path = path.dup
763
768
  next_path << idx
764
769
  this_idx = idx
@@ -772,6 +777,13 @@ module GraphQL
772
777
  resolve_list_item(inner_value, inner_type, next_path, ast_node, field, owner_object, arguments, this_idx, response_list, next_selections, owner_type)
773
778
  end
774
779
  end
780
+ # Maybe the list was empty and the block was never called.
781
+ if !result_was_set
782
+ set_result(selection_result, result_name, response_list)
783
+ result_was_set = true
784
+ end
785
+
786
+ response_list
775
787
  rescue NoMethodError => err
776
788
  # Ruby 2.2 doesn't have NoMethodError#receiver, can't check that one in this case. (It's been EOL since 2017.)
777
789
  if err.name == :each && (err.respond_to?(:receiver) ? err.receiver == value : true)
@@ -781,9 +793,17 @@ module GraphQL
781
793
  # This was some other NoMethodError -- let it bubble to reveal the real error.
782
794
  raise
783
795
  end
796
+ rescue GraphQL::ExecutionError, GraphQL::UnauthorizedError => ex_err
797
+ ex_err
798
+ rescue StandardError => err
799
+ begin
800
+ query.handle_or_reraise(err)
801
+ rescue GraphQL::ExecutionError => ex_err
802
+ ex_err
803
+ end
784
804
  end
785
805
 
786
- response_list
806
+ continue_value(path, list_value, owner_type, field, inner_type.non_null?, ast_node, result_name, selection_result)
787
807
  else
788
808
  raise "Invariant: Unhandled type kind #{current_type.kind} (#{current_type})"
789
809
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  require "graphql/execution/lazy/lazy_method_map"
3
- require "graphql/execution/lazy/resolve"
4
3
 
5
4
  module GraphQL
6
5
  module Execution
@@ -27,7 +27,7 @@ module GraphQL
27
27
  end
28
28
  field :of_type, GraphQL::Schema::LateBoundType.new("__Type")
29
29
 
30
- field :specified_by_url, String
30
+ field :specifiedByURL, String, resolver_method: :specified_by_url
31
31
 
32
32
  def specified_by_url
33
33
  if object.kind.scalar?
@@ -29,7 +29,7 @@ fragment FullType on __Type {
29
29
  kind
30
30
  name
31
31
  description
32
- #{include_specified_by_url ? "specifiedByUrl" : ""}
32
+ #{include_specified_by_url ? "specifiedByURL" : ""}
33
33
  fields(includeDeprecated: true) {
34
34
  name
35
35
  description