graphiti-activegraph 0.1.14 → 0.1.16

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: 8408ce87578c8d1bbe7d0dbdfc96849547a7a994c075fa7d562de1bd673c5e65
4
- data.tar.gz: ea954b8a98e7b82ad3e70683a914a8c536004be3a9ceb0ab219eb79289d59914
3
+ metadata.gz: 9794607d787979d0f7569abd80b40212eec9aedaaa93f176561ff1aef80a914f
4
+ data.tar.gz: 5827cbf1af92884fcb487d799883b3e1df1ea9ef7081aab68c404c96f895338f
5
5
  SHA512:
6
- metadata.gz: b0f4942b81d16f1017ccd0e8e1fe5b308fb7783892186267bdf2ad15cbaefe15d65157910fc46c424e5efa819b7d55830c63b052b2aa68d037dec59c6ba6a03e
7
- data.tar.gz: edeaca909d5b5cad0781cf8cf2e268da49279d64203bb902e8e234cc32c71957af97d8e011c81096467ab4d55222bd135a28e676a2b1ae1f83e419bcb84352f9
6
+ metadata.gz: a81ef5aff8b2dd3e4617ced5388014eb847c230dd34722c00f630cd7ba1cf81789eb16268bec8e5e446771ee68c79a0a06f9f9792579d7b4503657b4cd319a8e
7
+ data.tar.gz: 59cdd93ef290594ea2682bec8cf16da095ae534d9a027036409fde5dd817734e0ecfa10e7c9220121f78132659295893b857e476c5f2c6d0018319ab62b18047
@@ -0,0 +1,31 @@
1
+ name: Specs
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ pull_request:
7
+ branches: [ "master" ]
8
+
9
+ # Allows you to run this workflow manually from the Actions tab
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ test:
17
+ runs-on: ubuntu-latest
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby-version: [ jruby, ruby ]
22
+
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - name: Set up Ruby
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby-version }}
29
+ bundler-cache: true
30
+ - name: Run tests
31
+ run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -20,7 +20,13 @@ Features:
20
20
 
21
21
  - Adding unpaginated query to resource proxy with preloaded records. This will help in getting count on API.
22
22
 
23
- <!-- ### [version (DD-MM-YYYY)](diff_link) -->
23
+ ## 0.1.15 (21-06-2022)
24
+
25
+ Features:
26
+
27
+ - Relationships mentioned in sparse field param (and not in include), will now be returned in relationship block of response
28
+
29
+ <!-- ### [version (DD-MM-YYYY)] -->
24
30
  <!-- Breaking changes:-->
25
31
  <!-- Features:-->
26
32
  <!-- Fixes:-->
@@ -16,18 +16,15 @@ Gem::Specification.new do |spec|
16
16
  spec.bindir = "exe"
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
- spec.required_ruby_version = "~> 2.3"
20
19
 
21
- spec.add_dependency "graphiti", "~> 1.2.0"
22
- spec.add_dependency "concurrent-ruby", "~> 1.0"
23
- spec.add_dependency "activesupport", ">= 4.1"
20
+ spec.add_dependency "graphiti", ">= 1.2.0"
21
+ spec.add_dependency "activegraph", ">= 11.1.0.alpha.1"
24
22
  spec.add_dependency "zeitwerk"
25
23
 
26
24
  spec.add_development_dependency "faraday", "~> 0.15"
27
25
  spec.add_development_dependency "kaminari", "~> 0.17"
28
26
  spec.add_development_dependency "bundler"
29
27
  spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_development_dependency "activemodel", ">= 4.1"
31
28
  spec.add_development_dependency "graphiti_spec_helpers", "1.0.beta.4"
32
29
  spec.add_development_dependency "standard"
33
30
  spec.add_development_dependency "rspec", "~> 3.9.0"
@@ -91,7 +91,7 @@ module Graphiti::ActiveGraph
91
91
  params[:data][:relationships] ||= {}
92
92
  params[:data][:relationships][rel_name] = {
93
93
  data: {
94
- type: rel_name.to_s,
94
+ type: derive_resource_type(rel_name),
95
95
  id: path_value.to_i
96
96
  }
97
97
  }
@@ -122,7 +122,29 @@ module Graphiti::ActiveGraph
122
122
  end
123
123
 
124
124
  def detect_conflict(key, path_value, body_value)
125
- raise Conflict.new(key, path_value, body_value) if body_value && body_value != path_value
125
+ raise Conflict.new(key, path_value, body_value) if path_value && body_value && body_value != path_value
126
+ end
127
+
128
+ private
129
+
130
+ def derive_resource_type(rel_name)
131
+ if @model.include?(ActiveGraph::Node)
132
+ @model.associations[rel_name].target_class.model_name.plural.to_s
133
+ else
134
+ # ApplicationRelationship resource doesn't have #associations or any other method to list all associations
135
+ # "from_class" and "to_class" methods can contain value "any". Which makes it unreliable to use here
136
+ # Using "rel_name.to_s.pluralize" as it works in most cases.
137
+ # User can define a method on controller "" which will override this behaviour
138
+ derive_resource_type_from_controller(rel_name) || rel_name.to_s.pluralize
139
+ end
140
+ end
141
+
142
+ def derive_resource_type_from_controller(rel_name)
143
+ controller_obj.derive_parent_resource_type(rel_name) if controller_obj.respond_to?(:derive_parent_resource_type)
144
+ end
145
+
146
+ def controller_obj
147
+ @controller_obj ||= Graphiti.context[:object]
126
148
  end
