graphiti-rails 0.4.0 → 0.4.1

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: 67a63788c6e7d8f499050adb18b2f7b7f5495eea70622d988e3d456f4126e94a
4
- data.tar.gz: 35a4799fbbd289746c9488d9b719524f4ad88dfd052a0b5f05c4bb752c06604e
3
+ metadata.gz: 1d21bd110b218be81b90dc36e351c4497e372e3d68494e974da486760b79fc0e
4
+ data.tar.gz: 77d43f24e90ad20652f337af5fe0ec975aa7da24d11b4fa1afa1b7cc473357a9
5
5
  SHA512:
6
- metadata.gz: fe9f5da5a0ec25ce89c6e06080391bd6d7093221fdd59003f10b8939a48b80fadd7d290356b83e8d8cf4bb2359c1c13e22a948f37369e9917bb50f59235d9788
7
- data.tar.gz: ccd6afbdfcfc83061f0d8a0f3e0f60e89b70fbc85bf4e61de467315c7fce98a763fe269b92bcca499bee3b9884915e3cd8208859896981127fa0cc5cae34da11
6
+ metadata.gz: 72db45334240aa6a4890a6ed0259676aad04d0d1149c7a00f9fd61e5a4f4a604ec10ccd59673928c95e863ae45267587cec2a8b09af0d72523bb4847e10c4755
7
+ data.tar.gz: af12ee496a30f8e8a712e88bbb50cb70b386d8d05cf0e3aeb7325aaa25d106274edaf693470830560bdfb9aadcb06f88a319295d79b921bf4645e3d324f486dc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ graphiti-rails changelog
2
+
3
+ ## [0.4.1](https://github.com/graphiti-api/graphiti-rails/compare/v0.4.0...v0.4.1) (2025-03-21)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * `register_parameter_parser` overiding custom config ([#109](https://github.com/graphiti-api/graphiti-rails/issues/109)) ([a135bfa](https://github.com/graphiti-api/graphiti-rails/commit/a135bfa7729b921cf57563916567e272237b6b1f))
9
+ * Add basic column type conversion. ([#83](https://github.com/graphiti-api/graphiti-rails/issues/83)) ([e5bbc92](https://github.com/graphiti-api/graphiti-rails/commit/e5bbc92335376311f02af71d0db3ddc13bdd1ad9))
10
+ * Add condition to check RSpec availability in install generator ([#63](https://github.com/graphiti-api/graphiti-rails/issues/63)) ([13895d9](https://github.com/graphiti-api/graphiti-rails/commit/13895d98f8784f5552256840fd44caaa80c4717b))
11
+ * rspec double was leaking across tests ([#105](https://github.com/graphiti-api/graphiti-rails/issues/105)) ([b38faf2](https://github.com/graphiti-api/graphiti-rails/commit/b38faf2a02bd9e5e91e9014ca060092d7398b47d))
12
+ * Stringify path if Rails version > 7 ([#107](https://github.com/graphiti-api/graphiti-rails/issues/107)) ([47d356c](https://github.com/graphiti-api/graphiti-rails/commit/47d356c23c3d800e83236227a6684fc40af360af))
13
+
1
14
  # Changelog
2
15
 
3
16
  All notable changes to this project will be documented in this file.
@@ -7,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
20
 
8
21
  ---
9
22
 
23
+ ## [0.4.0] - 2022-02-03
24
+ - `rescue_registry` has been updated to 0.4.0 for Ruby 3.1 support.
25
+
10
26
  ## [0.3.0] - 2021-05-11
11
27
  ### Changed
12
28
  - `rescue_registry` has been updated to 0.3.0. This causes some changes to error payloads.
@@ -41,8 +41,10 @@ module Graphiti
41
41
  RUBY
42
42
  end
43
43
 
44
- inject_into_file "spec/rails_helper.rb", after: /RSpec.configure.+^end$/m do
45
- "\n\nGraphitiSpecHelpers::RSpec.schema!"
44
+ if defined?(RSpec)
45
+ inject_into_file "spec/rails_helper.rb", after: /RSpec.configure.+^end$/m do
46
+ "\n\nGraphitiSpecHelpers::RSpec.schema!"
47
+ end
46
48
  end
47
49
 
48
50
  insert_into_file "config/routes.rb", after: "Rails.application.routes.draw do\n" do
@@ -100,7 +100,10 @@ module Graphiti
100
100
  end
101
101
  if attributes_class.table_exists?
102
102
  return attributes_class.columns.map do |c|
103
- OpenStruct.new({name: c.name.to_sym, type: c.type})
103
+ OpenStruct.new({
104
+ name: c.name.to_sym,
105
+ type: convert_column_type_to_graphiti_resource_type(c.type)
106
+ })
104
107
  end
105
108
  else
106
109
  raise "#{attributes_class} table must exist. Please run migrations."
@@ -181,5 +184,34 @@ module Graphiti
181
184
  def type
182
185
  model_klass.name.underscore.pluralize
183
186
  end
187
+
188
+ def convert_column_type_to_graphiti_resource_type(type)
189
+ # TODO: Support database specific types.
190
+ case type
191
+ when :string, :text
192
+ :string
193
+ when :float, :decimal
194
+ :integer
195
+ when :integer, :bigint
196
+ :integer
197
+ when :datetime, :time
198
+ :datetime
199
+ when :date
200
+ :date
201
+ when :boolean
202
+ :boolean
203
+ when :numeric
204
+ # TODO: Return type.
205
+ type
206
+ when :primary_key
207
+ # TODO: Return type.
208
+ type
209
+ when :binary
210
+ # TODO: Return type.
211
+ type
212
+ else
213
+ type
214
+ end
215
+ end
184
216
  end
185
217
  end
@@ -72,9 +72,9 @@ module Graphiti
72
72
 
73
73
  def register_parameter_parser
74
74
  if ::Rails::VERSION::MAJOR >= 5
75
- ActionDispatch::Request.parameter_parsers[:jsonapi] = PARSER
75
+ ActionDispatch::Request.parameter_parsers[:jsonapi] ||= PARSER
76
76
  else
77
- ActionDispatch::ParamsParser::DEFAULT_PARSERS[Mime[:jsonapi]] = PARSER
77
+ ActionDispatch::ParamsParser::DEFAULT_PARSERS[Mime[:jsonapi]] ||= PARSER
78
78
  end
79
79
  end
80
80
 
@@ -131,8 +131,11 @@ module Graphiti
131
131
  end
132
132
 
133
133
  route = begin
134
+ if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("7.0.0")
135
+ path = path.to_s
136
+ end
134
137
  ::Rails.application.routes.recognize_path(path, method: method)
135
- rescue
138
+ rescue => e
136
139
  nil
137
140
  end
138
141
  "#{route[:controller]}_controller".classify.safe_constantize if route
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Graphiti
4
4
  module Rails
5
- VERSION = '0.4.0'
5
+ VERSION = '0.4.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Wagenet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-04 00:00:00.000000000 Z
11
+ date: 2025-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphiti
@@ -251,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
251
  - !ruby/object:Gem::Version
252
252
  version: '0'
253
253
  requirements: []
254
- rubygems_version: 3.3.3
254
+ rubygems_version: 3.3.27
255
255
  signing_key:
256
256
  specification_version: 4
257
257
  summary: Rails integration for Graphiti