graphiti 1.3.9 → 1.5.0

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: 30f5b9382256603c1f3f8f4ab8c4e614804c1a2e2152617d7b19892bca6bd465
4
- data.tar.gz: 948837bfa0f8deee2f44849aba9df2bb18f2fdf532a1caaab92b16c7d9ba91fd
3
+ metadata.gz: 4ac18e95dbeb97600ec5027bf94e58724e652f5c77dd0d83f122651a04b9676f
4
+ data.tar.gz: 4691d5f4f4e037e6d2d5100e84789ea53b6084d884e22bdf1f55b6a3a0e7981d
5
5
  SHA512:
6
- metadata.gz: 4fe6fff9c219fd463378bbdc793f648cbeffe27c61c191f11e2aab4723e952d2d8f7cc26b334255e12adca3e9d819b1bbde17697a6621f11a28151d2649d6d9c
7
- data.tar.gz: becca9eaa17f328a99669e1e855a4024862b45d1902ddf30de597f7b33e3f52e4145b0f1dba1542a0d144ba2bc1bdec280ad9d8fa599a102ead9efb5260e1ab3
6
+ metadata.gz: 36401cebf8a89402bdbafccf234a98d988df2f642ff00d4ee51030857ce98b008f91d3ca80b7f05e64a2a3ab79f872c225c1d79cf3d1c531e9ff61e74b4f7280
7
+ data.tar.gz: 73601e0ee6d54235a54c4db54baab90313e735ae81806520354a8f75890de6ec7fb3025952ed972f15fe493230a97a50a2e41e82b7f957739b21177355743479
@@ -0,0 +1,2 @@
1
+ enabled:
2
+ - cla
@@ -28,10 +28,11 @@ jobs:
28
28
  fail-fast: false
29
29
  matrix:
30
30
  ruby:
31
- - "2.6"
32
31
  - "2.7"
33
32
  - "3.0"
34
33
  - "3.1"
34
+ - "3.2"
35
+ - "3.3"
35
36
  gemfile:
36
37
  - Gemfile
37
38
  - gemfiles/rails_5_2.gemfile
@@ -40,12 +41,13 @@ jobs:
40
41
  - gemfiles/rails_5_2_graphiti_rails.gemfile
41
42
  - gemfiles/rails_6_graphiti_rails.gemfile
42
43
  - gemfiles/rails_7_graphiti_rails.gemfile
44
+ - gemfiles/rails_7_1_graphiti_rails.gemfile
43
45
  appraisal:
44
46
  - true
45
47
  - false
46
48
  include:
47
49
  - ruby: ruby-head
48
- gemfile: Gemfile
50
+ gemfile: gemfiles/rails_7_1.gemfile
49
51
  appraisal: true
50
52
  - ruby: ruby-head
51
53
  gemfile: Gemfile
@@ -66,7 +68,9 @@ jobs:
66
68
  appraisal: false
67
69
  - gemfile: gemfiles/rails_7_graphiti_rails.gemfile
68
70
  appraisal: false
69
- # Rails 5 can't run on Ruby 3
71
+ - gemfile: gemfiles/rails_7_1_graphiti_rails.gemfile
72
+ appraisal: false
73
+ # Rails 5 can't run on Ruby 3
70
74
  - gemfile: gemfiles/rails_5_2.gemfile
71
75
  ruby: 3.0
72
76
  - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
@@ -75,11 +79,14 @@ jobs:
75
79
  ruby: 3.1
76
80
  - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
77
81
  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
82
+ - gemfile: gemfiles/rails_5_2.gemfile
83
+ ruby: 3.2
84
+ - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
85
+ ruby: 3.2
86
+ - gemfile: gemfiles/rails_5_2.gemfile
87
+ ruby: 3.3
88
+ - gemfile: gemfiles/rails_5_2_graphiti_rails.gemfile
89
+ ruby: 3.3
83
90
  continue-on-error: ${{ matrix.ruby == 'ruby-head' }}
84
91
  env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
85
92
  BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
@@ -94,3 +101,14 @@ jobs:
94
101
  bundler-cache: true
