graphiti_gql 0.2.7 → 0.2.8

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: d38c8d27dc214efd323ee98932bcb858bca8553e45c5e4428858b3b5503db44d
4
- data.tar.gz: ae38e08ba55f6c38b464ed9a3cbd592394568c080aac2361d0549adea259b9fe
3
+ metadata.gz: c8711fac905c21ac485bec3ead197d2c5a8e2135eb5fcf1ff4156fec2a34d3ec
4
+ data.tar.gz: 82a643591b6f630d78d67e480cf915b8dbf1c0531fa0c817f204a9ae405d237c
5
5
  SHA512:
6
- metadata.gz: d50257d774787869a18187e76e924503fb34dfad8c4d93fd73d99289fc203626d120585448bc646175cb9ff80e607df5c374a6207a95732aeccedb2d20ea9d39
7
- data.tar.gz: e1f1ff11574682dd8946907f2e76e3b9279c08039e29e4bc1f53436f184c1e6bd0e04f2ef52f391526abd1d837ef6a9dbd3f1a8a617528ee90942857b66d9706
6
+ metadata.gz: 6a6935dda01d0d68bacfc8c49252469322e93c96613a852f092dc76aa80cc44545b7e3c3d478fd5da28d6039c1a33940c9164f8bb1aad0b8018b1d2a5c92de72
7
+ data.tar.gz: fd9004e64db1c3dc39321e4eb2df56e5a7bf37a221c5323b062ddce182446ea1a4285649f61fdbb8508ac0b1a654c3311a7429bdc535f2589866b053c9d0617e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphiti_gql (0.2.2)
4
+ graphiti_gql (0.2.7)
5
5
  graphiti (~> 1.3.9)
6
6
  graphql (~> 2.0)
7
7
  graphql-batch (~> 0.5)
@@ -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 = if customized_edge?
8
- build_customized_edge_type(sideload_type)
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 : @sideload_type.connection_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,20 @@ module GraphitiGql
41
38
  @sideload.type == :many_to_many && @sideload.class.edge_resource
42
39
  end
43
40
 
44
- def build_customized_edge_type(sideload_type)
45
- edge_type_class = build_edge_type_class(sideload_type)
46
-
47
- # Build the sideload type with new edge class applied
48
- if sideload_type.is_a?(Module)
49
- klass = sideload_type
50
- # There's some magic that happens when subclassing, but modules
51
- # don't subclass. This is the kind of resetting we need to happen.
52
- # Might be a graphql-ruby issue.
53
- klass.instance_variable_set(:@connection_type, nil)
54
- klass.instance_variable_set(:@edge_type, nil)
55
- klass.edge_type_class(edge_type_class)
41
+ def find_or_build_connection
42
+ if customized_edge?
43
+ prior = @sideload_type.connection_type
44
+ klass = Class.new(prior)
45
+ registered_parent = Schema.registry.get(@sideload.parent_resource.class)
46
+ parent_name = registered_parent[:type].graphql_name
47
+ name = "#{parent_name}To#{@sideload_type.graphql_name}Connection"
48
+ klass.graphql_name(name)
49
+ edge_type_class = build_edge_type_class(@sideload_type)
50
+ edge_type_class.node_type(prior.node_type)
51
+ klass.edge_type(edge_type_class)
56
52
  klass
57
53
  else
58
- klass = Class.new(sideload_type)
59
- klass.edge_type_class(edge_class)
60
- klass
54
+ @sideload_type.connection_type
61
55
  end
62
56
  end
63
57
 
@@ -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
- value && @sideload.foreign_key != name
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
@@ -1,3 +1,3 @@
1
1
  module GraphitiGql
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti_gql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2022-07-11 00:00:00.000000000 Z
@@ -108,7 +108,7 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '7.0'
111
- description:
111
+ description:
112
112
  email:
113
113
  - richmolj@gmail.com
114
114
  executables: []
@@ -170,7 +170,7 @@ licenses:
170
170
  - MIT
171
171
  metadata:
172
172
  homepage_uri: https://www.graphiti.dev
173
- post_install_message:
173
+ post_install_message:
174
174
  rdoc_options: []
175
175
  require_paths:
176
176
  - lib
@@ -185,8 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
- rubygems_version: 3.0.3.1
189
- signing_key:
188
+ rubygems_version: 3.3.7
189
+ signing_key:
190
190
  specification_version: 4
191
191
  summary: GraphQL support for Graphiti
192
192
  test_files: []