graphiti 1.0.rc.1 → 1.0.rc.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/.travis.yml +14 -9
- data/README.md +10 -2
- data/lib/graphiti/configuration.rb +6 -2
- data/lib/graphiti/filter_operators.rb +2 -2
- data/lib/graphiti/resource/persistence.rb +28 -16
- data/lib/graphiti/schema.rb +1 -0
- data/lib/graphiti/util/serializer_attributes.rb +1 -1
- data/lib/graphiti/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26fc322fc29632b3e24f85bcbe535a3542c0d142
|
4
|
+
data.tar.gz: a7125ea4aada6e5d04d4f58109ef931593f39273
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e7410a027fa7a72a15fb90af367680069c9c1842a83aa96eb137e77596880bd803fa8478379c7724213930cc1c51db150bacd18e62681d9cb0d6080a16c0227
|
7
|
+
data.tar.gz: 01a535771b79dcaa05a78cf7a938e3a59261380762c6dd8118b889339cff0647774d8d8ca881c55ddcea361f18dc3857089bea67d0800a5cc4fe4b783f76f482
|
data/.travis.yml
CHANGED
@@ -1,18 +1,23 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
script: "bundle exec rake"
|
4
|
+
- 2.4
|
5
|
+
- 2.5
|
6
|
+
- 2.6
|
9
7
|
|
8
|
+
script: bundle exec rake
|
10
9
|
install: bundle install --retry=3 --jobs=3
|
11
10
|
|
12
|
-
#https://docs.travis-ci.com/user/languages/ruby/
|
13
11
|
before_install:
|
14
|
-
|
12
|
+
- gem install bundler -v '< 2'
|
15
13
|
|
16
14
|
gemfile:
|
17
|
-
|
18
|
-
|
15
|
+
- gemfiles/rails_4.gemfile
|
16
|
+
- gemfiles/rails_5.gemfile
|
17
|
+
|
18
|
+
deploy:
|
19
|
+
provider: rubygems
|
20
|
+
api_key:
|
21
|
+
secure: WbnbSdU4Tje9FbrJp/H80vBRvFGU9MpgyOOr8VSZUxOHJxzppaVWNS15luY9RKyai6jCn32az5dkcdatm+ij4bbT5DcEP+JERON6bgMlVQ8H5OJ6WncdN4KzMLAP0nbHbdC6j6rin5v4Ex8hUWEfFb4A4TRjCdRVmXtgPmITGjgdkHKNFp1xpJLGk3ya5T5Ii4sG/HRjJ7KtY6/xOJC/6qR+o7OBNC3lCocfIuqz6mS146n5nAy037Utuf/UatB9l5KX9k543GdKDGoP/MaAgA6PiOn3fF2osboSw1/re1485wVY/EtO/nIvwhBY99HiZFSg7RVxdCvP0LeP9Tug48LFP8zCW2lJIokOH9dAEddk/IDVRqp+Jl/WhXr1QU7en1GuHqtBrWX8CQeYOIU1bQwguzTvWe/4a5DB70iUeSamTRYUvwgkEyD/91QywaFQKNjDBHc0Uo3D+55p/Q4oR2x3jmr8NS0Af1oIPJFCck58UgN1RSln4iUBdaqST0hMbzjhOpa6ZCShbwT/P9qJkkUbE4pY9gB+XY5PFiXkC/KoWWUpjXJ2ZNEDL1vBAVOeT77lAbXczhMmg38aMSRjW312z2o+YjsWs8Ti0U+ie/98UZRR2zoydfr3VmURpaCBpKmK4K+uRbau5h2/G4uOMHR7YmCiiU4dq0bGmb8iM48=
|
22
|
+
on:
|
23
|
+
tags: true
|
data/README.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|

