graphql-relay 0.3.3 → 0.3.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e7798563f603df39b5780740ad4a7ebb9c47fa6
|
4
|
+
data.tar.gz: 1047b236e12da6d92fd7b9dce071295edc409927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb001b7579d8c570be9a30227b90b15f9e094959b392c6d861e135d0b5d9290062bb7415a8553b692434df5a3f237afd7d82500a82155f3edbcc96c2779f326e
|
7
|
+
data.tar.gz: 51b9750a832569fff27ed6a2a3d6253d0d29c57f45bb2f96874763dff5da97cd7cc5beed6f9c95fd723e989483c2f6e139bf6c94ccebacf03a50f3665a4ac357
|
@@ -1,38 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
1
|
+
class GraphQL::DefinitionHelpers::DefinedByConfig::DefinitionConfig
|
2
|
+
# Wraps a field definition with a ConnectionField
|
3
|
+
# - applies default fields
|
4
|
+
# - wraps the resolve proc to make a connection
|
5
|
+
#
|
6
|
+
def connection(name, type = nil, desc = nil, property: nil, &block)
|
7
|
+
# Wrap the given block to define the default args
|
8
|
+
definition_block = -> (config) {
|
9
|
+
argument :first, types.Int
|
10
|
+
argument :after, types.String
|
11
|
+
argument :last, types.Int
|
12
|
+
argument :before, types.String
|
13
|
+
argument :order, types.String
|
14
|
+
self.instance_eval(&block)
|
15
|
+
}
|
16
|
+
connection_field = field(name, type, desc, property: property, &definition_block)
|
17
|
+
# Wrap the defined resolve proc
|
18
|
+
# TODO: make a public API on GraphQL::Field to expose this proc
|
19
|
+
original_resolve = connection_field.instance_variable_get(:@resolve_proc)
|
20
|
+
connection_resolve = -> (obj, args, ctx) {
|
21
|
+
items = original_resolve.call(obj, args, ctx)
|
22
|
+
connection_class = GraphQL::Relay::BaseConnection.connection_for_items(items)
|
23
|
+
connection_class.new(items, args)
|
24
|
+
}
|
25
|
+
connection_field.resolve = connection_resolve
|
26
|
+
fields[name.to_s] = connection_field
|
27
|
+
end
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
alias :return_field :field
|
30
|
+
alias :return_fields :fields
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
32
|
+
def global_id_field(field_name)
|
33
|
+
name || raise("You must define the type's name before creating a GlobalIdField")
|
34
|
+
field(name, field: GraphQL::Relay::GlobalIdField.new(name))
|
37
35
|
end
|
38
36
|
end
|