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 +4 -4
- data/Gemfile.lock +1 -1
- data/graphiti_graphql.gemspec +1 -1
- data/lib/graphiti_graphql/federation/resource_dsl.rb +30 -12
- data/lib/graphiti_graphql/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e99c86540776f6e5aa93eaa422f4919cf4434f6116bb040267bd37f3a0036ba8
|
4
|
+
data.tar.gz: bfac34b9d8b0f5e5e96e9169d969b5a3efbe6d01d0c3da964d27649a6b7514be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c8d515d95e749457c887dadfaaedab1e8d9367d57565364a7a5ef969843ad13486f530a4e61623003198c7d099aa571cba2e4269b9e29a4f7941a7b700631ae
|
7
|
+
data.tar.gz: edfe5d07374179c3cceb6dc1fbfd05a6de8cc124759e65b659204f03eb5e0ee1c4980d0515f9b9cccb1ec6095706d7373283435804f5f618e94fb29e045d4b88
|
data/Gemfile.lock
CHANGED
data/graphiti_graphql.gemspec
CHANGED
@@ -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
|
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(
|
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
|
-
|
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:,
|
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
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
|
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.
|
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
|
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
|
26
|
+
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|