graphql-active_record 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a42c1c4d191558622eb115e0055a19e7d1a7bd3f
4
- data.tar.gz: d23d359283a6245a1513838adfcda0833ad8e329
3
+ metadata.gz: 9bdc7ab9b28d7a7bad0891c742b5b0fb72e7a1bc
4
+ data.tar.gz: ce12f8396bf35abc87c1b963634f8b935e8a911c
5
5
  SHA512:
6
- metadata.gz: c45cb2a9e0103b8b88170b655463e7655f6c9b50184a67b4d4c05de4bb61efb96ee3c20d72e263a71fa4cee213306f099b398d38130ab7adbb3ab17356e248da
7
- data.tar.gz: edca63d81a3e08e94f712437800551e7e503d5de9474c02c92db0c13f728c3095ab6c8c452e845c0326a5f33a88ab2d8efdbe40629dd1ecb5e1ab8c0e04cafc7
6
+ metadata.gz: e1e7977bd16d41d5b0cd0cfd820483221d7de8410a82091015903cac9e1765b58837c1b6eb2b592cd5c4d7b002ac523e4c10f36f3562a787ae85e5a949dfe792
7
+ data.tar.gz: 51f41cc5ab110eb15d3667fb776e4378c531472679d1c1451ef71ea6b8c3f775090b4a554ba9947104f6553781851a24d90feea2fd98e868238e722d787920a7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # version 2.2.2
2
+ fix for non-ActiveRecord models failing on includes
3
+
1
4
  # version 2.2.1
2
5
  fix fragments for newer versions `graphql-ruby`
3
6
 
@@ -80,11 +80,14 @@ module GraphQL
80
80
 
81
81
  nested = map_includes(next_model, node.selections, ctx)
82
82
 
83
- final_type = if (model.reflections[singular] || model.reflections[singular.to_sym]).present?
83
+ singular_reflection = model.reflections[singular] || model.reflections[singular.to_sym]
84
+ plural_reflection = model.reflections[plural] || model.reflections[plural.to_sym]
85
+
86
+ final_type = if valid_association(singular_reflection)
84
87
  # this is for has_one relationships
85
88
  singular
86
89
 
87
- elsif (model.reflections[plural] || model.reflections[plural.to_sym]).present?
90
+ elsif valid_association(plural_reflection)
88
91
  # this is for has_many relationships
89
92
  plural
90
93
 
@@ -142,6 +145,19 @@ module GraphQL
142
145
  [node.name, node]
143
146
  end
144
147
  end
148
+
149
+ ##
150
+ # Method to check whether a reflection is valid.
151
+ # Some things, like PowerEnum, have reflections but do not work properly
152
+ # because they do not have an association_class. So ignore them.
153
+ #
154
+ # @param reflection [ActiveRecord::Associations::* | any | nil] Inputted Association
155
+ # @return [boolean] Whether or not the association is valid
156
+ def self.valid_association(reflection)
157
+ return false if reflection.blank?
158
+ return false unless reflection.respond_to?(:association_class)
159
+ return (reflection.association_class < ActiveRecord::Associations::Association)
160
+ end
145
161
  end
146
162
  end
147
163
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module ActiveRecordExtensions
3
- VERSION = "2.2.1"
3
+ VERSION = "2.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Jurgens
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-15 00:00:00.000000000 Z
11
+ date: 2017-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -232,9 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements: []
234
234
  rubyforge_project:
235
- rubygems_version: 2.4.5.1
235
+ rubygems_version: 2.5.2
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Active Record Helpers for graphql-ruby
239
239
  test_files: []
240
- has_rdoc: