graphql-relay 0.3.2 → 0.3.3

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