graphiti 2.0.0.beta.7 → 2.0.0.beta.8
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/.git-blame-ignore-revs +2 -0
- data/.github/workflows/ci.yml +55 -3
- data/.github/workflows/docs.yml +1 -1
- data/.github/workflows/notify-example-app.yml +18 -0
- data/.gitignore +2 -0
- data/.standard.yml +6 -0
- data/CHANGELOG.md +45 -0
- data/CONTRIBUTING.md +3 -1
- data/README.md +13 -206
- data/Rakefile +6 -3
- data/UPGRADING.md +1 -1
- data/graphiti.gemspec +8 -4
- data/lib/generators/graphiti/generator_mixin.rb +1 -1
- data/lib/generators/graphiti/install_generator.rb +1 -1
- data/lib/generators/graphiti/resource_generator.rb +6 -3
- data/lib/generators/graphiti/templates/application_resource.rb.erb +19 -0
- data/lib/generators/graphiti/templates/controller.rb.erb +26 -8
- data/lib/graphiti/audit/report.rb +6 -6
- data/lib/graphiti/audit.rb +3 -4
- data/lib/graphiti/delegates/pagination.rb +2 -2
- data/lib/graphiti/deserializer.rb +3 -3
- data/lib/graphiti/errors.rb +6 -6
- data/lib/graphiti/extensions/temp_id.rb +1 -1
- data/lib/graphiti/query.rb +3 -3
- data/lib/graphiti/rails/context.rb +2 -1
- data/lib/graphiti/rails/controller.rb +3 -0
- data/lib/graphiti/rails/debugging.rb +1 -1
- data/lib/graphiti/rails/responders.rb +2 -1
- data/lib/graphiti/resource/configuration.rb +1 -0
- data/lib/graphiti/resource/dsl.rb +2 -2
- data/lib/graphiti/resource/links.rb +1 -1
- data/lib/graphiti/resource/persistence.rb +1 -1
- data/lib/graphiti/resource/polymorphism.rb +1 -1
- data/lib/graphiti/resource.rb +2 -2
- data/lib/graphiti/resource_proxy.rb +0 -1
- data/lib/graphiti/scoping/filter.rb +5 -3
- data/lib/graphiti/scoping/paginate.rb +1 -1
- data/lib/graphiti/scoping/sort.rb +1 -1
- data/lib/graphiti/sideload/has_many.rb +1 -1
- data/lib/graphiti/spec_helpers/errors_proxy.rb +1 -1
- data/lib/graphiti/spec_helpers/matchers.rb +1 -1
- data/lib/graphiti/types.rb +5 -1
- data/lib/graphiti/util/cache_debug.rb +3 -3
- data/lib/graphiti/util/hash.rb +1 -1
- data/lib/graphiti/util/persistence.rb +6 -6
- data/lib/graphiti/util/serializer_relationships.rb +1 -1
- data/lib/graphiti/version.rb +1 -1
- data/lib/tasks/graphiti.rake +1 -1
- metadata +31 -197
- data/docs/concepts/backends-and-models.md +0 -122
- data/docs/concepts/endpoints.md +0 -183
- data/docs/concepts/links.md +0 -212
- data/docs/concepts/overview.md +0 -80
- data/docs/concepts/persisting.md +0 -376
- data/docs/concepts/relationships.md +0 -627
- data/docs/concepts/resources.md +0 -677
- data/docs/getting-started/first-api.md +0 -289
- data/docs/getting-started/installation.md +0 -185
- data/docs/intro.md +0 -307
- data/docs/js/authentication.md +0 -63
- data/docs/js/ddau.md +0 -20
- data/docs/js/extra-params.md +0 -41
- data/docs/js/index.md +0 -112
- data/docs/js/installation.md +0 -120
- data/docs/js/middleware.md +0 -72
- data/docs/js/models.md +0 -202
- data/docs/js/reads.md +0 -494
- data/docs/js/state-syncing.md +0 -100
- data/docs/js/writes.md +0 -373
- data/docs/reference/vandal.md +0 -63
- data/docs/reference/why.md +0 -13
- data/docs/topics/authorization.md +0 -155
- data/docs/topics/caching.md +0 -55
- data/docs/topics/customizing-sideloads.md +0 -156
- data/docs/topics/debugging.md +0 -242
- data/docs/topics/error-handling.md +0 -210
- data/docs/topics/etags.md +0 -46
- data/docs/topics/hopping-relationships.md +0 -149
- data/docs/topics/json-attributes.md +0 -77
- data/docs/topics/openstruct-models.md +0 -50
- data/docs/topics/remote-resources.md +0 -291
- data/docs/topics/testing.md +0 -916
- data/docs/topics/without-activerecord.md +0 -324
- data/docs/tutorial/index.md +0 -58
- data/docs/tutorial/step_0.md +0 -107
- data/docs/tutorial/step_1.md +0 -199
- data/docs/tutorial/step_2.md +0 -312
- data/docs/tutorial/step_3.md +0 -142
- data/docs/tutorial/step_4.md +0 -135
- data/docs/tutorial/step_5.md +0 -69
- data/docs/tutorial/step_6.md +0 -82
- data/docs/tutorial/step_7.md +0 -205
- data/docs/tutorial/step_8.md +0 -128
- data/docs/tutorial/step_9.md +0 -171
- data/docs/upgrading.md +0 -267
- data/website/.gitignore +0 -20
- data/website/README.md +0 -43
- data/website/docusaurus.config.js +0 -197
- data/website/package-lock.json +0 -19474
- data/website/package.json +0 -46
- data/website/sidebars.js +0 -82
- data/website/src/css/custom.css +0 -85
- data/website/src/pages/markdown-page.mdx +0 -7
- data/website/static/.nojekyll +0 -0
- data/website/static/1.13/2019/03/31/graphiti-1-0.html +0 -205
- data/website/static/1.13/2019/05/08/graphiti-1-1.html +0 -212
- data/website/static/1.13/2019/05/20/graphiti-1-2.html +0 -214
- data/website/static/1.13/2019/10/14/tutorial.html +0 -198
- data/website/static/1.13/CNAME +0 -1
- data/website/static/1.13/README.md +0 -16
- data/website/static/1.13/assets/css/syntax.css +0 -60
- data/website/static/1.13/assets/favicons/android-chrome-192x192.png +0 -0
- data/website/static/1.13/assets/favicons/android-chrome-256x256.png +0 -0
- data/website/static/1.13/assets/favicons/apple-touch-icon.png +0 -0
- data/website/static/1.13/assets/favicons/browserconfig.xml +0 -9
- data/website/static/1.13/assets/favicons/favicon-16x16.png +0 -0
- data/website/static/1.13/assets/favicons/favicon-32x32.png +0 -0
- data/website/static/1.13/assets/favicons/favicon.ico +0 -0
- data/website/static/1.13/assets/favicons/mstile-150x150.png +0 -0
- data/website/static/1.13/assets/favicons/safari-pinned-tab.svg +0 -1
- data/website/static/1.13/assets/favicons/site.webmanifest +0 -19
- data/website/static/1.13/assets/img/backend.gif +0 -0
- data/website/static/1.13/assets/img/conformity.png +0 -0
- data/website/static/1.13/assets/img/error_payload.png +0 -0
- data/website/static/1.13/assets/img/fancy-cushion.png +0 -0
- data/website/static/1.13/assets/img/gh.png +0 -0
- data/website/static/1.13/assets/img/home-bg.jpg +0 -0
- data/website/static/1.13/assets/img/lifecycle.gif +0 -0
- data/website/static/1.13/assets/img/logo-500.png +0 -0
- data/website/static/1.13/assets/img/logo.png +0 -0
- data/website/static/1.13/assets/img/love-graffiti.jpg +0 -0
- data/website/static/1.13/assets/img/meta_total_count.png +0 -0
- data/website/static/1.13/assets/img/persist.jpg +0 -0
- data/website/static/1.13/assets/img/resource.gif +0 -0
- data/website/static/1.13/assets/img/rest-graffiti.jpg +0 -0
- data/website/static/1.13/assets/img/rest1.gif +0 -0
- data/website/static/1.13/assets/img/rest2.gif +0 -0
- data/website/static/1.13/assets/img/rest3.gif +0 -0
- data/website/static/1.13/assets/img/rethink-rest-graffiti.jpg +0 -0
- data/website/static/1.13/assets/img/sunrise.png +0 -0
- data/website/static/1.13/assets/img/why.png +0 -0
- data/website/static/1.13/assets/js/highlight.pack.js +0 -2
- data/website/static/1.13/assets/main.css +0 -15518
- data/website/static/1.13/assets/main.css.map +0 -1
- data/website/static/1.13/bin/bundle +0 -109
- data/website/static/1.13/bin/jekyll +0 -27
- data/website/static/1.13/bin/kramdown +0 -27
- data/website/static/1.13/bin/listen +0 -27
- data/website/static/1.13/bin/rake +0 -27
- data/website/static/1.13/bin/rougify +0 -27
- data/website/static/1.13/bin/safe_yaml +0 -27
- data/website/static/1.13/bin/sass +0 -27
- data/website/static/1.13/bin/sass-convert +0 -27
- data/website/static/1.13/bin/scss +0 -27
- data/website/static/1.13/blog.html +0 -259
- data/website/static/1.13/cheatsheet.html +0 -316
- data/website/static/1.13/cookbooks/authorization.md +0 -0
- data/website/static/1.13/cookbooks/caching.md +0 -0
- data/website/static/1.13/cookbooks/customizing-sideloads.html +0 -325
- data/website/static/1.13/cookbooks/etags.md +0 -0
- data/website/static/1.13/cookbooks/hopping-relationships.html +0 -324
- data/website/static/1.13/cookbooks/json_attributes.md +0 -0
- data/website/static/1.13/cookbooks/openstruct-models.md +0 -0
- data/website/static/1.13/cookbooks/remote-resources.md +0 -0
- data/website/static/1.13/cookbooks/without-activerecord.html +0 -510
- data/website/static/1.13/features.html +0 -249
- data/website/static/1.13/feed.xml +0 -106
- data/website/static/1.13/guides/concepts/backends-and-models.html +0 -467
- data/website/static/1.13/guides/concepts/debugging.html +0 -440
- data/website/static/1.13/guides/concepts/endpoints.html +0 -432
- data/website/static/1.13/guides/concepts/error-handling.html +0 -396
- data/website/static/1.13/guides/concepts/links.html +0 -501
- data/website/static/1.13/guides/concepts/remote-resources.html +0 -536
- data/website/static/1.13/guides/concepts/resources.html +0 -2176
- data/website/static/1.13/guides/concepts/testing.html +0 -1469
- data/website/static/1.13/guides/getting-started/installation.html +0 -420
- data/website/static/1.13/guides/graphiti-rails-migration.html +0 -242
- data/website/static/1.13/guides/index.html +0 -269
- data/website/static/1.13/guides/overview.html +0 -325
- data/website/static/1.13/guides/upgrading-2-0.html +0 -193
- data/website/static/1.13/guides/upgrading.html +0 -314
- data/website/static/1.13/guides/vandal.html +0 -282
- data/website/static/1.13/guides/why.html +0 -1121
- data/website/static/1.13/index.html +0 -72
- data/website/static/1.13/js/authentication.html +0 -295
- data/website/static/1.13/js/ddau.html +0 -238
- data/website/static/1.13/js/extra-params.html +0 -270
- data/website/static/1.13/js/index.html +0 -321
- data/website/static/1.13/js/installation.html +0 -637
- data/website/static/1.13/js/introduction.html +0 -257
- data/website/static/1.13/js/middleware.html +0 -318
- data/website/static/1.13/js/reads/fieldsets.html +0 -271
- data/website/static/1.13/js/reads/filtering.html +0 -289
- data/website/static/1.13/js/reads/includes.html +0 -260
- data/website/static/1.13/js/reads/index.html +0 -497
- data/website/static/1.13/js/reads/nested-queries.html +0 -353
- data/website/static/1.13/js/reads/pagination.html +0 -260
- data/website/static/1.13/js/reads/sorting.html +0 -265
- data/website/static/1.13/js/reads/statistics.html +0 -289
- data/website/static/1.13/js/state-syncing.html +0 -340
- data/website/static/1.13/js/writes/deferred.html +0 -296
- data/website/static/1.13/js/writes/dirty-tracking.html +0 -399
- data/website/static/1.13/js/writes/index.html +0 -391
- data/website/static/1.13/js/writes/nested.html +0 -330
- data/website/static/1.13/js/writes/validations.html +0 -272
- data/website/static/1.13/quickstart.html +0 -660
- data/website/static/1.13/template +0 -161
- data/website/static/1.13/tutorial/index.html +0 -250
- data/website/static/1.13/tutorial/step_0.html +0 -292
- data/website/static/1.13/tutorial/step_1.html +0 -517
- data/website/static/1.13/tutorial/step_2.html +0 -481
- data/website/static/1.13/tutorial/step_3.html +0 -323
- data/website/static/1.13/tutorial/step_4.html +0 -318
- data/website/static/1.13/tutorial/step_5.html +0 -265
- data/website/static/1.13/tutorial/step_6.html +0 -276
- data/website/static/1.13/tutorial/step_7.html +0 -390
- data/website/static/1.13/tutorial/step_8.html +0 -316
- data/website/static/1.13/tutorial/step_9.html +0 -365
- data/website/static/CNAME +0 -1
- data/website/static/assets/img/error_payload.png +0 -0
- data/website/static/assets/img/legacy/legacy-0378a3bb39.png +0 -0
- data/website/static/assets/img/legacy/legacy-05bbd3e5fd.png +0 -0
- data/website/static/assets/img/legacy/legacy-07aa104495.png +0 -0
- data/website/static/assets/img/legacy/legacy-0c75a16b3a.gif +0 -0
- data/website/static/assets/img/legacy/legacy-3076df6209.png +0 -0
- data/website/static/assets/img/legacy/legacy-7f6889bc89.png +0 -0
- data/website/static/assets/img/legacy/legacy-a2cc4363c3.png +0 -0
- data/website/static/assets/img/legacy/legacy-f67cfa89ab.png +0 -0
- data/website/static/assets/img/meta_total_count.png +0 -0
- data/website/static/img/docusaurus-social-card.jpg +0 -0
- data/website/static/img/docusaurus.png +0 -0
- data/website/static/img/favicon.ico +0 -0
- data/website/static/img/logo.png +0 -0
- data/website/static/img/logo.svg +0 -1
- data/website/static/img/undraw_docusaurus_mountain.svg +0 -171
- data/website/static/img/undraw_docusaurus_react.svg +0 -170
- data/website/static/img/undraw_docusaurus_tree.svg +0 -40
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Thor::Base.shell = Thor::Shell::Color
|
|
3
|
-
require 'yaml'
|
|
4
|
-
|
|
5
|
-
def truthy?(statement)
|
|
6
|
-
val = ask(statement)
|
|
7
|
-
['y', 'yes', ''].include?(val)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def eval_template(name)
|
|
11
|
-
instance_eval(File.read(File.dirname(__FILE__) + "/#{name}.rb"))
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def update_config!(attrs)
|
|
15
|
-
config = File.exists?('.graphiticfg.yml') ? YAML.load_file('.graphiticfg.yml') : {}
|
|
16
|
-
config.merge!(attrs)
|
|
17
|
-
File.open('.graphiticfg.yml', 'w') { |f| f.write(config.to_yaml) }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def api_namespace
|
|
21
|
-
@api_namespace ||= begin
|
|
22
|
-
ns = prompt \
|
|
23
|
-
header: "What is your API namespace?",
|
|
24
|
-
description: "This will be used as a route prefix, e.g. if you want the route '/books_api/v1/authors' your namespace would be '/books_api/v1'",
|
|
25
|
-
default: '/api/v1'
|
|
26
|
-
update_config!('namespace' => ns)
|
|
27
|
-
ns
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def prompt(header: nil, description: nil, default: nil)
|
|
32
|
-
say(set_color("\n#{header}", :magenta, :bold)) if header
|
|
33
|
-
say("\n#{description}") if description
|
|
34
|
-
answer = ask(set_color("\n(default: #{default}):", :magenta, :bold))
|
|
35
|
-
answer = default if answer.blank? && default != 'nil'
|
|
36
|
-
say(set_color("\nGot it!\n", :white, :bold))
|
|
37
|
-
answer
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
welcome = <<-STR
|
|
41
|
-
\n
|
|
42
|
-
Welcome to the Graphiti generator!
|
|
43
|
-
=======================================
|
|
44
|
-
|
|
45
|
-
This will take care of some boilerplate for you, like adding gem dependencies and rspec helpers.
|
|
46
|
-
|
|
47
|
-
If you're worried there might be too much magic here, feel free to run 'git diff' at the end to see what happened. You can also learn more at our documentation website, https://jsonapi-suite.github.io/jsonapi_suite
|
|
48
|
-
STR
|
|
49
|
-
|
|
50
|
-
say(set_color(welcome.rstrip, :cyan, :bold))
|
|
51
|
-
api_namespace
|
|
52
|
-
|
|
53
|
-
require 'rails/version'
|
|
54
|
-
|
|
55
|
-
gem 'graphiti'
|
|
56
|
-
gem 'graphiti-rails'
|
|
57
|
-
gem 'vandal_ui'
|
|
58
|
-
gem 'kaminari', '~> 1.1'
|
|
59
|
-
|
|
60
|
-
if Rails::VERSION::MAJOR == 5
|
|
61
|
-
gem 'responders', '~> 2.4'
|
|
62
|
-
else
|
|
63
|
-
gem 'responders', '~> 3.0'
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
gem_group :development, :test do
|
|
67
|
-
if Rails::VERSION::MAJOR == 5
|
|
68
|
-
gem 'rspec-rails', '~> 3.5.2'
|
|
69
|
-
else
|
|
70
|
-
gem 'rspec-rails', '~> 4.0.0beta2'
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
gem 'factory_bot_rails', '~> 5.0'
|
|
74
|
-
gem 'faker', '~> 2.5' # keep here for seeds.rb
|
|
75
|
-
gem 'graphiti_spec_helpers'
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
gem_group :test do
|
|
79
|
-
gem 'database_cleaner', '~> 1.7'
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
after_bundle do
|
|
83
|
-
unless Rails::VERSION::MAJOR > 6
|
|
84
|
-
run 'bin/spring stop'
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
git :init
|
|
88
|
-
git add: '.'
|
|
89
|
-
run "bundle binstub rspec-core"
|
|
90
|
-
rails_command "generate rspec:install"
|
|
91
|
-
run "rm -rf test"
|
|
92
|
-
|
|
93
|
-
insert_into_file "spec/rails_helper.rb", :after => "require 'rspec/rails'\n" do
|
|
94
|
-
"require 'graphiti_spec_helpers/rspec'\n"
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
|
|
98
|
-
<<-STR
|
|
99
|
-
|
|
100
|
-
# bootstrap database cleaner
|
|
101
|
-
config.before(:suite) do
|
|
102
|
-
DatabaseCleaner.strategy = :transaction
|
|
103
|
-
DatabaseCleaner.clean_with(:truncation)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
config.around(:each) do |example|
|
|
107
|
-
begin
|
|
108
|
-
DatabaseCleaner.cleaning do
|
|
109
|
-
example.run
|
|
110
|
-
end
|
|
111
|
-
ensure
|
|
112
|
-
DatabaseCleaner.clean
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
STR
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
|
|
120
|
-
<<-STR
|
|
121
|
-
|
|
122
|
-
config.before :each do
|
|
123
|
-
handle_request_exceptions(false)
|
|
124
|
-
end
|
|
125
|
-
STR
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
|
|
129
|
-
" config.include Graphiti::Rails::TestHelpers\n"
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
|
|
133
|
-
" config.include GraphitiSpecHelpers::Sugar\n"
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
|
|
137
|
-
" config.include GraphitiSpecHelpers::RSpec\n"
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
|
|
141
|
-
" config.include FactoryBot::Syntax::Methods\n"
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
gsub_file "spec/rails_helper.rb", 'config.fixture_path = "#{::Rails.root}/spec/fixtures"' do |match|
|
|
145
|
-
"# #{match}"
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
gsub_file "spec/rails_helper.rb", 'config.use_transactional_fixtures = true' do |match|
|
|
149
|
-
"# #{match}"
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
run "mkdir spec/factories"
|
|
153
|
-
|
|
154
|
-
rails_command('generate graphiti:install')
|
|
155
|
-
run 'bundle binstubs bundler --force'
|
|
156
|
-
rake('vandal:install')
|
|
157
|
-
say(set_color("\nYou're all set!
|
|
158
|
-
", :green, :bold))
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
-
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
|
|
9
|
-
<link href="https://fonts.googleapis.com/css?family=Boogaloo" rel="stylesheet">
|
|
10
|
-
|
|
11
|
-
<link rel="apple-touch-icon" sizes="180x180" href="/1.13/assets/favicons/apple-touch-icon.png">
|
|
12
|
-
<link rel="icon" type="image/png" sizes="32x32" href="/1.13/assets/favicons/favicon-32x32.png">
|
|
13
|
-
<link rel="icon" type="image/png" sizes="16x16" href="/1.13/assets/favicons/favicon-16x16.png">
|
|
14
|
-
<link rel="manifest" href="/1.13/assets/favicons/site.webmanifest">
|
|
15
|
-
<link rel="mask-icon" href="/1.13/assets/favicons/safari-pinned-tab.svg" color="#F86DA7">
|
|
16
|
-
<link rel="shortcut icon" href="/1.13/assets/favicons/favicon.ico">
|
|
17
|
-
<meta name="msapplication-TileColor" content="#F86DA7">
|
|
18
|
-
<meta name="msapplication-config" content="/1.13/assets/favicons/browserconfig.xml">
|
|
19
|
-
<meta name="theme-color" content="#F86DA7">
|
|
20
|
-
|
|
21
|
-
<title>Graphiti</title>
|
|
22
|
-
<meta name="description" content="Stylish Graph APIs">
|
|
23
|
-
|
|
24
|
-
<link rel="stylesheet" href="/1.13/assets/main.css?ref=wh4t3v45">
|
|
25
|
-
<link rel="alternate" type="application/rss+xml" title="Graphiti" href="/1.13/feed.xml">
|
|
26
|
-
|
|
27
|
-
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
28
|
-
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-127904727-1"></script>
|
|
29
|
-
<script>
|
|
30
|
-
window.dataLayer = window.dataLayer || [];
|
|
31
|
-
function gtag(){dataLayer.push(arguments);}
|
|
32
|
-
gtag('js', new Date());
|
|
33
|
-
|
|
34
|
-
gtag('config', 'UA-127904727-1');
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<!-- javascript -->
|
|
38
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
|
39
|
-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
</head>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<body>
|
|
46
|
-
<main class="page-content" aria-label="Content">
|
|
47
|
-
<div class="wrapper">
|
|
48
|
-
<header class="navbar navbar-inverse normal" role="banner">
|
|
49
|
-
<div class="container">
|
|
50
|
-
<div class="navbar-header">
|
|
51
|
-
<a href="/1.13/1.13" class="navbar-brand">
|
|
52
|
-
<img alt="logo" src="/1.13/assets/img/logo.png">
|
|
53
|
-
</a>
|
|
54
|
-
</div>
|
|
55
|
-
<nav class="" role="navigation">
|
|
56
|
-
<ul class="nav navbar-nav nav-links">
|
|
57
|
-
<li>
|
|
58
|
-
<a class="quickstart nav-link" href="/1.13/quickstart">Quickstart</a>
|
|
59
|
-
</li>
|
|
60
|
-
<li>
|
|
61
|
-
<a class="guides nav-link" href="/1.13/guides">Guides</a>
|
|
62
|
-
</li>
|
|
63
|
-
<li>
|
|
64
|
-
<a class="tutorial nav-link" href="/1.13/tutorial">Tutorial</a>
|
|
65
|
-
</li>
|
|
66
|
-
<li>
|
|
67
|
-
<a class="spraypaint nav-link" href="/1.13/js">Spraypaint</a>
|
|
68
|
-
</li>
|
|
69
|
-
</ul>
|
|
70
|
-
<ul class="nav gh navbar-nav navbar-right visible-lg visible-md">
|
|
71
|
-
<li>
|
|
72
|
-
<span class="star">⭐</span>
|
|
73
|
-
<a href="https://github.com/graphiti-api/graphiti">
|
|
74
|
-
<img alt="github-star" style="margin-right: 65px;margin-top: -20px" src="/1.13/assets/img/gh.png">
|
|
75
|
-
</a>
|
|
76
|
-
</li>
|
|
77
|
-
</ul>
|
|
78
|
-
</nav>
|
|
79
|
-
</div>
|
|
80
|
-
</header>
|
|
81
|
-
|
|
82
|
-
<div class="container">
|
|
83
|
-
<p align="center">
|
|
84
|
-
<img src="https://user-images.githubusercontent.com/55264/45711831-c87dbd80-bb58-11e8-9c67-84ba9427d60a.gif" />
|
|
85
|
-
</p>
|
|
86
|
-
|
|
87
|
-
<h1 id="tutorial">Tutorial</h1>
|
|
88
|
-
|
|
89
|
-
<p>This tutorial serves as a deeper-dive into Graphiti development,
|
|
90
|
-
building an Employee Directory application. We purposefully built this
|
|
91
|
-
to illustrate common - but non-trivial - scenarios present in many
|
|
92
|
-
applications.</p>
|
|
93
|
-
|
|
94
|
-
<p>A core concept of Graphiti is <strong>Test-First</strong> - the most pleasant way to
|
|
95
|
-
develop Graphiti is by starting with an <a href="/1.13/guides/concepts/testing">integration test</a>. But that can add a lot of noise to a tutorial like this. Though we’ll occasionally touch on testing - and the git diffs at the top of each section contain the necessary tests - we won’t test first for the purposes of this tutorial.</p>
|
|
96
|
-
|
|
97
|
-
<div class="clearfix">
|
|
98
|
-
<div class="tutorial col-md-6">
|
|
99
|
-
|
|
100
|
-
<h3 id="server-side-rails">Server Side: Rails</h3>
|
|
101
|
-
|
|
102
|
-
<p><a href="https://github.com/graphiti-api/employee_directory">Rails Sample Application</a></p>
|
|
103
|
-
|
|
104
|
-
<ul>
|
|
105
|
-
<li><a href="/1.13/tutorial/step_0">Step 0: Bootstrapping</a></li>
|
|
106
|
-
<li><a href="/1.13/tutorial/step_1">Step 1: Initial Resource</a></li>
|
|
107
|
-
<li><a href="/1.13/tutorial/step_2">Step 2: Has Many</a></li>
|
|
108
|
-
<li><a href="/1.13/tutorial/step_3">Step 3: Belongs To</a></li>
|
|
109
|
-
<li><a href="/1.13/tutorial/step_4">Step 4: Customizing Queries</a></li>
|
|
110
|
-
<li><a href="/1.13/tutorial/step_5">Step 5: Has One</a></li>
|
|
111
|
-
<li><a href="/1.13/tutorial/step_6">Step 6: Customizing Writes</a></li>
|
|
112
|
-
<li><a href="/1.13/tutorial/step_7">Step 7: Many-to-Many</a></li>
|
|
113
|
-
<li><a href="/1.13/tutorial/step_8">Step 8: Polymorphic
|
|
114
|
-
Relationships</a></li>
|
|
115
|
-
<li><a href="/1.13/tutorial/step_9">Step 9: Polymorphic Resources</a></li>
|
|
116
|
-
</ul>
|
|
117
|
-
|
|
118
|
-
</div>
|
|
119
|
-
|
|
120
|
-
<div class="tutorial col-md-6">
|
|
121
|
-
|
|
122
|
-
<h3 id="client-side-vuejs-diff-only">Client Side: VueJS (diff-only)</h3>
|
|
123
|
-
|
|
124
|
-
<p><a href="https://github.com/graphiti-api/employee-directory-vue">VueJS Sample Application</a></p>
|
|
125
|
-
|
|
126
|
-
<ul>
|
|
127
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/commit/be690c3038380e17e326935d595a0b83fc8004f9">Step 0: Setup</a>
|
|
128
|
-
<ul>
|
|
129
|
-
<li>Run after <code class="language-plaintext highlighter-rouge">vue create employee-directory-vue</code> using <a href="https://cli.vuejs.org">Vue CLI</a>.</li>
|
|
130
|
-
</ul>
|
|
131
|
-
</li>
|
|
132
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_0_setup...step_1_models">Step 1: Define Models</a></li>
|
|
133
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_1_models...step_2_data_grid">Step 2: Data Grid</a></li>
|
|
134
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_2_data_grid...step_3_includes">Step 3: Relationships</a></li>
|
|
135
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_3_includes...step_4_filtering">Step 4: Filtering</a></li>
|
|
136
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_4_filtering...step_5_sorting">Step 5: Sorting</a></li>
|
|
137
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_5_sorting...step_6_stats">Step 6: Total Count</a></li>
|
|
138
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_6_stats...step_7_pagination">Step 7: Pagination</a></li>
|
|
139
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_7_pagination...step_8_basic_form_setup">Step 8: Basic Form Setup</a></li>
|
|
140
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_8_basic_form_setup...step_9_dropdown">Step 9: Dropdown</a></li>
|
|
141
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_9_dropdown...step_10_nested_create">Step 10: Nested Form Submission</a></li>
|
|
142
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_10_nested_create...step_11_validations">Step 11: Validation Errors</a></li>
|
|
143
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_11_validations...step_12_nested_destroy">Step 12: Nested Destroy</a></li>
|
|
144
|
-
<li><a href="https://github.com/graphiti-api/employee-directory-vue/compare/step_12_nested_destroy...step_13_vue">Step 13: Vue-Specific Glue Code</a></li>
|
|
145
|
-
</ul>
|
|
146
|
-
|
|
147
|
-
</div>
|
|
148
|
-
</div>
|
|
149
|
-
|
|
150
|
-
<p><br />
|
|
151
|
-
<br />
|
|
152
|
-
<br />
|
|
153
|
-
<br />
|
|
154
|
-
<br /></p>
|
|
155
|
-
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
</main>
|
|
159
|
-
<div class="main-footer main-footer--dark">
|
|
160
|
-
<div class="container">
|
|
161
|
-
<div class="row">
|
|
162
|
-
<div class="col-sm-4 menu">
|
|
163
|
-
<h3>Overview</h3>
|
|
164
|
-
<ul>
|
|
165
|
-
<li>
|
|
166
|
-
<a href="/1.13/quickstart">Quickstart</a>
|
|
167
|
-
</li>
|
|
168
|
-
<li>
|
|
169
|
-
<a href="/1.13/tutorial">Tutorial</a>
|
|
170
|
-
</li>
|
|
171
|
-
<li>
|
|
172
|
-
<a href="/1.13/guides">Guides</a>
|
|
173
|
-
</li>
|
|
174
|
-
</ul>
|
|
175
|
-
</div>
|
|
176
|
-
<div class="col-sm-4 menu">
|
|
177
|
-
<h3>Contact</h3>
|
|
178
|
-
<ul>
|
|
179
|
-
<li>
|
|
180
|
-
<a target="_blank" href="https://discord.gg/wgqkMBsSRV">Discord Chat</a>
|
|
181
|
-
</li>
|
|
182
|
-
<li>
|
|
183
|
-
<a href="mailto:richmolj@gmail.com">Email</a>
|
|
184
|
-
</li>
|
|
185
|
-
</ul>
|
|
186
|
-
</div>
|
|
187
|
-
<div class="col-sm-4 menu">
|
|
188
|
-
<h3>Related</h3>
|
|
189
|
-
<ul>
|
|
190
|
-
<li>
|
|
191
|
-
<a target="_blank" href="http://jsonapi.org">JSONAPI Spec</a>
|
|
192
|
-
</li>
|
|
193
|
-
<li>
|
|
194
|
-
<a target="_blank" href="http://jsonapi-rb.org">jsonapi-rb</a>
|
|
195
|
-
</li>
|
|
196
|
-
<li>
|
|
197
|
-
<a target="_blank" href="https://vuejs.org/">VueJS</a>
|
|
198
|
-
</li>
|
|
199
|
-
</ul>
|
|
200
|
-
</div>
|
|
201
|
-
</div>
|
|
202
|
-
</div>
|
|
203
|
-
</div>
|
|
204
|
-
|
|
205
|
-
<script type="text/javascript">
|
|
206
|
-
$(function () {
|
|
207
|
-
|
|
208
|
-
var flipTabs = function() {
|
|
209
|
-
var isTS = true;
|
|
210
|
-
if (localStorage.getItem('js-lang') === 'javascript') {
|
|
211
|
-
isTS = false;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
$('.code-tabs').each(function(index, el) {
|
|
215
|
-
if (isTS) {
|
|
216
|
-
console.log('hiding js');
|
|
217
|
-
$($(el).children()[1]).hide();
|
|
218
|
-
$($(el).children()[0]).show();
|
|
219
|
-
} else {
|
|
220
|
-
console.log('hiding ts');
|
|
221
|
-
$($(el).children()[0]).hide();
|
|
222
|
-
$($(el).children()[1]).show();
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
if (isTS) {
|
|
227
|
-
$('.tab.typescript').addClass('active');
|
|
228
|
-
$('.tab.javascript').removeClass('active');
|
|
229
|
-
} else {
|
|
230
|
-
$('.tab.typescript').removeClass('active');
|
|
231
|
-
$('.tab.javascript').addClass('active');
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
$('.tab').click(function() {
|
|
236
|
-
if ($(this).hasClass('typescript')) {
|
|
237
|
-
localStorage.setItem('js-lang', 'typescript');
|
|
238
|
-
} else {
|
|
239
|
-
localStorage.setItem('js-lang', 'javascript');
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
flipTabs();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
flipTabs();
|
|
246
|
-
})
|
|
247
|
-
</script>
|
|
248
|
-
|
|
249
|
-
</body>
|
|
250
|
-
</html>
|