|
4
4
|
|
5
|
-
|
5
|
+
Stylish Graph APIs.
|
6
6
|
|
7
|
-
[View Official Documentation](https://graphiti-api.github.io/graphiti/guides)
|
7
|
+
[View Official Documentation](https://graphiti-api.github.io/graphiti/guides/)
|
8
|
+
|
9
|
+
[Join the Slack Channel](https://join.slack.com/t/graphiti-api/shared_invite/enQtMjkyMTA3MDgxNTQzLWVkMDM3NTlmNTIwODY2YWFkMGNiNzUzZGMzOTY3YmNmZjBhYzIyZWZlZTk4YmI1YTI0Y2M0OTZmZGYwN2QxZjg)
|
10
|
+
|
11
|
+
Direct Contact: richmolj@gmail.com
|
12
|
+
|
13
|
+
Supports Rails >= 4.1
|
14
|
+
|
15
|
+
*Looking for JSONAPI-Suite? You're in the right place. Graphiti is the 1.0 version of JSONAPI Suite. For the deprecated Suite gem, go [here](https://github.com/jsonapi-suite/jsonapi_suite_deprecated)*
|
@@ -28,8 +28,12 @@ module Graphiti
|
|
28
28
|
self.debug_models = ENV.fetch('GRAPHITI_DEBUG_MODELS', false)
|
29
29
|
|
30
30
|
if defined?(::Rails)
|
31
|
-
|
32
|
-
|
31
|
+
if File.exists?("#{::Rails.root}/.graphiticfg.yml")
|
32
|
+
cfg = YAML.load_file("#{::Rails.root}/.graphiticfg.yml")
|
33
|
+
@schema_path = "#{::Rails.root}/public#{cfg['namespace']}/schema.json"
|
34
|
+
else
|
35
|
+
@schema_path = "#{::Rails.root}/public/schema.json"
|
36
|
+
end
|
33
37
|
self.debug = ::Rails.logger.level.zero?
|
34
38
|
Graphiti.logger = ::Rails.logger
|
35
39
|
end
|
@@ -7,10 +7,10 @@ module Graphiti
|
|
7
7
|
@procs = {}
|
8
8
|
defaults = resource.adapter.default_operators[type_name] || [:eq]
|
9
9
|
if opts[:only]
|
10
|
-
defaults = defaults.select { |op| opts[:only].include?(op) }
|
10
|
+
defaults = defaults.select { |op| Array(opts[:only]).include?(op) }
|
11
11
|
end
|
12
12
|
if opts[:except]
|
13
|
-
defaults = defaults.reject { |op| opts[:except].include?(op) }
|
13
|
+
defaults = defaults.reject { |op| Array(opts[:except]).include?(op) }
|
14
14
|
end
|
15
15
|
defaults.each do |op|
|
16
16
|
@procs[op] = nil
|
@@ -44,6 +44,14 @@ module Graphiti
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
def around_persistence(method = nil, only: [:create, :update], &blk)
|
48
|
+
if blk
|
49
|
+
raise Errors::AroundCallbackProc.new(self, 'around_persistence')
|
50
|
+
else
|
51
|
+
add_callback(:persistence, :around, method, only, &blk)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
47
55
|
def around_destroy(method = nil, &blk)
|
48
56
|
if blk
|
49
57
|
raise Errors::AroundCallbackProc.new(self, 'around_destroy')
|
@@ -64,31 +72,35 @@ module Graphiti
|
|
64
72
|
def create(create_params)
|
65
73
|
model_instance = nil
|
66
74
|
|
67
|
-
run_callbacks :
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
75
|
+
run_callbacks :persistence, :create, create_params do
|
76
|
+
run_callbacks :attributes, :create, create_params do |params|
|
77
|
+
model_instance = build(model)
|
78
|
+
assign_attributes(model_instance, params)
|
79
|
+
model_instance
|
80
|
+
end
|
72
81
|
|
73
|
-
|
74
|
-
|
75
|
-
|
82
|
+
run_callbacks :save, :create, model_instance do
|
83
|
+
model_instance = save(model_instance)
|
84
|
+
end
|
76
85
|
|
77
|
-
|
86
|
+
model_instance
|
87
|
+
end
|
78
88
|
end
|
79
89
|
|
80
90
|
def update(update_params)
|
81
91
|
model_instance = nil
|
82
92
|
id = update_params.delete(:id)
|
83
93
|
|
84
|
-
run_callbacks :
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
94
|
+
run_callbacks :persistence, :update, update_params do
|
95
|
+
run_callbacks :attributes, :update, update_params do |params|
|
96
|
+
model_instance = self.class._find(params.merge(id: id)).data
|
97
|
+
assign_attributes(model_instance, params)
|
98
|
+
model_instance
|
99
|
+
end
|
89
100
|
|
90
|
-
|
91
|
-
|
101
|
+
run_callbacks :save, :update, model_instance do
|
102
|
+
model_instance = save(model_instance)
|
103
|
+
end
|
92
104
|
end
|
93
105
|
|
94
106
|
model_instance
|
data/lib/graphiti/schema.rb
CHANGED
@@ -16,6 +16,7 @@ module Graphiti
|
|
16
16
|
errors = Graphiti::SchemaDiff.new(old, schema).compare
|
17
17
|
return errors if errors.any?
|
18
18
|
end
|
19
|
+
FileUtils.mkdir_p(Graphiti.config.schema_path.gsub('/schema.json', ''))
|
19
20
|
File.write(Graphiti.config.schema_path, JSON.pretty_generate(schema))
|
20
21
|
[]
|
21
22
|
end
|
data/lib/graphiti/version.rb
CHANGED
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.0.rc.
|
4
|
+
version: 1.0.rc.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: 2019-01-
|
11
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|