graphiti 1.7.0 → 1.7.2

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: 48e9df9f78bfe2d9b9303f304541894222fa4eb3d925f2ac68a01e3b0567fbb4
4
- data.tar.gz: d8d010bca5894bc11cc0bfb76f9d88deaf6d95d7b413d937765b58d87fefe1cc
3
+ metadata.gz: 0ef6f59bab6be83f8be9f2dd2f2350d49abac04ad0ca7338bb1d52aa88cec27d
4
+ data.tar.gz: 2c904533a08f64faa13b5aed12467da757c87ed842ba8680ecf86052ddd37e86
5
5
  SHA512:
6
- metadata.gz: 56ec9608ea8de6b8a8be491e27a8dc0ef83b297a3178e617495d8a63098d8df2d408b944e4f314eacd98e8e87e278e01fa287b68e07961228086ffb21259d509
7
- data.tar.gz: f2077122a2b0a4996a0326f21fcae529724dd6438303f42822eb73605b58801c1c8466d012d8f3edf5899cb82ed234373fcc989f4630b012d7e045c32e40894d
6
+ metadata.gz: f30b06bb304bef743ce7926df28187f8772b5c803e8407c7cacaa810cff9ac9880046efa8c73f3d2e911a9088f04ca613fd32e7a1e1c3f41ae755b68cc25a4f3
7
+ data.tar.gz: 13b6980e5be70675eabed5cf9d799a02281072abf93e35cc8a0266d58adf1d029d7e114394ba973a1e5531ab66d7f091ecaa97005dd001cb320ca1e3961d9146
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  graphiti changelog
2
2
 
3
+ ## [1.7.2](https://github.com/graphiti-api/graphiti/compare/v1.7.1...v1.7.2) (2024-06-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * require necessary ActiveSupport parts in proper order ([bb2a488](https://github.com/graphiti-api/graphiti/commit/bb2a48874a6533522df6eb027d0df8ec14c80a20))
9
+
10
+ ## [1.7.1](https://github.com/graphiti-api/graphiti/compare/v1.7.0...v1.7.1) (2024-04-18)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * properly display .find vs .all in debugger statements ([d2a7a03](https://github.com/graphiti-api/graphiti/commit/d2a7a038a649818979d52ccd898e68dba78b051f))
16
+ * rescue error from sideloads updated_at calculation, defaulting to the current time ([661e3b5](https://github.com/graphiti-api/graphiti/commit/661e3b5212e2649870a200067d0d5d52fa962637))
17
+
3
18
  # [1.7.0](https://github.com/graphiti-api/graphiti/compare/v1.6.4...v1.7.0) (2024-03-27)
4
19
 
5
20
 
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
- ![Build Status](https://travis-ci.org/graphiti-api/graphiti.svg?branch=master)
1
+ [![CI](https://github.com/graphiti-api/graphiti/actions/workflows/ci.yml/badge.svg)](https://github.com/graphiti-api/graphiti/actions/workflows/ci.yml)
2
2
  [![Gem Version](https://badge.fury.io/rb/graphiti.svg)](https://badge.fury.io/rb/graphiti)
3
3
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
4
+ [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
4
5
 
5
6
  <p align="center">
6
7
  <a href="https://www.graphiti.dev/guides">
@@ -36,7 +36,7 @@ module Graphiti
36
36
  json[:sideload] = sideload.name
37
37
  end
38
38
  if params
39
- query = "#{payload[:resource].class.name}.all(#{JSON.pretty_generate(params)}).data"
39
+ query = "#{payload[:resource].class.name}.#{payload[:action]}(#{JSON.pretty_generate(params)}).data"
40
40
  logs << [query, :cyan, true]
41
41
  logs << ["The error occurred when running the above query. Copy/paste it into a rake task or Rails console session to reproduce. Keep in mind you may have to set context.", :yellow, true]
42
42
  else
@@ -64,7 +64,7 @@ module Graphiti
64
64
  query = if sideload.class.scope_proc
65
65
  "#{payload[:resource].class.name}: Manual sideload via .scope"
66
66
  else
67
- "#{payload[:resource].class.name}.all(#{params.inspect})"
67
+ "#{payload[:resource].class.name}.#{payload[:action]}(#{params.inspect})"
68
68
  end
69
69
  logs << [" #{query}", :cyan, true]
70
70
  json[:query] = query
@@ -82,7 +82,7 @@ module Graphiti
82
82
  title = "Top Level Data Retrieval (+ sideloads):"
83
83
  logs << [title, :green, true]
84
84
  json[:title] = title
85
- query = "#{payload[:resource].class.name}.all(#{params.inspect})"
85
+ query = "#{payload[:resource].class.name}.#{payload[:action]}(#{params.inspect})"
86
86
  logs << [query, :cyan, true]
87
87
  json[:query] = query
88
88
  logs << ["Returned Models: #{results}"] if debug_models
@@ -92,16 +92,17 @@ module Graphiti
92
92
  end
93
93
 
94
94
  def updated_at
95
- updated_ats = sideload_resource_proxies.map(&:updated_at)
96
-
95
+ updated_time = nil
97
96
  begin
97
+ updated_ats = sideload_resource_proxies.map(&:updated_at)
98
98
  updated_ats << @object.maximum(:updated_at)
99
+ updated_time = updated_ats.compact.max
99
100
  rescue => e
100
- Graphiti.log("error calculating last_modified_at for #{@resource.class}")
101
+ Graphiti.log(["error calculating last_modified_at for #{@resource.class}", :red])
101
102
  Graphiti.log(e)
102
103
  end
103
104
 
104
- updated_ats.compact.max
105
+ updated_time || Time.now
105
106
  end
106
107
  alias_method :last_modified_at, :updated_at
107
108
 
@@ -128,9 +129,10 @@ module Graphiti
128
129
  def broadcast_data
129
130
  opts = {
130
131
  resource: @resource,
131
- params: @opts[:params],
132
+ params: @opts[:params] || @query.params,
132
133
  sideload: @opts[:sideload],
133
- parent: @opts[:parent]
134
+ parent: @opts[:parent],
135
+ action: @query.action
134
136
  # Set once data is resolved within block
135
137
  # results: ...
136
138
  }
@@ -12,7 +12,7 @@ module Graphiti
12
12
  end
13
13
 
14
14
  def name
15
- "#{Graphiti.context[:object].request.method} #{Graphiti.context[:object].request.url}"
15
+ "#{Graphiti.context[:object]&.request&.method} #{Graphiti.context[:object]&.request&.url}"
16
16
  end
17
17
 
18
18
  def key
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.2"
3
3
  end
data/lib/graphiti.rb CHANGED
@@ -1,13 +1,16 @@
1
1
  require "json"
2
2
  require "forwardable"
3
3
  require "uri"
4
+
5
+ require "active_support/version"
6
+ require "active_support/deprecation"
7
+ require "active_support/deprecator" if ::ActiveSupport.version >= Gem::Version.new("7.1")
4
8
  require "active_support/core_ext/string"
5
9
  require "active_support/core_ext/enumerable"
6
10
  require "active_support/core_ext/class/attribute"
7
11
  require "active_support/core_ext/hash/conversions" # to_xml
8
12
  require "active_support/concern"
9
13
  require "active_support/time"
10
- require "active_support/deprecation"
11
14
 
12
15
  require "dry-types"
13
16
  require "graphiti_errors"
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.7.0
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-27 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable
@@ -361,7 +361,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
361
  - !ruby/object:Gem::Version
362
362
  version: '0'
363
363
  requirements: []
364
- rubygems_version: 3.3.26
364
+ rubygems_version: 3.3.27
365
365
  signing_key:
366
366
  specification_version: 4
367
367
  summary: Easily build jsonapi.org-compatible APIs