graphql 1.2.5 → 1.2.6
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: 2550713a1eb62110904f3370fc77ce4f9d829efa
|
4
|
+
data.tar.gz: d70c9b62e551278f6764e5aa4a5a3cdcb973c7be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86120c08fcf5598c0672ff0a035939ec44a450509d57dcf6ca5627f35c3bb8efcfd1b3be063fa5ea194c40e652390a22a20eb32b2e347026e87ce28100551a96
|
7
|
+
data.tar.gz: 83692323da75a39f24439aefdf0280d1a64240f332bef934207753dc672edb7fc4da81b8900aeeccbf463409df2497ef25243b98595604bc7676abaa0df775c1
|
@@ -24,17 +24,17 @@ module GraphQL
|
|
24
24
|
memo
|
25
25
|
end
|
26
26
|
|
27
|
-
#
|
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]
|
32
|
+
# @return [GraphQL::Field] A redefined field with connection behavior
|
33
33
|
def self.create(underlying_field, max_page_size: nil)
|
34
|
-
|
34
|
+
connection_arguments = DEFAULT_ARGUMENTS.merge(underlying_field.arguments)
|
35
35
|
original_resolve = underlying_field.resolve_proc
|
36
|
-
|
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
|
data/lib/graphql/version.rb
CHANGED
data/spec/graphql/field_spec.rb
CHANGED
@@ -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.
|
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
|
+
date: 2016-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codeclimate-test-reporter
|