95
102
  - name: Run tests
96
103
  run: bundle exec rspec
104
+ publish:
105
+ name: Release
106
+ runs-on: ubuntu-latest
107
+ if: github.ref == 'refs/heads/master'
108
+ needs: [test]
109
+ steps:
110
+ - name: Dispatch Release
111
+ uses: benc-uk/workflow-dispatch@v1
112
+ with:
113
+ workflow: Generate New Release
114
+ token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: Generate New Release
3
+
4
+ on:
5
+ workflow_dispatch:
6
+
7
+ jobs:
8
+ release:
9
+ name: Release
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout
13
+ uses: actions/checkout@v3
14
+ with:
15
+ submodules: true
16
+ persist-credentials: false
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: "3.1"
21
+ - name: Build
22
+ run: |
23
+ gem install bundler
24
+ git submodule update --init --recursive
25
+ bundle install --jobs 4 --retry 3
26
+ - name: Setup Node.js
27
+ uses: actions/setup-node@v2
28
+ with:
29
+ node-version: 14
30
+ - name: Install Dependencies
31
+ run: yarn install --frozen-lockfile
32
+ - name: Release
33
+ env:
34
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35
+ GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
36
+ run: node_modules/.bin/semantic-release
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /spec/reports/
8
8
  /gemfiles/*.lock
9
9
  /tmp/
10
+ node_modules
10
11
  .byebug_history
11
12
  spec/.rspec-examples
12
13
  spec/dummy/log/*
data/Appraisals CHANGED
@@ -42,3 +42,18 @@ appraise "rails-7-graphiti-rails" do
42
42
  gem "database_cleaner"
43
43
  gem "graphiti-rails", "~> 0.4.0"
44
44
  end
45
+
46
+ appraise "rails-7-1" do
47
+ gem "rails", "~> 7.1"
48
+ gem "rspec-rails"
49
+ gem "sqlite3", "~> 1.4.0"
50
+ gem "database_cleaner"
51
+ end
52
+
53
+ appraise "rails-7-1-graphiti-rails" do
54
+ gem "rails", "~> 7.1"
55
+ gem "rspec-rails"
56
+ gem "sqlite3", "~> 1.4.0"
57
+ gem "database_cleaner"
58
+ gem "graphiti-rails", "~> 0.4.0"
59
+ end
data/CHANGELOG.md CHANGED
@@ -1,4 +1,27 @@
1
- ## Unreleased
1
+ graphiti changelog
2
+
3
+ # [1.5.0](https://github.com/graphiti-api/graphiti/compare/v1.4.0...v1.5.0) (2024-03-18)
4
+
5
+
6
+ ### Features
7
+
8
+ * add before_sideload hook ([#371](https://github.com/graphiti-api/graphiti/issues/371)) ([f68b61f](https://github.com/graphiti-api/graphiti/commit/f68b61ff09ec61ecf23acc5bc37d0accba14aeed))
9
+
10
+ ## 1.4.0, Sun March 17th 2024
11
+ Features:
12
+ - [461](https://github.com/graphiti-api/graphiti/pull/461), [463](https://github.com/graphiti-api/graphiti/pull/463) Add support for Rails 7.1 + Ruby 3.2 + Ruby 3.3
13
+
14
+ Fixes:
15
+ - [464](https://github.com/graphiti-api/graphiti/pull/464) Check for url presence before trying to append
16
+ - [407](https://github.com/graphiti-api/graphiti/pull/407) Sort types in generated schema
17
+ - [421](https://github.com/graphiti-api/graphiti/pull/421) Re-use resource class for remote sideloads to avoid memory leak
18
+ - [452](https://github.com/graphiti-api/graphiti/pull/452) Resolve inconsistency for filters containing curly brackets
19
+ - [446](https://github.com/graphiti-api/graphiti/pull/446) Fix private call
20
+
21
+ ## 1.3.9, May 25th 2022
22
+ Use an options hash for log subscriber instead of positional arguments
23
+
24
+ ## 1.x ??
2
25
 
3
26
  Features:
4
27
  - [329](https://github.com/graphiti-api/graphiti/pull/329) Propagate `extra_fields` to related resource links.
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :test do
7
+ gem "database_cleaner"
7
8
  gem "pry"
8
9
  gem "pry-byebug", platform: [:mri]
9
10
  gem "appraisal"
@@ -0,0 +1,18 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 7.1"
6
+ gem "rspec-rails"
7
+ gem "sqlite3", "~> 1.4.0"
8
+ gem "database_cleaner"
9
+
10
+ group :test do
11
+ gem "pry"
12
+ gem "pry-byebug", platform: [:mri]
13
+ gem "appraisal"
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+ end
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,19 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 7.1"
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: "../"
@@ -15,6 +15,7 @@ module Graphiti
15
15
  attr_accessor :pagination_links
16
16
  attr_accessor :typecast_reads
17
17
  attr_accessor :raise_on_missing_sidepost
18
+ attr_accessor :before_sideload
18
19
 
19
20
  attr_reader :debug, :debug_models
20
21
 
@@ -140,7 +140,6 @@ module Graphiti
140
140
  params ||= {}
141
141
  params = params.to_unsafe_h if params.respond_to?(:to_unsafe_h)
142
142
  params.reject! { |k, v| [:controller, :action, :format, :debug].include?(k.to_sym) }
143
- params.reject! { |k, v| k.to_sym == :include }
144
143
  params.deep_symbolize_keys
145
144
  end
146
145
 
@@ -76,11 +76,14 @@ module Graphiti
76
76
  end
77
77
  end
78
78
 
79
+ class RemoteSideloadResource < ::Graphiti::Resource
80
+ self.remote = "_remote_sideload_".freeze
81
+ self.abstract_class = true # exclude from schema
82
+ end
83
+
79
84
  def resource_for_sideload(sideload)
80
85
  if @resource.remote?
81
- Class.new(Graphiti::Resource) {
82
- self.remote = "_remote_sideload_"
83
- }.new
86
+ RemoteSideloadResource.new
84
87
  else
85
88
  sideload.resource
86
89
  end
@@ -205,7 +205,7 @@ module Graphiti
205
205
  options[name] ||= send(:"relationships_#{name}_by_default")
206
206
  end
207
207
  end
208
- private :attribute_option
208
+ private :relationship_option
209
209
  end
210
210
  end
211
211
  end
@@ -68,7 +68,7 @@ module Graphiti
68
68
  model_ref = model
69
69
  has_many name, opts do
70
70
  params do |hash|
71
- hash[:filter][:"#{as}_type"] = { eql: model_ref.name }
71
+ hash[:filter][:"#{as}_type"] = {eql: model_ref.name}
72
72
  end
73
73
 
74
74
  instance_eval(&blk) if blk
@@ -82,7 +82,7 @@ module Graphiti
82
82
  model_ref = model
83
83
  has_one name, opts do
84
84
  params do |hash|
85
- hash[:filter][:"#{as}_type"] = { eql: model_ref.name }
85
+ hash[:filter][:"#{as}_type"] = {eql: model_ref.name}
86
86
  end
87
87
 
88
88
  instance_eval(&blk) if blk
@@ -153,11 +153,13 @@ module Graphiti
153
153
  success
154
154
  end
155
155
 
156
- def update_attributes
156
+ def update
157
157
  data
158
158
  save(action: :update)
159
159
  end
160
160
 
161
+ alias update_attributes update # standard:disable Style/Alias
162
+
161
163
  def include_hash
162
164
  @include_hash ||= begin
163
165
  base = @payload ? @payload.include_hash : {}
@@ -42,7 +42,7 @@ module Graphiti
42
42
 
43
43
  def generate_types
44
44
  {}.tap do |types|
45
- Graphiti::Types.map.each_pair do |name, config|
45
+ Graphiti::Types.map.sort.each_entry do |name, config|
46
46
  types[name] = config.slice(:kind, :description)
47
47
  end
48
48
  end
@@ -43,6 +43,7 @@ module Graphiti
43
43
  parent_resource = @resource
44
44
  graphiti_context = Graphiti.context
45
45
  resolve_sideload = -> {
46
+ Graphiti.config.before_sideload&.call(graphiti_context)
46
47
  Graphiti.context = graphiti_context
47
48
  sideload.resolve(results, q, parent_resource)
48
49
  @resource.adapter.close if concurrent
@@ -193,14 +193,14 @@ module Graphiti
193
193
  # Find the quoted strings
194
194
  quotes = value.scan(/{{.*?}}/)
195
195
  # remove them from the rest
196
- quotes.each { |q| value.gsub!(q, "") }
196
+ non_quotes = quotes.inject(value) { |v, q| v.gsub(q, "") }
197
197
  # remove the quote characters from the quoted strings
198
198
  quotes.each { |q| q.gsub!("{{", "").gsub!("}}", "") }
199
199
  # merge everything back together into an array
200
200
  value = if singular_filter
201
- Array(value) + quotes
201
+ Array(non_quotes) + quotes
202
202
  else
203
- Array(value.split(",")) + quotes
203
+ Array(non_quotes.split(",")) + quotes
204
204
  end
205
205
  # remove any blanks that are left
206
206
  value.reject! { |v| v.length.zero? }
@@ -48,6 +48,7 @@ module Graphiti
48
48
 
49
49
  def on_demand_links(url)
50
50
  return url unless Graphiti.config.links_on_demand
51
+ return unless url
51
52
 
52
53
  url << if url.include?("?")
53
54
  "&links=true"
@@ -118,7 +118,7 @@ module Graphiti
118
118
  cache_key = :"#{@sideload.object_id}-#{action}"
119
119
  return if self.class.validated_link_cache.include?(cache_key)
120
120
  prc = Graphiti.config.context_for_endpoint
121
- unless prc.call(sideload.resource.endpoint[:full_path], action)
121
+ unless prc.call(sideload.resource.endpoint[:full_path].to_s, action)
122
122
  raise Errors::InvalidLink.new(@resource_class, sideload, action)
123
123
  end
124
124
  self.class.validated_link_cache << cache_key
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.3.9"
2
+ VERSION = "1.5.0"
3
3
  end
data/lib/graphiti.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "json"
2
2
  require "forwardable"
3
+ require "uri"
3
4
  require "active_support/core_ext/string"
4
5
  require "active_support/core_ext/enumerable"
5
6
  require "active_support/core_ext/class/attribute"
@@ -83,7 +84,12 @@ module Graphiti
83
84
  end
84
85
 
85
86
  def self.log(msg, color = :white, bold = false)
86
- colored = ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold)
87
+ colored = if ::ActiveSupport.version >= Gem::Version.new("7.1")
88
+ ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold: bold)
89
+ else
90
+ ActiveSupport::LogSubscriber.new.send(:color, msg, color, bold)
91
+ end
92
+
87
93
  logger.debug(colored)
88
94
  end
89
95
 
@@ -131,7 +137,6 @@ require "graphiti/resource_proxy"
131
137
  require "graphiti/request_validator"
132
138
  require "graphiti/request_validators/validator"
133
139
  require "graphiti/request_validators/update_validator"
134
- require "graphiti/query"
135
140
  require "graphiti/scope"
136
141
  require "graphiti/deserializer"
137
142
  require "graphiti/renderer"
@@ -170,6 +175,7 @@ require "graphiti/extensions/extra_attribute"
170
175
  require "graphiti/extensions/boolean_attribute"
171
176
  require "graphiti/extensions/temp_id"
172
177
  require "graphiti/serializer"
178
+ require "graphiti/query"
173
179
  require "graphiti/debugger"
174
180
 
175
181
  if defined?(ActiveRecord)
data/package.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "name": "graphiti",
3
+ "version": "1.4.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/graphiti-api/graphiti.git"
7
+ },
8
+ "license": "MIT",
9
+ "bugs": {
10
+ "url": "https://github.com/graphiti-api/graphiti/issues"
11
+ },
12
+ "homepage": "https://graphiti.dev",
13
+ "scripts": {
14
+ "semantic-release": "semantic-release"
15
+ },
16
+ "devDependencies": {
17
+ "semantic-release-rubygem": "^1.2.0",
18
+ "semantic-release": "^19.0.3",
19
+ "@semantic-release/changelog": "^6.0.1",
20
+ "@semantic-release/git": "^10.0.1"
21
+ },
22
+ "release": {
23
+ "branches": [
24
+ "master",
25
+ {
26
+ "name": "beta",
27
+ "prerelease": true
28
+ },
29
+ {
30
+ "name": "alpha",
31
+ "prerelease": true
32
+ }
33
+ ],
34
+ "plugins": [
35
+ [
36
+ "@semantic-release/commit-analyzer",
37
+ {
38
+ "releaseRules": [
39
+ {
40
+ "type": "*!",
41
+ "release": "major"
42
+ },
43
+ {
44
+ "type": "feat",
45
+ "release": "minor"
46
+ },
47
+ {
48
+ "type": "build",
49
+ "release": "patch"
50
+ },
51
+ {
52
+ "type": "ci",
53
+ "release": "patch"
54
+ },
55
+ {
56
+ "type": "chore",
57
+ "release": "patch"
58
+ },
59
+ {
60
+ "type": "docs",
61
+ "release": "patch"
62
+ },
63
+ {
64
+ "type": "refactor",
65
+ "release": "patch"
66
+ },
67
+ {
68
+ "type": "style",
69
+ "release": "patch"
70
+ },
71
+ {
72
+ "type": "test",
73
+ "release": "patch"
74
+ }
75
+ ],
76
+ "parserOpts": {
77
+ "noteKeywords": [
78
+ "BREAKING CHANGE",
79
+ "BREAKING CHANGES",
80
+ "BREAKING",
81
+ "BREAKING CHANGE!",
82
+ "BREAKING CHANGES!",
83
+ "BREAKING!"
84
+ ]
85
+ }
86
+ }
87
+ ],
88
+ "@semantic-release/release-notes-generator",
89
+ [
90
+ "@semantic-release/changelog",
91
+ {
92
+ "changelogTitle": "graphiti changelog",
93
+ "changelogFile": "CHANGELOG.md"
94
+ }
95
+ ],
96
+ "@semantic-release/github",
97
+ [
98
+ "@semantic-release/git",
99
+ {
100
+ "assets": [
101
+ "CHANGELOG.md"
102
+ ],
103
+ "message": "${nextRelease.version} CHANGELOG [skip ci]\n\n${nextRelease.notes}"
104
+ }
105
+ ]
106
+ ],
107
+ "debug": true,
108
+ "dryRun": false
109
+ }
110
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.9
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-25 00:00:00.000000000 Z
11
+ date: 2024-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable
@@ -212,7 +212,9 @@ executables:
212
212
  extensions: []
213
213
  extra_rdoc_files: []
214
214
  files:
215
+ - ".github/probots.yml"
215
216
  - ".github/workflows/ci.yml"
217
+ - ".github/workflows/release.yml"
216
218
  - ".gitignore"
217
219
  - ".rspec"
218
220
  - ".standard.yml"
@@ -251,6 +253,8 @@ files:
251
253
  - gemfiles/rails_6.gemfile
252
254
  - gemfiles/rails_6_graphiti_rails.gemfile
253
255
  - gemfiles/rails_7.gemfile
256
+ - gemfiles/rails_7_1.gemfile
257
+ - gemfiles/rails_7_1_graphiti_rails.gemfile
254
258
  - gemfiles/rails_7_graphiti_rails.gemfile
255
259
  - graphiti.gemspec
256
260
  - lib/graphiti.rb
@@ -336,6 +340,7 @@ files:
336
340
  - lib/graphiti/util/transaction_hooks_recorder.rb
337
341
  - lib/graphiti/util/validation_response.rb
338
342
  - lib/graphiti/version.rb
343
+ - package.json
339
344
  homepage: https://github.com/graphiti-api/graphiti
340
345
  licenses:
341
346
  - MIT