graphql 1.2.5 → 1.2.6

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: b49f51c993d3f37fb6596a0547175b9cb1e6dfe0
4
- data.tar.gz: 4e639bf70ca713dd8a795690a30b2eafca16c5be
3
+ metadata.gz: 2550713a1eb62110904f3370fc77ce4f9d829efa
4
+ data.tar.gz: d70c9b62e551278f6764e5aa4a5a3cdcb973c7be
5
5
  SHA512:
6
- metadata.gz: 8ba6eec79d60b4e4fac5a3779dce895c9e757e3bd923b64d6d77b2702638ed2dcb6b57ae914a6be2e582cff6cad29a3f3f18662e90b7ff5076f56610c75c2519
7
- data.tar.gz: 39e999428ae079e15e942852e295518bb242b6c4dcb65ca32f31cdcde7d2518427f34dbd39d5b92a8e72d70762f85d0e85079d4efe4d670bf2ea674f98e542f8
6
+ metadata.gz: 86120c08fcf5598c0672ff0a035939ec44a450509d57dcf6ca5627f35c3bb8efcfd1b3be063fa5ea194c40e652390a22a20eb32b2e347026e87ce28100551a96
7
+ data.tar.gz: 83692323da75a39f24439aefdf0280d1a64240f332bef934207753dc672edb7fc4da81b8900aeeccbf463409df2497ef25243b98595604bc7676abaa0df775c1
@@ -20,6 +20,11 @@ module GraphQL
20
20
  end
21
21
  end
22
22
 
23
+ def respond_to_missing?(name, include_private = false)
24
+ return true if @dictionary[name]
25
+ super
26
+ end
27
+
23
28
  def to_s
24
29
  inspect
25
30
  end
@@ -24,17 +24,17 @@ module GraphQL
24
24
  memo
25
25
  end
26
26
 
27
- # Turn A GraphQL::Field into a connection by:
27
+ # Build a connection field from a {GraphQL::Field} by:
28
28
  # - Merging in the default arguments
29
29
  # - Transforming its resolve function to return a connection object
30
30
  # @param underlying_field [GraphQL::Field] A field which returns nodes to be wrapped as a connection
31
31
  # @param max_page_size [Integer] The maximum number of nodes which may be requested (if a larger page is requested, it is limited to this number)
32
- # @return [GraphQL::Field] The same field, modified to resolve to a connection object
32
+ # @return [GraphQL::Field] A redefined field with connection behavior
33
33
  def self.create(underlying_field, max_page_size: nil)
34
- underlying_field.arguments = DEFAULT_ARGUMENTS.merge(underlying_field.arguments)
34
+ connection_arguments = DEFAULT_ARGUMENTS.merge(underlying_field.arguments)
35
35
  original_resolve = underlying_field.resolve_proc
36
- underlying_field.resolve = GraphQL::Relay::ConnectionResolve.new(underlying_field, original_resolve, max_page_size: max_page_size)
37
- underlying_field
36
+ connection_resolve = GraphQL::Relay::ConnectionResolve.new(underlying_field, original_resolve, max_page_size: max_page_size)
37
+ underlying_field.redefine(resolve: connection_resolve, arguments: connection_arguments)
38
38
  end
39
39
  end
40
40
  end
@@ -1,3 +1,3 @@
1
1
  module GraphQL
2
- VERSION = "1.2.5"
2
+ VERSION = "1.2.6"
3
3
  end
@@ -150,4 +150,19 @@ describe GraphQL::Field do
150
150
  assert_equal ["int", "int2", "int3"], query_field_names, "It works in introspection"
151
151
  end
152
152
  end
153
+
154
+ describe "#redefine" do
155
+ it "can add arguments" do
156
+ int_field = GraphQL::Field.define do
157
+ argument :value, types.Int
158
+ end
159
+
160
+ int_field_2 = int_field.redefine do
161
+ argument :value_2, types.Int
162
+ end
163
+
164
+ assert_equal 1, int_field.arguments.size
165
+ assert_equal 2, int_field_2.arguments.size
166
+ end
167
+ end
153
168
  end
@@ -31,4 +31,20 @@ describe GraphQL::Relay::ConnectionField do
31
31
  assert_instance_of GraphQL::Field::Resolve::MethodResolve, test_field.resolve_proc
32
32
  assert_instance_of GraphQL::Relay::ConnectionResolve, conn_field.resolve_proc
33
33
  end
34
+
35
+ it "passes connection behaviors to redefinitions" do
36
+ test_type = GraphQL::ObjectType.define do
37
+ name "Test"
38
+ connection :tests, test_type.connection_type
39
+ end
40
+
41
+ connection_field = test_type.fields["tests"]
42
+ redefined_connection_field = connection_field.redefine { argument "name", types.String }
43
+
44
+ assert_equal 4, connection_field.arguments.size
45
+ assert_equal 5, redefined_connection_field.arguments.size
46
+
47
+ assert_instance_of GraphQL::Relay::ConnectionResolve, connection_field.resolve_proc
48
+ assert_instance_of GraphQL::Relay::ConnectionResolve, redefined_connection_field.resolve_proc
49
+ end
34
50
  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.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-22 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter