graphql 0.18.8 → 0.18.9

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
  SHA1:
3
- metadata.gz: e3550ea852aad13e43cd451dfa44ed0889f71f9a
4
- data.tar.gz: ce68835d73683f572b8b53529dc5f7de426b7a02
3
+ metadata.gz: 18dd53e870fcdffcb0ce92efe962848d7e9b0259
4
+ data.tar.gz: edc7a7a7e56f10bbd3f50b330fe59f53efc35653
5
5
  SHA512:
6
- metadata.gz: af009ae9281638daab169b41c94b6def2967a16ba2e41f667cf51d5c45a83b6aeacf0169195c651e5f2136934346a086775d65be713d4da03db429e4d41ce421
7
- data.tar.gz: b7c1225ffe636db87a332f8ec0af465ee38b29d8269cc18485f40f22296608b1cb0ee0d69a17be58e7f28067611ebf946b1b306d1c796bb4dcf439190bc15249
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
- schema.resolve_type = @type_from_object_proc
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)
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module GraphQL
2
- VERSION = "0.18.8"
2
+ VERSION = "0.18.9"
3
3
  end
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.8
4
+ version: 0.18.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo