graphiti 2.0.0.beta.1 → 2.0.0.beta.2
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 +4 -4
- data/.ruby-version +1 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +16 -0
- data/lib/graphiti/errors.rb +13 -0
- data/lib/graphiti/resource/interface.rb +20 -0
- data/lib/graphiti/resource_proxy.rb +6 -0
- data/lib/graphiti/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4df03897f8a42130dd72eef307de014c5b3f3511986410d21b1379d8fe4fe3b8
|
|
4
|
+
data.tar.gz: eced17fbba2045d85aa89d41bc70ef27b212d311a8325ec5ae7bc5f93747c5cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f6932861330cf82c379d34c7c2611ec0e9fd83e914d230460676779981f7b19d4f9255debae2baf6f85fe9bd2e9b31a09121ab5de8e5f77d6c6c1609577aef4
|
|
7
|
+
data.tar.gz: fc457d4ba75e216f9cff808dc1907cbf247d0bd614a4ffa2ff13aca4587129a8a5e11661c89e0b587ef4301bd6222d91d8f9da17c984411efe9aa1ddfa24f6b8
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.3
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 3.3.4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
graphiti changelog
|
|
2
2
|
|
|
3
|
+
# [2.0.0-beta.2](https://github.com/graphiti-api/graphiti/compare/v2.0.0-beta.1...v2.0.0-beta.2) (2026-07-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add Resource.wrap as an easy way to use graphiti serialization on models fetched via other means (and not via graphiti's finders) ([#513](https://github.com/graphiti-api/graphiti/issues/513)) ([fcd19e2](https://github.com/graphiti-api/graphiti/commit/fcd19e2d023091d85947dbdd89259b587e0f582b))
|
|
9
|
+
* deprecate mutating attributes in around_persistence hooks ([#514](https://github.com/graphiti-api/graphiti/issues/514)) [skip ci] ([8410ab0](https://github.com/graphiti-api/graphiti/commit/8410ab0a916077601cf85d8260a05ef9098149eb))
|
|
10
|
+
|
|
3
11
|
# [2.0.0-beta.1](https://github.com/graphiti-api/graphiti/compare/v1.12.2...v2.0.0-beta.1) (2026-07-30)
|
|
4
12
|
|
|
5
13
|
|
|
@@ -14,6 +22,14 @@ graphiti changelog
|
|
|
14
22
|
* around_persistence hooks receive the assigned model instead of the attributes hash. Move attribute-hash modifications to before_attributes, or set values on the model. Custom create/update overrides that should receive a pre-assigned model must accept an assigned_model: keyword. See UPGRADING.md
|
|
15
23
|
* Ruby >= 3.0 / Rails >= 6 are now required.
|
|
16
24
|
|
|
25
|
+
# [1.13.0](https://github.com/graphiti-api/graphiti/compare/v1.12.2...v1.13.0) (2026-07-30)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* add Resource.wrap as an easy way to use graphiti serialization on models fetched via other means (and not via graphiti's finders) ([#513](https://github.com/graphiti-api/graphiti/issues/513)) ([fcd19e2](https://github.com/graphiti-api/graphiti/commit/fcd19e2d023091d85947dbdd89259b587e0f582b))
|
|
31
|
+
* deprecate mutating attributes in around_persistence hooks ([#514](https://github.com/graphiti-api/graphiti/issues/514)) [skip ci] ([8410ab0](https://github.com/graphiti-api/graphiti/commit/8410ab0a916077601cf85d8260a05ef9098149eb))
|
|
32
|
+
|
|
17
33
|
## [1.12.2](https://github.com/graphiti-api/graphiti/compare/v1.12.1...v1.12.2) (2026-07-29)
|
|
18
34
|
|
|
19
35
|
|
data/lib/graphiti/errors.rb
CHANGED
|
@@ -486,6 +486,19 @@ module Graphiti
|
|
|
486
486
|
end
|
|
487
487
|
end
|
|
488
488
|
|
|
489
|
+
class InvalidWrapModel < Base
|
|
490
|
+
def initialize(resource_class, model)
|
|
491
|
+
@resource_class = resource_class
|
|
492
|
+
@model = model
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def message
|
|
496
|
+
<<~MSG
|
|
497
|
+
#{@resource_class.name}.wrap was given a #{@model.class}, but this resource is for #{@resource_class.model} (subclasses are fine).
|
|
498
|
+
MSG
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
|
|
489
502
|
class ResourceEndpointConflict < Base
|
|
490
503
|
def initialize(path, action, resource_a, resource_b)
|
|
491
504
|
@path = path
|
|
@@ -53,8 +53,28 @@ module Graphiti
|
|
|
53
53
|
runner.proxy(base_scope, single: true, raise_on_missing: true, assign_action: :create)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
+
# Wrap models fetched outside graphiti so they render like any other proxy
|
|
57
|
+
def wrap(models, base_scope = nil)
|
|
58
|
+
validate_wrap_models!(models)
|
|
59
|
+
runner = Runner.new(self, {}, nil, :find)
|
|
60
|
+
runner.proxy(base_scope, bypass_required_filters: true).tap do |proxy|
|
|
61
|
+
proxy.data = models
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
56
65
|
private
|
|
57
66
|
|
|
67
|
+
# Skip polymorphic parents - resource_for_model raises a better error for unknown children
|
|
68
|
+
def validate_wrap_models!(models)
|
|
69
|
+
return if abstract_class? || (polymorphic? && !polymorphic_child?)
|
|
70
|
+
|
|
71
|
+
[models].flatten.compact.each do |model|
|
|
72
|
+
unless model.is_a?(self.model)
|
|
73
|
+
raise Errors::InvalidWrapModel.new(self, model)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
58
78
|
def caching_options
|
|
59
79
|
{cache: @cache_resource, cache_expires_in: @cache_expires_in, cache_tag: @cache_tag}
|
|
60
80
|
end
|
|
@@ -82,6 +82,12 @@ module Graphiti
|
|
|
82
82
|
Renderer.new(self, options).as_graphql
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
+
# Records supplied directly, no scope resolution
|
|
86
|
+
def data=(models)
|
|
87
|
+
@data = models
|
|
88
|
+
[@data].flatten.compact.each { |record| @resource.decorate_record(record) }
|
|
89
|
+
end
|
|
90
|
+
|
|
85
91
|
def data
|
|
86
92
|
return @data unless @data.nil?
|
|
87
93
|
return assign_attributes(@payload.params) if @assign_action
|
data/lib/graphiti/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: graphiti
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.beta.
|
|
4
|
+
version: 2.0.0.beta.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lee Richmond
|
|
@@ -237,7 +237,9 @@ files:
|
|
|
237
237
|
- ".github/workflows/release.yml"
|
|
238
238
|
- ".gitignore"
|
|
239
239
|
- ".rspec"
|
|
240
|
+
- ".ruby-version"
|
|
240
241
|
- ".standard.yml"
|
|
242
|
+
- ".tool-versions"
|
|
241
243
|
- ".yardopts"
|
|
242
244
|
- Appraisals
|
|
243
245
|
- CHANGELOG.md
|