127
149
  end
128
150
  end
@@ -0,0 +1,8 @@
1
+ module Graphiti::ActiveGraph::JsonapiExt::Serializable
2
+ module ResourceExt
3
+ def as_jsonapi(fields: nil, include: [])
4
+ include.merge(fields) if fields.present?
5
+ super(fields: fields, include: include)
6
+ end
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  module Graphiti
2
2
  module ActiveGraph
3
- VERSION = '0.1.14'
3
+ VERSION = '0.1.16'
4
4
  end
5
5
  end
@@ -1,27 +1,18 @@
1
1
  require 'zeitwerk'
2
+ require 'active_graph'
2
3
 
3
- # Workaround for missing zeitwerk support as of jruby-9.2.13.0
4
+ # Workaround for jruby prepend issue https://github.com/jruby/jruby/issues/6971
4
5
  module Graphiti
5
- module Scoping
6
- end
7
6
  module ActiveGraph
8
- module Scoping
9
- end
10
- module Adapters
11
- end
12
- module Util
13
- end
7
+ end
8
+ module Scoping
14
9
  end
15
10
  end
16
- # End workaround
17
-
18
- # Workaround for jruby prepend issue https://github.com/jruby/jruby/issues/6971
19
11
  require 'graphiti/scoping/filterable'
20
12
  require 'graphiti/resource/persistence'
21
13
  # End workaround for jruby prepend issue
22
14
 
23
- loader = Zeitwerk::Loader.for_gem
24
- loader.inflector.inflect 'version' => 'VERSION'
15
+ loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
25
16
  loader.ignore(File.expand_path('graphiti-activegraph.rb', __dir__))
26
17
  loader.setup
27
18
 
@@ -39,3 +30,6 @@ Graphiti::Resource.extend Graphiti::ActiveGraph::Resource
39
30
  Graphiti::ResourceProxy.prepend Graphiti::ActiveGraph::ResourceProxy
40
31
  Graphiti::Runner.prepend Graphiti::ActiveGraph::Runner
41
32
  Graphiti::Scope.prepend Graphiti::ActiveGraph::SideloadResolve
33
+
34
+ # JSONAPI extensions
35
+ JSONAPI::Serializable::Resource.prepend Graphiti::ActiveGraph::JsonapiExt::Serializable::ResourceExt
metadata CHANGED
@@ -1,64 +1,50 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti-activegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hardik Joshi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-03 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: graphiti
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - "~>"
17
+ - - ">="
17
18
  - !ruby/object:Gem::Version
18
19
  version: 1.2.0
19
- name: graphiti
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.2.0
27
27
  - !ruby/object:Gem::Dependency
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - "~>"
31
- - !ruby/object:Gem::Version
32
- version: '1.0'
33
- name: concurrent-ruby
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.0'
41
- - !ruby/object:Gem::Dependency
28
+ name: activegraph
42
29
  requirement: !ruby/object:Gem::Requirement
43
30
  requirements:
44
31
  - - ">="
45
32
  - !ruby/object:Gem::Version
46
- version: '4.1'
47
- name: activesupport
33
+ version: 11.1.0.alpha.1
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '4.1'
40
+ version: 11.1.0.alpha.1
55
41
  - !ruby/object:Gem::Dependency
42
+ name: zeitwerk
56
43
  requirement: !ruby/object:Gem::Requirement
57
44
  requirements:
58
45
  - - ">="
59
46
  - !ruby/object:Gem::Version
60
47
  version: '0'
61
- name: zeitwerk
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
@@ -67,12 +53,12 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
56
+ name: faraday
70
57
  requirement: !ruby/object:Gem::Requirement
71
58
  requirements:
72
59
  - - "~>"
73
60
  - !ruby/object:Gem::Version
74
61
  version: '0.15'
75
- name: faraday
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
@@ -81,12 +67,12 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0.15'
83
69
  - !ruby/object:Gem::Dependency
70
+ name: kaminari
84
71
  requirement: !ruby/object:Gem::Requirement
85
72
  requirements:
86
73
  - - "~>"
87
74
  - !ruby/object:Gem::Version
88
75
  version: '0.17'
89
- name: kaminari
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
@@ -95,12 +81,12 @@ dependencies:
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0.17'
97
83
  - !ruby/object:Gem::Dependency
84
+ name: bundler
98
85
  requirement: !ruby/object:Gem::Requirement
