graphql-rails-api 0.1.4 → 0.1.5
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da727dde4584527a0597124ff476b0366f056ec29f46b51e0886a51f5c7fe00c
|
4
|
+
data.tar.gz: 1ccc03fa9aaf3b81e0df7135571601df989a65b6e6b50d9940ca7329d2a69486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4fc5d6d2e90a155c8dc712b739dc2e2921d12121b46168a7549c2bb16108c5c77620a84c3f6fda467de239d8ced4ddf36db3f9bf8203cabc67a4989cd6248a3
|
7
|
+
data.tar.gz: ca77d437d4f161d16555da1c8dabf16207d798291c883b1f33309467a7470d121f75314f0e8d37f6a4e998cbc0317118ec70d61d4eb6e751288390b1d902b3c2
|
@@ -60,11 +60,14 @@ class GraphqlResourceGenerator < Rails::Generators::NamedBase
|
|
60
60
|
@has_many = []
|
61
61
|
@many_to_many = []
|
62
62
|
@mutations_directory = "#{graphql_resource_directory(@resource)}/mutations"
|
63
|
+
@belongs_to_fields = {}
|
63
64
|
|
64
65
|
@args = args.each_with_object({}) do |f, hash|
|
65
66
|
next if f.split(':').count != 2
|
66
67
|
case f.split(':').first
|
67
|
-
when 'belongs_to' then
|
68
|
+
when 'belongs_to' then
|
69
|
+
hash["#{f.split(':').last.singularize}_id"] = @id_db_type
|
70
|
+
@belongs_to_fields["#{f.split(':').last.singularize}_id"] = @id_db_type
|
68
71
|
when 'has_many' then @has_many << f.split(':').last.pluralize
|
69
72
|
when 'many_to_many' then @many_to_many << f.split(':').last.pluralize
|
70
73
|
else
|
@@ -72,8 +75,6 @@ class GraphqlResourceGenerator < Rails::Generators::NamedBase
|
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
75
|
-
@id_fields = @args.select { |k, _| k.end_with?('_id') }
|
76
|
-
|
77
78
|
@fields_to_migration = @args.map do |f|
|
78
79
|
"t.#{f.reverse.join(' :')}"
|
79
80
|
end.join("\n ")
|
@@ -203,7 +204,7 @@ class GraphqlResourceGenerator < Rails::Generators::NamedBase
|
|
203
204
|
add_has_many_fields_to_type(resource, f)
|
204
205
|
add_belongs_to_field_to_type(resource, f)
|
205
206
|
end
|
206
|
-
@
|
207
|
+
@belongs_to_fields.each do |f, _|
|
207
208
|
add_has_many_fields_to_type(f.gsub('_id', ''), resource)
|
208
209
|
add_belongs_to_field_to_type(f.gsub('_id', ''), resource)
|
209
210
|
end
|
@@ -260,7 +261,7 @@ t.#{@id_db_type} :#{resource.underscore.singularize}_id
|
|
260
261
|
add_to_model(resource, "has_many :#{field.pluralize}")
|
261
262
|
add_to_model(field, "belongs_to :#{resource.singularize}")
|
262
263
|
end
|
263
|
-
@
|
264
|
+
@belongs_to_fields.each do |k, _|
|
264
265
|
field = k.gsub('_id', '')
|
265
266
|
add_to_model(field, "has_many :#{resource.pluralize}")
|
266
267
|
add_to_model(resource, "belongs_to :#{field.singularize}")
|
@@ -272,7 +273,7 @@ t.#{@id_db_type} :#{resource.underscore.singularize}_id
|
|
272
273
|
field_name = k
|
273
274
|
field_type = types_mapping(v)
|
274
275
|
res = "#{input_type ? 'argument' : 'field'} :#{field_name}, #{field_type}"
|
275
|
-
if !input_type && field_name.ends_with?('_id')
|
276
|
+
if !input_type && field_name.ends_with?('_id') && @belongs_to_fields.key?(field_name)
|
276
277
|
res += "\n field :#{field_name.gsub('_id', '')}, " \
|
277
278
|
"!#{field_name.gsub('_id', '').pluralize.camelize}::Type"
|
278
279
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-rails-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- poilon
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
80
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.7.
|
81
|
+
rubygems_version: 2.7.6
|
82
82
|
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: Graphql rails api framework to create easily graphql api with rails
|