graphiti 1.2.16 → 1.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +96 -0
- data/.standard.yml +4 -4
- data/Appraisals +23 -17
- data/CHANGELOG.md +7 -1
- data/Guardfile +5 -5
- data/deprecated_generators/graphiti/generator_mixin.rb +1 -0
- data/deprecated_generators/graphiti/resource_generator.rb +1 -1
- data/gemfiles/{rails_5.gemfile → rails_5_2.gemfile} +2 -2
- data/gemfiles/{rails_5_graphiti_rails.gemfile → rails_5_2_graphiti_rails.gemfile} +3 -4
- data/gemfiles/rails_6.gemfile +1 -1
- data/gemfiles/rails_6_graphiti_rails.gemfile +2 -3
- data/gemfiles/{rails_4.gemfile → rails_7.gemfile} +2 -2
- data/gemfiles/rails_7_graphiti_rails.gemfile +19 -0
- data/graphiti.gemspec +16 -16
- data/lib/graphiti/adapters/abstract.rb +20 -5
- data/lib/graphiti/adapters/active_record/belongs_to_sideload.rb +1 -1
- data/lib/graphiti/adapters/active_record/has_many_sideload.rb +1 -1
- data/lib/graphiti/adapters/active_record/has_one_sideload.rb +1 -1
- data/lib/graphiti/adapters/active_record/{inferrence.rb → inference.rb} +2 -2
- data/lib/graphiti/adapters/active_record/many_to_many_sideload.rb +19 -0
- data/lib/graphiti/adapters/active_record.rb +119 -74
- data/lib/graphiti/adapters/graphiti_api.rb +1 -1
- data/lib/graphiti/adapters/null.rb +1 -1
- data/lib/graphiti/adapters/persistence/associations.rb +78 -0
- data/lib/graphiti/configuration.rb +3 -1
- data/lib/graphiti/debugger.rb +12 -8
- data/lib/graphiti/delegates/pagination.rb +47 -13
- data/lib/graphiti/deserializer.rb +3 -3
- data/lib/graphiti/errors.rb +109 -15
- data/lib/graphiti/extensions/extra_attribute.rb +4 -4
- data/lib/graphiti/extensions/temp_id.rb +1 -1
- data/lib/graphiti/filter_operators.rb +0 -1
- data/lib/graphiti/hash_renderer.rb +198 -21
- data/lib/graphiti/query.rb +105 -73
- data/lib/graphiti/railtie.rb +5 -5
- data/lib/graphiti/renderer.rb +19 -1
- data/lib/graphiti/request_validator.rb +10 -10
- data/lib/graphiti/request_validators/update_validator.rb +4 -5
- data/lib/graphiti/request_validators/validator.rb +38 -24
- data/lib/graphiti/resource/configuration.rb +35 -7
- data/lib/graphiti/resource/dsl.rb +34 -8
- data/lib/graphiti/resource/interface.rb +13 -3
- data/lib/graphiti/resource/links.rb +3 -3
- data/lib/graphiti/resource/persistence.rb +2 -1
- data/lib/graphiti/resource/polymorphism.rb +8 -2
- data/lib/graphiti/resource/remote.rb +2 -2
- data/lib/graphiti/resource/sideloading.rb +4 -4
- data/lib/graphiti/resource.rb +12 -1
- data/lib/graphiti/resource_proxy.rb +23 -3
- data/lib/graphiti/runner.rb +5 -5
- data/lib/graphiti/schema.rb +36 -11
- data/lib/graphiti/schema_diff.rb +44 -4
- data/lib/graphiti/scope.rb +8 -10
- data/lib/graphiti/scoping/base.rb +3 -3
- data/lib/graphiti/scoping/filter.rb +36 -15
- data/lib/graphiti/scoping/filter_group_validator.rb +78 -0
- data/lib/graphiti/scoping/paginate.rb +47 -3
- data/lib/graphiti/scoping/sort.rb +5 -7
- data/lib/graphiti/serializer.rb +49 -7
- data/lib/graphiti/sideload/belongs_to.rb +1 -1
- data/lib/graphiti/sideload/has_many.rb +19 -1
- data/lib/graphiti/sideload/many_to_many.rb +11 -4
- data/lib/graphiti/sideload/polymorphic_belongs_to.rb +3 -4
- data/lib/graphiti/sideload.rb +47 -23
- data/lib/graphiti/stats/dsl.rb +0 -1
- data/lib/graphiti/stats/payload.rb +12 -9
- data/lib/graphiti/types.rb +15 -15
- data/lib/graphiti/util/attribute_check.rb +1 -1
- data/lib/graphiti/util/class.rb +6 -0
- data/lib/graphiti/util/link.rb +10 -2
- data/lib/graphiti/util/persistence.rb +21 -78
- data/lib/graphiti/util/relationship_payload.rb +4 -4
- data/lib/graphiti/util/remote_params.rb +9 -4
- data/lib/graphiti/util/remote_serializer.rb +1 -0
- data/lib/graphiti/util/serializer_attributes.rb +41 -11
- data/lib/graphiti/util/simple_errors.rb +4 -4
- data/lib/graphiti/util/transaction_hooks_recorder.rb +1 -1
- data/lib/graphiti/version.rb +1 -1
- data/lib/graphiti.rb +6 -3
- metadata +46 -37
- data/.travis.yml +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f5b9382256603c1f3f8f4ab8c4e614804c1a2e2152617d7b19892bca6bd465
|
4
|
+
data.tar.gz: 948837bfa0f8deee2f44849aba9df2bb18f2fdf532a1caaab92b16c7d9ba91fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fe6fff9c219fd463378bbdc793f648cbeffe27c61c191f11e2aab4723e952d2d8f7cc26b334255e12adca3e9d819b1bbde17697a6621f11a28151d2649d6d9c
|
7
|
+
data.tar.gz: becca9eaa17f328a99669e1e855a4024862b45d1902ddf30de597f7b33e3f52e4145b0f1dba1542a0d144ba2bc1bdec280ad9d8fa599a102ead9efb5260e1ab3
|
@@ -0,0 +1,96 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request: {}
|
7
|
+
|
8
|
+
concurrency:
|
9
|
+
group: ci-${{ github.head_ref || github.ref }}
|
10
|
+
cancel-in-progress: true
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
lint:
|
14
|
+
name: Lint
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: "3.0"
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Run standardrb
|
23
|
+
run: bundle exec standardrb --no-fix --format progress
|
24
|
+
test:
|
25
|
+
name: "Tests - ${{ matrix.ruby }} | ${{ matrix.gemfile }} | Appraisal: ${{ matrix.appraisal }}"
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
strategy:
|
28
|
+
fail-fast: false
|
29
|
+
matrix:
|
30
|
+
ruby:
|
31
|
+
- "2.6"
|
32
|
+
- "2.7"
|
33
|
+
- "3.0"
|
34
|
+
- "3.1"
|
35
|
+
gemfile:
|
36
|
+
- Gemfile
|
37
|
+
- gemfiles/rails_5_2.gemfile
|
38
|
+
- gemfiles/rails_6.gemfile
|
39
|
+
- gemfiles/rails_7.gemfile
|
40
|
+
- gemfiles/rails_5_2_graphiti_rails.gemfile
|
41
|
+
- gemfiles/rails_6_graphiti_rails.gemfile
|
42
|
+
- gemfiles/rails_7_graphiti_rails.gemfile
|
43
|
+
appraisal:
|
44
|
+
- true
|
45
|
+
- false
|
46
|
+
include:
|
47
|
+
- ruby: ruby-head
|
48
|
+
gemfile: Gemfile
|
49
|
+
appraisal: true
|
50
|
+
- ruby: ruby-head
|
51
|
+
gemfile: Gemfile
|
52
|
+
appraisal: false
|
53
|
+
exclude:
|
54
|
+
# Skip some extra variants
|
55
|
+
- gemfile: Gemfile
|
56
|
+
appraisal: true
|
57
|
+
- gemfile: gemfiles/rails_5_2.gemfile
|
58
|
+
appraisal: false
|
59
|
+
- gemfile: gemfiles/rails_6.gemfile
|
60
|
+
appraisal: false
|
61
|
+
- gemfile: gemfiles/rails_7.gemfile
|
62
|
+
appraisal: false
|
63
|
+
- gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
|
64
|
+
appraisal: false
|
65
|
+
- gemfile: gemfiles/rails_6_graphiti_rails.gemfile
|
66
|
+
appraisal: false
|
67
|
+
- gemfile: gemfiles/rails_7_graphiti_rails.gemfile
|
68
|
+
appraisal: false
|
69
|
+
# Rails 5 can't run on Ruby 3
|
70
|
+
- gemfile: gemfiles/rails_5_2.gemfile
|
71
|
+
ruby: 3.0
|
72
|
+
- gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
|
73
|
+
ruby: 3.0
|
74
|
+
- gemfile: gemfiles/rails_5_2.gemfile
|
75
|
+
ruby: 3.1
|
76
|
+
- gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
|
77
|
+
ruby: 3.1
|
78
|
+
# Raise 7 can't run on 2.6
|
79
|
+
- gemfile: gemfiles/rails_7.gemfile
|
80
|
+
ruby: 2.6
|
81
|
+
- gemfile: gemfiles/rails_7_graphiti_rails.gemfile
|
82
|
+
ruby: 2.6
|
83
|
+
continue-on-error: ${{ matrix.ruby == 'ruby-head' }}
|
84
|
+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
85
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
|
86
|
+
steps:
|
87
|
+
- name: Set up Appraisal
|
88
|
+
if: matrix.appraisal
|
89
|
+
run: echo "APPRAISAL_INITIALIZED=true" >> $GITHUB_ENV
|
90
|
+
- uses: actions/checkout@v2
|
91
|
+
- uses: ruby/setup-ruby@v1
|
92
|
+
with:
|
93
|
+
ruby-version: ${{ matrix.ruby }}
|
94
|
+
bundler-cache: true
|
95
|
+
- name: Run tests
|
96
|
+
run: bundle exec rspec
|
data/.standard.yml
CHANGED
@@ -8,7 +8,7 @@ ignore:
|
|
8
8
|
# There are some false hits when doing repeated
|
9
9
|
# Class.new blocks in different test cases
|
10
10
|
- Lint/DuplicateMethods
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
-
|
11
|
+
# We define a lot of test-specific classes within our test blocks
|
12
|
+
# There's probably a better way to do this, but it's not worth the
|
13
|
+
# effort right now, so let's just disable for specs
|
14
|
+
- Lint/ConstantDefinitionInBlock
|
data/Appraisals
CHANGED
@@ -1,38 +1,44 @@
|
|
1
|
-
appraise "rails-
|
2
|
-
gem "rails", "~>
|
1
|
+
appraise "rails-5_2" do
|
2
|
+
gem "rails", "~> 5.2.0"
|
3
3
|
gem "rspec-rails"
|
4
|
-
gem "sqlite3", "~> 1.
|
4
|
+
gem "sqlite3", "~> 1.4.0"
|
5
5
|
gem "database_cleaner"
|
6
6
|
end
|
7
7
|
|
8
|
-
appraise "rails-
|
9
|
-
gem "rails", "~> 5.2"
|
8
|
+
appraise "rails-5_2-graphiti-rails" do
|
9
|
+
gem "rails", "~> 5.2.0"
|
10
10
|
gem "rspec-rails"
|
11
|
-
gem "sqlite3", "~> 1.
|
11
|
+
gem "sqlite3", "~> 1.4.0"
|
12
12
|
gem "database_cleaner"
|
13
|
+
gem "graphiti-rails", "~> 0.4.0"
|
13
14
|
end
|
14
15
|
|
15
|
-
appraise "rails-
|
16
|
-
gem "rails", "~>
|
16
|
+
appraise "rails-6" do
|
17
|
+
gem "rails", "~> 6.0"
|
17
18
|
gem "rspec-rails"
|
18
|
-
gem "sqlite3", "~> 1.
|
19
|
+
gem "sqlite3", "~> 1.4.0"
|
19
20
|
gem "database_cleaner"
|
20
|
-
gem "rescue_registry", git: "https://github.com/wagenet/rescue_registry.git", branch: "master"
|
21
|
-
gem "graphiti-rails", git: "https://github.com/wagenet/graphiti-rails.git", branch: "master"
|
22
21
|
end
|
23
22
|
|
24
|
-
appraise "rails-6" do
|
25
|
-
gem "rails", "~> 6.0
|
23
|
+
appraise "rails-6-graphiti-rails" do
|
24
|
+
gem "rails", "~> 6.0"
|
26
25
|
gem "rspec-rails"
|
27
26
|
gem "sqlite3", "~> 1.4.0"
|
28
27
|
gem "database_cleaner"
|
28
|
+
gem "graphiti-rails", "~> 0.4.0"
|
29
29
|
end
|
30
30
|
|
31
|
-
appraise "rails-
|
32
|
-
gem "rails", "~>
|
31
|
+
appraise "rails-7" do
|
32
|
+
gem "rails", "~> 7.0"
|
33
|
+
gem "rspec-rails"
|
34
|
+
gem "sqlite3", "~> 1.4.0"
|
35
|
+
gem "database_cleaner"
|
36
|
+
end
|
37
|
+
|
38
|
+
appraise "rails-7-graphiti-rails" do
|
39
|
+
gem "rails", "~> 7.0"
|
33
40
|
gem "rspec-rails"
|
34
41
|
gem "sqlite3", "~> 1.4.0"
|
35
42
|
gem "database_cleaner"
|
36
|
-
gem "
|
37
|
-
gem "graphiti-rails", git: "https://github.com/wagenet/graphiti-rails.git", branch: "master"
|
43
|
+
gem "graphiti-rails", "~> 0.4.0"
|
38
44
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
3
|
Features:
|
4
|
-
|
4
|
+
- [329](https://github.com/graphiti-api/graphiti/pull/329) Propagate `extra_fields` to related resource links.
|
5
|
+
- [242](https://github.com/graphiti-api/graphiti/pull/242) Bump `jsonapi-renderer` to `~0.2.2` now that (https://github.com/jsonapi-rb/jsonapi-renderer/pull/36) is fixed.
|
5
6
|
- [158](https://github.com/graphiti-api/graphiti/pull/158) Filters options `allow_nil: true`
|
6
7
|
Option can be set at the resource level `Resource.filters_accept_nil_by_default = true`.
|
7
8
|
By default this is set to false. (@zeisler)
|
8
9
|
- [157](https://github.com/graphiti-api/graphiti/pull/157) Using attribute option schema: false.
|
9
10
|
This option is default true and is not effected by only and except options. (@zeisler)
|
10
11
|
|
12
|
+
Fixes:
|
13
|
+
- [282] Support model names including "Resource"
|
14
|
+
- [313](https://github.com/graphiti-api/graphiti/pull/313) Sort remote resources in schema generation
|
15
|
+
- [374](https://github.com/graphiti-api/graphiti/pull/374) Trim leading spaces from error messages
|
16
|
+
|
11
17
|
## 1.1.0
|
12
18
|
|
13
19
|
Features:
|
data/Guardfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
guard :rspec, cmd: "bundle exec rspec --color --format documentation" do
|
2
2
|
require "guard/rspec/dsl"
|
3
3
|
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
-
watch(%r{^spec/(.*)
|
4
|
+
watch(%r{^spec/(.*)/?(.*)_spec\.rb$})
|
5
5
|
|
6
6
|
# Feel free to open issues for suggestions and improvements
|
7
7
|
|
@@ -21,12 +21,12 @@ guard :rspec, cmd: "bundle exec rspec --color --format documentation" do
|
|
21
21
|
watch(rails.controllers) do |m|
|
22
22
|
[
|
23
23
|
rspec.spec.call("controllers/#{m[1]}_controller"),
|
24
|
-
rspec.spec.call("api/#{m[1]}")
|
24
|
+
rspec.spec.call("api/#{m[1]}")
|
25
25
|
]
|
26
26
|
end
|
27
27
|
|
28
28
|
# Rails config changes
|
29
|
-
watch(rails.spec_helper)
|
30
|
-
watch(rails.routes)
|
31
|
-
watch(rails.app_controller)
|
29
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
30
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
31
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
32
32
|
end
|
@@ -93,7 +93,7 @@ module Graphiti
|
|
93
93
|
raise "Unable to set #{self} default_attributes from #{attributes_class}. #{attributes_class} must be a kind of ApplicationRecord"
|
94
94
|
end
|
95
95
|
if attributes_class.table_exists?
|
96
|
-
|
96
|
+
attributes_class.columns.map do |c|
|
97
97
|
OpenStruct.new({name: c.name.to_sym, type: c.type})
|
98
98
|
end
|
99
99
|
else
|
@@ -2,12 +2,11 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "rails", "~> 5.2"
|
5
|
+
gem "rails", "~> 5.2.0"
|
6
6
|
gem "rspec-rails"
|
7
|
-
gem "sqlite3", "~> 1.
|
7
|
+
gem "sqlite3", "~> 1.4.0"
|
8
8
|
gem "database_cleaner"
|
9
|
-
gem "
|
10
|
-
gem "graphiti-rails", git: "https://github.com/wagenet/graphiti-rails.git", branch: "master"
|
9
|
+
gem "graphiti-rails", "~> 0.4.0"
|
11
10
|
|
12
11
|
group :test do
|
13
12
|
gem "pry"
|
data/gemfiles/rails_6.gemfile
CHANGED
@@ -2,12 +2,11 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "rails", "~> 6.0
|
5
|
+
gem "rails", "~> 6.0"
|
6
6
|
gem "rspec-rails"
|
7
7
|
gem "sqlite3", "~> 1.4.0"
|
8
8
|
gem "database_cleaner"
|
9
|
-
gem "
|
10
|
-
gem "graphiti-rails", git: "https://github.com/wagenet/graphiti-rails.git", branch: "master"
|
9
|
+
gem "graphiti-rails", "~> 0.4.0"
|
11
10
|
|
12
11
|
group :test do
|
13
12
|
gem "pry"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 7.0"
|
6
|
+
gem "rspec-rails"
|
7
|
+
gem "sqlite3", "~> 1.4.0"
|
8
|
+
gem "database_cleaner"
|
9
|
+
gem "graphiti-rails", "~> 0.4.0"
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem "pry"
|
13
|
+
gem "pry-byebug", platform: [:mri]
|
14
|
+
gem "appraisal"
|
15
|
+
gem "guard"
|
16
|
+
gem "guard-rspec"
|
17
|
+
end
|
18
|
+
|
19
|
+
gemspec path: "../"
|
data/graphiti.gemspec
CHANGED
@@ -3,33 +3,33 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require "graphiti/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = "graphiti"
|
7
|
+
spec.version = Graphiti::VERSION
|
8
|
+
spec.authors = ["Lee Richmond"]
|
9
|
+
spec.email = ["richmolj@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.homepage
|
13
|
-
spec.license
|
11
|
+
spec.summary = "Easily build jsonapi.org-compatible APIs"
|
12
|
+
spec.homepage = "https://github.com/graphiti-api/graphiti"
|
13
|
+
spec.license = "MIT"
|
14
14
|
|
15
|
-
spec.files
|
16
|
-
spec.bindir
|
17
|
-
spec.executables
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
|
-
spec.required_ruby_version = "
|
19
|
+
spec.required_ruby_version = ">= 2.6"
|
20
20
|
|
21
21
|
spec.add_dependency "jsonapi-serializable", "~> 0.3.0"
|
22
|
-
spec.add_dependency "jsonapi-renderer", "0.2.
|
22
|
+
spec.add_dependency "jsonapi-renderer", "~> 0.2", ">= 0.2.2"
|
23
23
|
spec.add_dependency "dry-types", ">= 0.15.0", "< 2.0"
|
24
24
|
spec.add_dependency "graphiti_errors", "~> 1.1.0"
|
25
25
|
spec.add_dependency "concurrent-ruby", "~> 1.0"
|
26
|
-
spec.add_dependency "activesupport", ">=
|
26
|
+
spec.add_dependency "activesupport", ">= 5.2"
|
27
27
|
|
28
28
|
spec.add_development_dependency "faraday", "~> 0.15"
|
29
29
|
spec.add_development_dependency "kaminari", "~> 0.17"
|
30
30
|
spec.add_development_dependency "bundler"
|
31
|
-
spec.add_development_dependency "rake", "
|
32
|
-
spec.add_development_dependency "
|
31
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
32
|
+
spec.add_development_dependency "standard", "~> 1.4.0"
|
33
|
+
spec.add_development_dependency "activemodel", ">= 5.2"
|
33
34
|
spec.add_development_dependency "graphiti_spec_helpers", "1.0.beta.4"
|
34
|
-
spec.add_development_dependency "standard"
|
35
35
|
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Graphiti
|
2
2
|
module Adapters
|
3
3
|
class Abstract
|
4
|
+
require "graphiti/adapters/persistence/associations"
|
5
|
+
include Graphiti::Adapters::Persistence::Associations
|
6
|
+
|
4
7
|
attr_reader :resource
|
5
8
|
|
6
9
|
def initialize(resource)
|
@@ -17,7 +20,7 @@ module Graphiti
|
|
17
20
|
belongs_to: ::Graphiti::Sideload::BelongsTo,
|
18
21
|
has_one: ::Graphiti::Sideload::HasOne,
|
19
22
|
many_to_many: ::Graphiti::Sideload::ManyToMany,
|
20
|
-
polymorphic_belongs_to: ::Graphiti::Sideload::PolymorphicBelongsTo
|
23
|
+
polymorphic_belongs_to: ::Graphiti::Sideload::PolymorphicBelongsTo
|
21
24
|
}
|
22
25
|
end
|
23
26
|
|
@@ -33,7 +36,7 @@ module Graphiti
|
|
33
36
|
:suffix,
|
34
37
|
:not_suffix,
|
35
38
|
:match,
|
36
|
-
:not_match
|
39
|
+
:not_match
|
37
40
|
],
|
38
41
|
uuid: [:eq, :not_eq],
|
39
42
|
enum: [:eq, :not_eq],
|
@@ -45,7 +48,7 @@ module Graphiti
|
|
45
48
|
date: numerical_operators,
|
46
49
|
datetime: numerical_operators,
|
47
50
|
hash: [:eq],
|
48
|
-
array: [:eq]
|
51
|
+
array: [:eq]
|
49
52
|
}
|
50
53
|
end
|
51
54
|
|
@@ -241,14 +244,15 @@ module Graphiti
|
|
241
244
|
# @param scope The scope object we are chaining
|
242
245
|
# @param [Integer] current_page The current page number
|
243
246
|
# @param [Integer] per_page The number of results per page
|
247
|
+
# @param [Integer] offset The offset to start from
|
244
248
|
# @return the scope
|
245
249
|
#
|
246
250
|
# @example ActiveRecord default
|
247
251
|
# # via kaminari gem
|
248
|
-
# def paginate(scope, current_page, per_page)
|
252
|
+
# def paginate(scope, current_page, per_page, offset)
|
249
253
|
# scope.page(current_page).per(per_page)
|
250
254
|
# end
|
251
|
-
def paginate(scope, current_page, per_page)
|
255
|
+
def paginate(scope, current_page, per_page, offset)
|
252
256
|
raise "you must override #paginate in an adapter subclass"
|
253
257
|
end
|
254
258
|
|
@@ -400,10 +404,21 @@ module Graphiti
|
|
400
404
|
raise "you must override #destroy in an adapter subclass"
|
401
405
|
end
|
402
406
|
|
407
|
+
def close
|
408
|
+
end
|
409
|
+
|
410
|
+
def persistence_attributes(persistance, attributes)
|
411
|
+
attributes
|
412
|
+
end
|
413
|
+
|
403
414
|
def self.numerical_operators
|
404
415
|
[:eq, :not_eq, :gt, :gte, :lt, :lte].freeze
|
405
416
|
end
|
406
417
|
|
418
|
+
def can_group?
|
419
|
+
false
|
420
|
+
end
|
421
|
+
|
407
422
|
private
|
408
423
|
|
409
424
|
def activerecord_adapter
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module Graphiti::Adapters::ActiveRecord::
|
1
|
+
module Graphiti::Adapters::ActiveRecord::Inference
|
2
2
|
# If going AR to AR, use AR introspection
|
3
|
-
# If going AR to PORO, fall back to normal
|
3
|
+
# If going AR to PORO, fall back to normal inference
|
4
4
|
def infer_foreign_key
|
5
5
|
parent_model = parent_resource_class.model
|
6
6
|
reflection = parent_model.reflections[association_name.to_s]
|
@@ -8,6 +8,18 @@ class Graphiti::Adapters::ActiveRecord::ManyToManySideload < Graphiti::Sideload:
|
|
8
8
|
foreign_key.keys.first
|
9
9
|
end
|
10
10
|
|
11
|
+
def inverse_filter
|
12
|
+
return @inverse_filter if @inverse_filter
|
13
|
+
|
14
|
+
inferred_name = infer_inverse_association
|
15
|
+
|
16
|
+
if inferred_name
|
17
|
+
"#{inferred_name.to_s.singularize}_id"
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
11
23
|
def belongs_to_many_filter(scope, value)
|
12
24
|
if polymorphic?
|
13
25
|
clauses = value.group_by { |v| v["type"] }.map { |group|
|
@@ -75,4 +87,11 @@ class Graphiti::Adapters::ActiveRecord::ManyToManySideload < Graphiti::Sideload:
|
|
75
87
|
value = through_reflection.foreign_key.to_sym
|
76
88
|
{key => value}
|
77
89
|
end
|
90
|
+
|
91
|
+
def infer_inverse_association
|
92
|
+
through_class = through_reflection.klass
|
93
|
+
|
94
|
+
foreign_reflection = through_class.reflections[name.to_s.singularize]
|
95
|
+
foreign_reflection && foreign_reflection.options[:inverse_of]
|
96
|
+
end
|
78
97
|
end
|