graphql 2.0.5 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/install_generator.rb +1 -1
- data/lib/generators/graphql/relay.rb +3 -17
- data/lib/graphql/execution/interpreter/resolve.rb +7 -0
- data/lib/graphql/execution/interpreter/runtime.rb +23 -3
- data/lib/graphql/execution/lazy.rb +0 -1
- data/lib/graphql/introspection/type_type.rb +1 -1
- data/lib/graphql/introspection.rb +1 -1
- data/lib/graphql/language/parser.rb +338 -327
- data/lib/graphql/language/parser.y +12 -8
- data/lib/graphql/language/printer.rb +9 -5
- data/lib/graphql/pagination/array_connection.rb +4 -2
- data/lib/graphql/schema/field.rb +41 -22
- data/lib/graphql/schema/loader.rb +1 -1
- data/lib/graphql/schema/member/has_fields.rb +1 -1
- data/lib/graphql/schema/resolver.rb +1 -1
- data/lib/graphql/schema/warden.rb +6 -2
- data/lib/graphql/schema.rb +17 -8
- data/lib/graphql/subscriptions.rb +15 -3
- data/lib/graphql/tracing/data_dog_tracing.rb +16 -1
- data/lib/graphql/tracing/platform_tracing.rb +4 -0
- data/lib/graphql/types/iso_8601_date.rb +4 -1
- data/lib/graphql/types/iso_8601_date_time.rb +4 -0
- data/lib/graphql/types/relay/base_connection.rb +16 -6
- data/lib/graphql/version.rb +1 -1
- metadata +2 -3
- data/lib/graphql/execution/lazy/resolve.rb +0 -91
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a10c35ffd2541c0b387e2e7d127eea0d1e2b4559fbd637288296369c0be09d0d
|
4
|
+
data.tar.gz: 34bf4d3cc5ef08bfbc065f9cdff4690dfa4b3351d46e014422304b897b531189
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 `--
|
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
|
-
|
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(
|
40
|
+
def self.object_from_id(global_id, query_ctx)
|
49
41
|
# For example, use Rails' GlobalID library (https://github.com/rails/globalid):
|
50
|
-
|
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
|
-
|
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
|