graphiti_graphql 0.1.12 → 0.1.14

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
  SHA256:
3
- metadata.gz: e50aa66c6cf3fda89d96665c6f2fc61fa92db821b4d00461101970d72c24eea6
4
- data.tar.gz: 1e058e770b73378802fd43b3e852720d9cfa9b5b80cfc77c40ea1e2e2ea602df
3
+ metadata.gz: e99c86540776f6e5aa93eaa422f4919cf4434f6116bb040267bd37f3a0036ba8
4
+ data.tar.gz: bfac34b9d8b0f5e5e96e9169d969b5a3efbe6d01d0c3da964d27649a6b7514be
5
5
  SHA512:
6
- metadata.gz: 7ecb9fda5f17d3414b2ae8a39f5e9fddb40f34ed683fc9d966c1098bd86f93422e9ee77439c8f27faed1384ab5876ee67bbfc296980f314c7f656930edee3734
7
- data.tar.gz: f00540102b8cccd704a2ef2d6b7cb787c750f23858b78e425e1dc59e452065b16c9d8788065c0a0c2e87a653fac70d803f743f72ead06405f207e549e0f8e132
6
+ metadata.gz: 4c8d515d95e749457c887dadfaaedab1e8d9367d57565364a7a5ef969843ad13486f530a4e61623003198c7d099aa571cba2e4269b9e29a4f7941a7b700631ae
7
+ data.tar.gz: edfe5d07374179c3cceb6dc1fbfd05a6de8cc124759e65b659204f03eb5e0ee1c4980d0515f9b9cccb1ec6095706d7373283435804f5f618e94fb29e045d4b88
data/Gemfile.lock CHANGED
@@ -3,7 +3,7 @@ PATH
3
3
  specs:
4
4
  graphiti_graphql (0.1.12)
5
5
  activesupport (>= 4.1)
6
- graphiti (~> 1.3.2)
6
+ graphiti (~> 1.3)
7
7
  graphql (~> 1.12)
8
8
 
9
9
  GEM
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency "graphiti", "~> 1.3.2"
30
+ spec.add_dependency "graphiti", "~> 1.3"
31
31
  spec.add_dependency "activesupport", ">= 4.1"
32
32
  spec.add_dependency "graphql", "~> 1.12"
33
33
 
@@ -7,11 +7,18 @@ module GraphitiGraphQL
7
7
  @type_name = type_name
8
8
  end
9
9
 
10
- def has_many(relationship_name, foreign_key: nil, magic: true, &blk)
10
+ def has_many(
11
+ relationship_name,
12
+ foreign_key: nil,
13
+ field: true,
14
+ filter: true,
15
+ &blk
16
+ )
11
17
  @caller.federated_has_many relationship_name,
12
18
  type: @type_name,
13
19
  foreign_key: foreign_key,
14
- magic: magic,
20
+ field: field,
21
+ filter: filter,
15
22
  &blk
16
23
  end
17
24
  end
@@ -34,13 +41,13 @@ module GraphitiGraphQL
34
41
  #
35
42
  # * Add to the list of external graphql-ruby types we need in schema
36
43
  # * Add a readable and filterable FK, without clobbering pre-existing
37
- def federated_has_many(name, type:, magic: true, foreign_key: nil, &blk)
44
+ def federated_has_many(name, type:, filter: true, field: true, foreign_key: nil, &blk)
38
45
  foreign_key ||= :"#{type.underscore}_id"
39
46
  resource = FederatedResource.new(type)
40
47
  federated_resources << resource
41
48
  resource.add_relationship(:has_many, name, self, foreign_key, &blk)
42
49
 
43
- return unless magic
50
+ return unless (filter || field)
44
51
 
45
52
  attribute = attributes.find { |name, config|
46
53
  name.to_sym == foreign_key &&
@@ -49,20 +56,31 @@ module GraphitiGraphQL
49
56
  }
50
57
  has_filter = filters.key?(foreign_key)
51
58
  if !attribute && !has_filter
52
- attribute foreign_key, :integer,
53
- only: [:readable, :filterable],
54
- schema: false,
55
- readable: :gql?,
56
- filterable: :gql?
57
- elsif has_filter && !attribute
59
+ if field
60
+ opts = {
61
+ only: [:readable],
62
+ schema: false,
63
+ readable: :gql?
64
+ }
65
+ if filter
66
+ opts[:only] << :filterable
67
+ opts[:filterable] = :gql?
68
+ end
69
+ attribute foreign_key, :integer, opts
70
+ elsif filter
71
+ filter foreign_key, :integer, schema: false
72
+ attributes[foreign_key][:filterable] = :gql?
73
+ end
74
+ elsif has_filter && !attribute && field
58
75
  prior = filters[foreign_key]
59
76
  attribute foreign_key, prior[:type],
60
77
  only: [:readable, :filterable],
61
78
  schema: false,
62
79
  readable: :gql?
63
80
  filters[foreign_key] = prior
64
- elsif attribute && !has_filter
65
- filter foreign_key, attribute[:type]
81
+ elsif attribute && !has_filter && filter
82
+ filter foreign_key, attribute[:type], schema: false
83
+ attributes[foreign_key][:filterable] = :gql?
66
84
  end
67
85
  end
68
86
 
@@ -1,3 +1,3 @@
1
1
  module GraphitiGraphQL
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.14"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti_graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.2
19
+ version: '1.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.2
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement