graphiti_gql 0.2.6 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/probots.yml +2 -0
- data/Gemfile.lock +1 -1
- data/lib/graphiti_gql/active_resource.rb +6 -3
- data/lib/graphiti_gql/graphiti_hax.rb +1 -0
- data/lib/graphiti_gql/schema/fields/to_many.rb +17 -20
- data/lib/graphiti_gql/schema/list_arguments.rb +4 -1
- data/lib/graphiti_gql/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 544e1209bfdf6e48d70a76490edec46bc04639d75d91bae2a35ab95ea8fb4530
|
4
|
+
data.tar.gz: '0688127e3a2ab48d4bdd3f7f70a4efd544dd4bb4c9a952c0c4302ede86c1c24a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67b52a3241814fd821cf23982ed55e02c1e0e171d41c5c3bb54cdcd53e04ea28a13fab327d86a5756dee7499f88d163316b93cfebf730a4681ab54a627693f9b
|
7
|
+
data.tar.gz: ce6ab0de40b33e0750f4eb33c63249c91a6b478503cce6fc0cc92081b18190346a9e4190027b940020f69459c40094a963b3a0d1e440e63ed4a2f47e1bd904cd
|
data/.github/probots.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -17,6 +17,8 @@ module GraphitiGql
|
|
17
17
|
Node.new(edge.except(:node).merge(node_id: node_id))
|
18
18
|
end
|
19
19
|
hash[key] = value[:edges].map { |v| Node.new(v[:node], sideload.resource.class) }
|
20
|
+
elsif value.key?(:nodes)
|
21
|
+
hash[key] = value[:nodes].map { |n| Node.new(n, sideload.resource.class) }
|
20
22
|
else
|
21
23
|
hash[key] = Node.new(value, sideload.resource.class)
|
22
24
|
end
|
@@ -115,8 +117,9 @@ module GraphitiGql
|
|
115
117
|
return @query if @query
|
116
118
|
|
117
119
|
name = Schema.registry.key_for(@resource)
|
118
|
-
filter_bang = "!" if @resource.filters.values.any? { |f| f[:required] }
|
119
120
|
sortvar = "$sort: [#{name}Sort!]," if @resource.sorts.any?
|
121
|
+
filter_bang = "!" if @resource.filters.values.any? { |f| f[:required] }
|
122
|
+
filtervar = "$filter: #{name}Filter#{filter_bang}," if @resource.filters.any?
|
120
123
|
|
121
124
|
if !(fields = @params[:fields])
|
122
125
|
fields = []
|
@@ -127,7 +130,7 @@ module GraphitiGql
|
|
127
130
|
|
128
131
|
q = %|
|
129
132
|
query #{name} (
|
130
|
-
|
133
|
+
#{filtervar}
|
131
134
|
#{sortvar}
|
132
135
|
$first: Int,
|
133
136
|
$last: Int,
|
@@ -135,7 +138,7 @@ module GraphitiGql
|
|
135
138
|
$after: String,
|
136
139
|
) {
|
137
140
|
#{@resource.graphql_entrypoint} (
|
138
|
-
filter: $filter,
|
141
|
+
#{ 'filter: $filter,' if filtervar }
|
139
142
|
#{ 'sort: $sort,' if sortvar }
|
140
143
|
first: $first,
|
141
144
|
last: $last,
|
@@ -162,6 +162,7 @@ module GraphitiGql
|
|
162
162
|
|
163
163
|
def apply_belongs_to_many_filter
|
164
164
|
super
|
165
|
+
return unless respond_to?(:belongs_to_many_filter) # activerecord
|
165
166
|
self_ref = self
|
166
167
|
fk_type = parent_resource_class.attributes[:id][:type]
|
167
168
|
fk_type = :hash if polymorphic?
|
@@ -4,11 +4,8 @@ module GraphitiGql
|
|
4
4
|
class ToMany
|
5
5
|
def initialize(sideload, sideload_type)
|
6
6
|
@sideload = sideload
|
7
|
-
@sideload_type =
|
8
|
-
|
9
|
-
else
|
10
|
-
sideload_type
|
11
|
-
end
|
7
|
+
@sideload_type = sideload_type
|
8
|
+
@connection_type = find_or_build_connection
|
12
9
|
end
|
13
10
|
|
14
11
|
def apply(type)
|
@@ -18,7 +15,7 @@ module GraphitiGql
|
|
18
15
|
extras: [:lookahead]
|
19
16
|
}
|
20
17
|
opts[:extensions] = [RelayConnectionExtension] unless has_one?
|
21
|
-
field_type = has_one? ? @sideload_type : @
|
18
|
+
field_type = has_one? ? @sideload_type : @connection_type
|
22
19
|
field = type.field @sideload.name,
|
23
20
|
field_type,
|
24
21
|
**opts
|
@@ -41,23 +38,23 @@ module GraphitiGql
|
|
41
38
|
@sideload.type == :many_to_many && @sideload.class.edge_resource
|
42
39
|
end
|
43
40
|
|
44
|
-
def
|
45
|
-
|
41
|
+
def find_or_build_connection
|
42
|
+
registered_parent = Schema.registry.get(@sideload.parent_resource.class)
|
43
|
+
parent_name = registered_parent[:type].graphql_name
|
44
|
+
name = "#{parent_name}To#{@sideload_type.graphql_name}Connection"
|
45
|
+
return Schema.registry[name][:type] if Schema.registry[name]
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
klass =
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
klass.
|
54
|
-
|
55
|
-
klass.edge_type_class(edge_type_class)
|
47
|
+
if customized_edge?
|
48
|
+
prior = @sideload_type.connection_type
|
49
|
+
klass = Class.new(prior)
|
50
|
+
klass.graphql_name(name)
|
51
|
+
edge_type_class = build_edge_type_class(@sideload_type)
|
52
|
+
edge_type_class.node_type(prior.node_type)
|
53
|
+
klass.edge_type(edge_type_class)
|
54
|
+
Schema.registry[name] = { type: klass }
|
56
55
|
klass
|
57
56
|
else
|
58
|
-
|
59
|
-
klass.edge_type_class(edge_class)
|
60
|
-
klass
|
57
|
+
@sideload_type.connection_type
|
61
58
|
end
|
62
59
|
end
|
63
60
|
|
@@ -23,12 +23,15 @@ module GraphitiGql
|
|
23
23
|
Registry.instance
|
24
24
|
end
|
25
25
|
|
26
|
+
# TODO - when no sorts schema error, when no filters schema error
|
26
27
|
def define_filters(field)
|
27
28
|
filter_type = generate_filter_type(field)
|
28
29
|
required = @resource.filters.any? { |name, config|
|
29
30
|
value = !!config[:required]
|
30
31
|
if @sideload
|
31
|
-
|
32
|
+
fk = @sideload.foreign_key
|
33
|
+
fk = fk.values.first if fk.is_a?(Hash)
|
34
|
+
value && fk != name
|
32
35
|
else
|
33
36
|
value
|
34
37
|
end
|
data/lib/graphiti_gql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti_gql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -115,6 +115,7 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
+
- ".github/probots.yml"
|
118
119
|
- ".gitignore"
|
119
120
|
- ".rspec"
|
120
121
|
- ".travis.yml"
|