99
86
  requirements:
100
87
  - - ">="
101
88
  - !ruby/object:Gem::Version
102
89
  version: '0'
103
- name: bundler
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
@@ -109,12 +95,12 @@ dependencies:
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
111
97
  - !ruby/object:Gem::Dependency
98
+ name: rake
112
99
  requirement: !ruby/object:Gem::Requirement
113
100
  requirements:
114
101
  - - "~>"
115
102
  - !ruby/object:Gem::Version
116
103
  version: '10.0'
117
- name: rake
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
@@ -123,26 +109,12 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: '10.0'
125
111
  - !ruby/object:Gem::Dependency
126
- requirement: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: '4.1'
131
- name: activemodel
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '4.1'
139
- - !ruby/object:Gem::Dependency
112
+ name: graphiti_spec_helpers
140
113
  requirement: !ruby/object:Gem::Requirement
141
114
  requirements:
142
115
  - - '='
143
116
  - !ruby/object:Gem::Version
144
117
  version: 1.0.beta.4
145
- name: graphiti_spec_helpers
146
118
  type: :development
147
119
  prerelease: false
148
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -151,12 +123,12 @@ dependencies:
151
123
  - !ruby/object:Gem::Version
152
124
  version: 1.0.beta.4
153
125
  - !ruby/object:Gem::Dependency
126
+ name: standard
154
127
  requirement: !ruby/object:Gem::Requirement
155
128
  requirements:
156
129
  - - ">="
157
130
  - !ruby/object:Gem::Version
158
131
  version: '0'
159
- name: standard
160
132
  type: :development
161
133
  prerelease: false
162
134
  version_requirements: !ruby/object:Gem::Requirement
@@ -165,12 +137,12 @@ dependencies:
165
137
  - !ruby/object:Gem::Version
166
138
  version: '0'
167
139
  - !ruby/object:Gem::Dependency
140
+ name: rspec
168
141
  requirement: !ruby/object:Gem::Requirement
169
142
  requirements:
170
143
  - - "~>"
171
144
  - !ruby/object:Gem::Version
172
145
  version: 3.9.0
173
- name: rspec
174
146
  type: :development
175
147
  prerelease: false
176
148
  version_requirements: !ruby/object:Gem::Requirement
@@ -178,16 +150,16 @@ dependencies:
178
150
  - - "~>"
179
151
  - !ruby/object:Gem::Version
180
152
  version: 3.9.0
181
- description:
153
+ description:
182
154
  email:
183
155
  - hardikjoshi1991@gmail.com
184
156
  executables: []
185
157
  extensions: []
186
158
  extra_rdoc_files: []
187
159
  files:
160
+ - ".github/workflows/specs.yml"
188
161
  - ".gitignore"
189
162
  - ".rspec"
190
- - ".travis.yml"
191
163
  - CHANGELOG.md
192
164
  - Gemfile
193
165
  - LICENSE.txt
@@ -199,6 +171,7 @@ files:
199
171
  - lib/graphiti/active_graph/adapters/active_graph/polymorphic_belongs_to.rb
200
172
  - lib/graphiti/active_graph/adapters/active_graph/sideload.rb
201
173
  - lib/graphiti/active_graph/deserializer.rb
174
+ - lib/graphiti/active_graph/jsonapi_ext/serializable/resource_ext.rb
202
175
  - lib/graphiti/active_graph/query.rb
203
176
  - lib/graphiti/active_graph/resource.rb
204
177
  - lib/graphiti/active_graph/resource/persistence.rb
@@ -215,23 +188,23 @@ homepage: https://github.com/mrhardikjoshi/graphiti-activegraph
215
188
  licenses:
216
189
  - MIT
217
190
  metadata: {}
218
- post_install_message:
191
+ post_install_message:
219
192
  rdoc_options: []
220
193
  require_paths:
221
194
  - lib
222
195
  required_ruby_version: !ruby/object:Gem::Requirement
223
196
  requirements:
224
- - - "~>"
197
+ - - ">="
225
198
  - !ruby/object:Gem::Version
226
- version: '2.3'
199
+ version: '0'
227
200
  required_rubygems_version: !ruby/object:Gem::Requirement
228
201
  requirements:
229
202
  - - ">="
230
203
  - !ruby/object:Gem::Version
231
204
  version: '0'
232
205
  requirements: []
233
- rubygems_version: 3.0.6
234
- signing_key:
206
+ rubygems_version: 3.0.3.1
207
+ signing_key:
235
208
  specification_version: 4
236
209
  summary: Easily build jsonapi.org-compatible APIs for GraphDB
237
210
  test_files: []
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- ---
2
- dist: xenial
3
- language: ruby
4
- jdk:
5
- - openjdk11
6
- cache: bundler
7
- rvm:
8
- - 2.7.1
9
- - jruby-9.2.16.0
10
- - jruby-9.3.2.0
11
- script: 'bundle exec rspec'