graphql 0.18.8 → 0.18.9
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18dd53e870fcdffcb0ce92efe962848d7e9b0259
|
4
|
+
data.tar.gz: edc7a7a7e56f10bbd3f50b330fe59f53efc35653
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1082187dac20710314b4dc469514f20d91f2619b6f658cf66ff8992e50813aa658eb47a0c7e0eb0d1febed8f7615cadcd7382e57dfe15b5a43e00da94f055cd1
|
7
|
+
data.tar.gz: 251ff406e0738e217bcbb1a5983a6ac7e2bc4c99678417bf16aead3bfa5a31d1a04f9b225cab14bef1e514c293719ec3f046fffb265a30b42b4e112d37f51020
|
@@ -108,11 +108,12 @@ module GraphQL
|
|
108
108
|
warn("type_from_object(object) is deprecated; use Schema.resolve_type(object) instead")
|
109
109
|
|
110
110
|
if @type_from_object_proc
|
111
|
-
|
111
|
+
type_from_obj = @type_from_object_proc
|
112
|
+
schema.resolve_type = -> (obj, ctx) { type_from_obj.call(obj) }
|
112
113
|
@type_from_object_proc = nil
|
113
114
|
end
|
114
115
|
|
115
|
-
schema.resolve_type(object)
|
116
|
+
schema.resolve_type(object, nil)
|
116
117
|
end
|
117
118
|
|
118
119
|
def type_from_object=(new_type_from_object_proc)
|
data/lib/graphql/schema.rb
CHANGED
@@ -63,7 +63,7 @@ module GraphQL
|
|
63
63
|
|
64
64
|
DIRECTIVES = [GraphQL::Directive::SkipDirective, GraphQL::Directive::IncludeDirective]
|
65
65
|
DYNAMIC_FIELDS = ["__type", "__typename", "__schema"]
|
66
|
-
RESOLVE_TYPE_PROC_REQUIRED = -> (obj) { raise("Schema.resolve_type is undefined, can't resolve type for #{obj}") }
|
66
|
+
RESOLVE_TYPE_PROC_REQUIRED = -> (obj, ctx) { raise("Schema.resolve_type is undefined, can't resolve type for #{obj.inspect}") }
|
67
67
|
|
68
68
|
attr_reader :directives, :static_validator
|
69
69
|
|
data/lib/graphql/version.rb
CHANGED
@@ -52,6 +52,28 @@ describe GraphQL::Relay::GlobalNodeIdentification do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
describe "type_from_object" do
|
56
|
+
it "works even though it's deprecated" do
|
57
|
+
thing_type = GraphQL::ObjectType.define do
|
58
|
+
name "Thing"
|
59
|
+
global_id_field :id
|
60
|
+
field :object_id, types.Int
|
61
|
+
end
|
62
|
+
|
63
|
+
node_ident = GraphQL::Relay::GlobalNodeIdentification.define do
|
64
|
+
type_from_object -> (obj) { thing_type }
|
65
|
+
end
|
66
|
+
|
67
|
+
schema = GraphQL::Schema.define do
|
68
|
+
node_identification(node_ident)
|
69
|
+
end
|
70
|
+
|
71
|
+
schema.send(:ensure_defined)
|
72
|
+
assert_equal thing_type, node_ident.type_from_object(nil)
|
73
|
+
assert_equal thing_type, schema.resolve_type(nil, nil)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
55
77
|
describe 'to_global_id / from_global_id ' do
|
56
78
|
it 'Converts typename and ID to and from ID' do
|
57
79
|
global_id = node_identification.to_global_id("SomeType", 123)
|