graphiti 1.0.rc.1 → 1.0.rc.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
  SHA1:
3
- metadata.gz: e2f08ef4d30b29ef5c5f92edbbe140f2c17fda44
4
- data.tar.gz: 69ecb7a4391c83464dd484fb41c311bd6b011279
3
+ metadata.gz: 26fc322fc29632b3e24f85bcbe535a3542c0d142
4
+ data.tar.gz: a7125ea4aada6e5d04d4f58109ef931593f39273
5
5
  SHA512:
6
- metadata.gz: 0e1a85b61236afbd009a8401b5c475ed2a2c1afd3fc5b38dd220971680e9bd4174b7e7bde8fd8738b59408065b4d01278bf3cc0b673aae87e0a5392bfbb735dd
7
- data.tar.gz: '0791076ccd2120da1db4060b7b674c7871a08e736687d78fa991e76b8e55901a31d70e4fcfb5fc2d54d518083f7312fefe16499828e78efe000f6655a4057966'
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
- - 2.4
5
- - 2.5
6
- - 2.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
- - gem install bundler -v '< 2'
12
+ - gem install bundler -v '< 2'
15
13
 
16
14
  gemfile:
17
- - gemfiles/rails_4.gemfile
18
- - gemfiles/rails_5.gemfile
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
  ![Build Status](https://travis-ci.org/graphiti-api/graphiti.svg?branch=master)
4
4
 
5
- A stylish alternative to GraphQL.
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
- cfg = YAML.load_file("#{::Rails.root}/.graphiticfg.yml")
32
- @schema_path = "#{::Rails.root}/public#{cfg['namespace']}/schema.json"
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 :attributes, :create, create_params do |params|
68
- model_instance = build(model)
69
- assign_attributes(model_instance, params)
70
- model_instance
71
- end
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
- run_callbacks :save, :create, model_instance do
74
- model_instance = save(model_instance)
75
- end
82
+ run_callbacks :save, :create, model_instance do
83
+ model_instance = save(model_instance)
84
+ end
76
85
 
77
- model_instance
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 :attributes, :update, update_params do |params|
85
- model_instance = self.class._find(params.merge(id: id)).data
86
- assign_attributes(model_instance, params)
87
- model_instance
88
- end
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
- run_callbacks :save, :update, model_instance do
91
- model_instance = save(model_instance)
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
@@ -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
@@ -13,7 +13,7 @@ module Graphiti
13
13
  return unless readable?
14
14
 
15
15
  if @name == :id
16
- @serializer.id(&@attr[:proc]) if @attr[:proc]
16
+ @serializer.id(&proc)
17
17
  elsif @attr[:proc]
18
18
  @serializer.send(_method, @name, serializer_options, &proc)
19
19
  else
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.0.rc.1"
2
+ VERSION = "1.0.rc.2"
3
3
  end
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.1
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-06 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable