graphql-relay 0.3.3 → 0.3.4

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