graphiti 2.0.0.beta.2 → 2.0.0.beta.4
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/.github/workflows/ci.yml +30 -86
- data/.github/workflows/docs.yml +60 -0
- data/.github/workflows/release.yml +8 -8
- data/.gitignore +7 -0
- data/.npmrc +9 -0
- data/.standard.yml +4 -1
- data/Appraisals +33 -32
- data/CHANGELOG.md +41 -0
- data/README.md +13 -2
- data/UPGRADING.md +2 -68
- data/docs/concepts/backends-and-models.md +122 -0
- data/docs/concepts/endpoints.md +183 -0
- data/docs/concepts/links.md +212 -0
- data/docs/concepts/overview.md +80 -0
- data/docs/concepts/persisting.md +376 -0
- data/docs/concepts/relationships.md +527 -0
- data/docs/concepts/resources.md +677 -0
- data/docs/getting-started/first-api.md +289 -0
- data/docs/getting-started/installation.md +185 -0
- data/docs/intro.md +307 -0
- data/docs/js/authentication.md +63 -0
- data/docs/js/ddau.md +20 -0
- data/docs/js/extra-params.md +41 -0
- data/docs/js/index.md +112 -0
- data/docs/js/installation.md +120 -0
- data/docs/js/middleware.md +72 -0
- data/docs/js/models.md +202 -0
- data/docs/js/reads.md +494 -0
- data/docs/js/state-syncing.md +100 -0
- data/docs/js/writes.md +373 -0
- data/docs/reference/vandal.md +63 -0
- data/docs/reference/why.md +13 -0
- data/docs/topics/authorization.md +155 -0
- data/docs/topics/caching.md +55 -0
- data/docs/topics/customizing-sideloads.md +156 -0
- data/docs/topics/debugging.md +216 -0
- data/docs/topics/error-handling.md +210 -0
- data/docs/topics/etags.md +46 -0
- data/docs/topics/hopping-relationships.md +149 -0
- data/docs/topics/json-attributes.md +77 -0
- data/docs/topics/openstruct-models.md +50 -0
- data/docs/topics/remote-resources.md +291 -0
- data/docs/topics/testing.md +894 -0
- data/docs/topics/without-activerecord.md +324 -0
- data/docs/tutorial/index.md +58 -0
- data/docs/tutorial/step_0.md +107 -0
- data/docs/tutorial/step_1.md +199 -0
- data/docs/tutorial/step_2.md +312 -0
- data/docs/tutorial/step_3.md +142 -0
- data/docs/tutorial/step_4.md +135 -0
- data/docs/tutorial/step_5.md +69 -0
- data/docs/tutorial/step_6.md +82 -0
- data/docs/tutorial/step_7.md +205 -0
- data/docs/tutorial/step_8.md +128 -0
- data/docs/tutorial/step_9.md +171 -0
- data/docs/upgrading.md +265 -0
- data/gemfiles/rails_7_1.gemfile +4 -3
- data/gemfiles/{rails_7_2_graphiti_rails.gemfile → rails_7_2.gemfile} +3 -3
- data/gemfiles/{rails_8_1_graphiti_rails.gemfile → rails_8_0.gemfile} +3 -3
- data/gemfiles/{rails_8_0_graphiti_rails.gemfile → rails_8_1.gemfile} +3 -3
- data/graphiti.gemspec +7 -5
- data/{deprecated_generators → lib/generators}/graphiti/api_test_generator.rb +7 -1
- data/{deprecated_generators → lib/generators}/graphiti/generator_mixin.rb +14 -1
- data/{deprecated_generators → lib/generators}/graphiti/install_generator.rb +19 -13
- data/{deprecated_generators → lib/generators}/graphiti/resource_generator.rb +43 -6
- data/{deprecated_generators → lib/generators}/graphiti/templates/index_request_spec.rb.erb +1 -1
- data/{deprecated_generators → lib/generators}/graphiti/templates/resource_reads_spec.rb.erb +6 -6
- data/{deprecated_generators → lib/generators}/graphiti/templates/show_request_spec.rb.erb +1 -1
- data/lib/graphiti/configuration.rb +2 -2
- data/lib/graphiti/error_serializers/conflict_request.rb +19 -0
- data/lib/graphiti/error_serializers/deprecated_constants.rb +48 -0
- data/lib/graphiti/error_serializers/invalid_request.rb +56 -0
- data/lib/graphiti/error_serializers/validation.rb +143 -0
- data/lib/graphiti/errors.rb +4 -23
- data/lib/graphiti/query.rb +1 -1
- data/lib/graphiti/rails/context.rb +33 -0
- data/lib/graphiti/rails/controller.rb +41 -0
- data/lib/graphiti/rails/debugging.rb +18 -0
- data/lib/graphiti/rails/exception_handlers.rb +77 -0
- data/lib/graphiti/rails/railtie.rb +139 -0
- data/lib/graphiti/rails/responders.rb +21 -0
- data/lib/graphiti/rails/test_helpers.rb +22 -0
- data/lib/graphiti/rails.rb +47 -29
- data/lib/graphiti/resource/configuration.rb +1 -0
- data/lib/graphiti/resource/interface.rb +2 -2
- data/lib/graphiti/resource/persistence.rb +14 -2
- data/lib/graphiti/resource/remote.rb +2 -2
- data/lib/graphiti/resource/sideloading.rb +1 -1
- data/lib/graphiti/resource.rb +13 -1
- data/lib/graphiti/responders.rb +7 -20
- data/lib/graphiti/schema.rb +5 -1
- data/lib/graphiti/schema_diff.rb +4 -0
- data/lib/graphiti/scope.rb +45 -37
- data/lib/graphiti/serializer.rb +6 -0
- data/lib/graphiti/sideload/belongs_to.rb +38 -5
- data/lib/graphiti/sideload/polymorphic_belongs_to.rb +27 -23
- data/lib/graphiti/sideload.rb +54 -35
- data/lib/graphiti/spec_helpers/errors.rb +73 -0
- data/lib/graphiti/spec_helpers/errors_proxy.rb +75 -0
- data/lib/graphiti/spec_helpers/helpers.rb +107 -0
- data/lib/graphiti/spec_helpers/node.rb +88 -0
- data/lib/graphiti/spec_helpers/rspec.rb +147 -0
- data/lib/graphiti/spec_helpers.rb +53 -0
- data/lib/graphiti/util/include_params.rb +2 -2
- data/lib/graphiti/util/persistence.rb +10 -11
- data/lib/graphiti/util/serializer_relationships.rb +41 -5
- data/lib/graphiti/version.rb +1 -1
- data/lib/graphiti-rails.rb +11 -0
- data/lib/graphiti.rb +34 -10
- data/lib/graphiti_errors.rb +11 -0
- data/lib/graphiti_spec_helpers/rspec.rb +3 -0
- data/lib/graphiti_spec_helpers.rb +11 -0
- data/lib/{graphiti/deprecated_tasks.rb → tasks/graphiti.rake} +6 -1
- data/package-lock.json +6199 -0
- data/package.json +5 -4
- data/website/.gitignore +20 -0
- data/website/README.md +43 -0
- data/website/docusaurus.config.js +141 -0
- data/website/package-lock.json +19474 -0
- data/website/package.json +46 -0
- data/website/sidebars.js +82 -0
- data/website/src/css/custom.css +58 -0
- data/website/src/pages/markdown-page.mdx +7 -0
- data/website/static/.nojekyll +0 -0
- data/website/static/1.13/2019/03/31/graphiti-1-0.html +205 -0
- data/website/static/1.13/2019/05/08/graphiti-1-1.html +212 -0
- data/website/static/1.13/2019/05/20/graphiti-1-2.html +214 -0
- data/website/static/1.13/2019/10/14/tutorial.html +198 -0
- data/website/static/1.13/CNAME +1 -0
- data/website/static/1.13/README.md +16 -0
- data/website/static/1.13/assets/css/syntax.css +60 -0
- 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 +9 -0
- 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 +1 -0
- data/website/static/1.13/assets/favicons/site.webmanifest +19 -0
- 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/gh.png +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/why.png +0 -0
- data/website/static/1.13/assets/js/highlight.pack.js +2 -0
- data/website/static/1.13/assets/main.css +15518 -0
- data/website/static/1.13/assets/main.css.map +1 -0
- data/website/static/1.13/bin/bundle +109 -0
- data/website/static/1.13/bin/jekyll +27 -0
- data/website/static/1.13/bin/kramdown +27 -0
- data/website/static/1.13/bin/listen +27 -0
- data/website/static/1.13/bin/rake +27 -0
- data/website/static/1.13/bin/rougify +27 -0
- data/website/static/1.13/bin/safe_yaml +27 -0
- data/website/static/1.13/bin/sass +27 -0
- data/website/static/1.13/bin/sass-convert +27 -0
- data/website/static/1.13/bin/scss +27 -0
- data/website/static/1.13/blog.html +259 -0
- data/website/static/1.13/cheatsheet.html +316 -0
- 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 +325 -0
- data/website/static/1.13/cookbooks/etags.md +0 -0
- data/website/static/1.13/cookbooks/hopping-relationships.html +324 -0
- 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 +510 -0
- data/website/static/1.13/features.html +249 -0
- data/website/static/1.13/feed.xml +106 -0
- data/website/static/1.13/guides/concepts/backends-and-models.html +467 -0
- data/website/static/1.13/guides/concepts/debugging.html +440 -0
- data/website/static/1.13/guides/concepts/endpoints.html +432 -0
- data/website/static/1.13/guides/concepts/error-handling.html +396 -0
- data/website/static/1.13/guides/concepts/links.html +501 -0
- data/website/static/1.13/guides/concepts/remote-resources.html +536 -0
- data/website/static/1.13/guides/concepts/resources.html +2176 -0
- data/website/static/1.13/guides/concepts/testing.html +1469 -0
- data/website/static/1.13/guides/getting-started/installation.html +420 -0
- data/website/static/1.13/guides/graphiti-rails-migration.html +242 -0
- data/website/static/1.13/guides/index.html +269 -0
- data/website/static/1.13/guides/overview.html +325 -0
- data/website/static/1.13/guides/upgrading-2-0.html +193 -0
- data/website/static/1.13/guides/upgrading.html +314 -0
- data/website/static/1.13/guides/vandal.html +282 -0
- data/website/static/1.13/guides/why.html +1121 -0
- data/website/static/1.13/index.html +72 -0
- data/website/static/1.13/js/authentication.html +295 -0
- data/website/static/1.13/js/ddau.html +238 -0
- data/website/static/1.13/js/extra-params.html +270 -0
- data/website/static/1.13/js/index.html +321 -0
- data/website/static/1.13/js/installation.html +637 -0
- data/website/static/1.13/js/introduction.html +257 -0
- data/website/static/1.13/js/middleware.html +318 -0
- data/website/static/1.13/js/reads/fieldsets.html +271 -0
- data/website/static/1.13/js/reads/filtering.html +289 -0
- data/website/static/1.13/js/reads/includes.html +260 -0
- data/website/static/1.13/js/reads/index.html +497 -0
- data/website/static/1.13/js/reads/nested-queries.html +353 -0
- data/website/static/1.13/js/reads/pagination.html +260 -0
- data/website/static/1.13/js/reads/sorting.html +265 -0
- data/website/static/1.13/js/reads/statistics.html +289 -0
- data/website/static/1.13/js/state-syncing.html +340 -0
- data/website/static/1.13/js/writes/deferred.html +296 -0
- data/website/static/1.13/js/writes/dirty-tracking.html +399 -0
- data/website/static/1.13/js/writes/index.html +391 -0
- data/website/static/1.13/js/writes/nested.html +330 -0
- data/website/static/1.13/js/writes/validations.html +272 -0
- data/website/static/1.13/quickstart.html +660 -0
- data/website/static/1.13/template +161 -0
- data/website/static/1.13/tutorial/index.html +250 -0
- data/website/static/1.13/tutorial/step_0.html +292 -0
- data/website/static/1.13/tutorial/step_1.html +517 -0
- data/website/static/1.13/tutorial/step_2.html +481 -0
- data/website/static/1.13/tutorial/step_3.html +323 -0
- data/website/static/1.13/tutorial/step_4.html +318 -0
- data/website/static/1.13/tutorial/step_5.html +265 -0
- data/website/static/1.13/tutorial/step_6.html +276 -0
- data/website/static/1.13/tutorial/step_7.html +390 -0
- data/website/static/1.13/tutorial/step_8.html +316 -0
- data/website/static/1.13/tutorial/step_9.html +365 -0
- 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 +1 -0
- data/website/static/img/undraw_docusaurus_mountain.svg +171 -0
- data/website/static/img/undraw_docusaurus_react.svg +170 -0
- data/website/static/img/undraw_docusaurus_tree.svg +40 -0
- metadata +245 -46
- data/gemfiles/rails_6.gemfile +0 -18
- data/gemfiles/rails_6_graphiti_rails.gemfile +0 -19
- data/gemfiles/rails_7.gemfile +0 -18
- data/gemfiles/rails_7_1_graphiti_rails.gemfile +0 -19
- data/gemfiles/rails_7_graphiti_rails.gemfile +0 -19
- data/lib/graphiti/railtie.rb +0 -121
- /data/{deprecated_generators → lib/generators}/graphiti/resource_test_generator.rb +0 -0
- /data/{deprecated_generators → lib/generators}/graphiti/templates/application_resource.rb.erb +0 -0
- /data/{deprecated_generators → lib/generators}/graphiti/templates/controller.rb.erb +0 -0
- /data/{deprecated_generators → lib/generators}/graphiti/templates/create_request_spec.rb.erb +0 -0
- /data/{deprecated_generators → lib/generators}/graphiti/templates/destroy_request_spec.rb.erb +0 -0
- /data/{deprecated_generators → lib/generators}/graphiti/templates/resource.rb.erb +0 -0
- /data/{deprecated_generators → lib/generators}/graphiti/templates/resource_writes_spec.rb.erb +0 -0
- /data/{deprecated_generators → lib/generators}/graphiti/templates/update_request_spec.rb.erb +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
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
|
+
<h1 id="upgrading-from-jsonapi-suite">Upgrading from JSONAPI Suite</h1>
|
|
84
|
+
|
|
85
|
+
<p>The early version of Graphiti was JSONAPI Suite. If you are a JSONAPI
|
|
86
|
+
Suite user, here’s how to upgrade your existing API.</p>
|
|
87
|
+
|
|
88
|
+
<p>The work here is mostly consolidating logic that currently lives in
|
|
89
|
+
multiple files into a single Resource, and rewriting specs. The good
|
|
90
|
+
news is that, because we emphasize full-stack integration tests, we can
|
|
91
|
+
perform the upgrade with confidence by ensuring our tests pass.</p>
|
|
92
|
+
|
|
93
|
+
<h3 id="before-you-start">Before You Start</h3>
|
|
94
|
+
|
|
95
|
+
<p>Begin by understanding Graphiti. Walk through the documentation and
|
|
96
|
+
<a href="https://github.com/graphiti-api/employee_directory">sample application</a> to get a feel for the new API. <a href="https://github.com/graphiti-api/employee_directory/blob/master/app/controllers/employees_controller.rb">Here’s a controller</a>.</p>
|
|
97
|
+
|
|
98
|
+
<p>There is no Swagger UI equivalent for Graphiti. Swagger is a
|
|
99
|
+
poor fit for graph APIs, and we instead rely on a custom Graphiti
|
|
100
|
+
Schema. Instead, check out <a href="/1.13/guides/vandal">Vandal</a>.</p>
|
|
101
|
+
|
|
102
|
+
<h3 id="setup">Setup</h3>
|
|
103
|
+
|
|
104
|
+
<p>Start by removing the gems <code class="language-plaintext highlighter-rouge">jsonapi_suite</code>, <code class="language-plaintext highlighter-rouge">jsonapi-rails</code>,
|
|
105
|
+
<code class="language-plaintext highlighter-rouge">jsonapi_swagger_helpers</code>, and <code class="language-plaintext highlighter-rouge">swagger-diff</code>. You’ll eventually remove
|
|
106
|
+
<code class="language-plaintext highlighter-rouge">jsonapi_spec_helpers</code>, but keep it for now.</p>
|
|
107
|
+
|
|
108
|
+
<p>Add gems <code class="language-plaintext highlighter-rouge">graphiti</code>, <code class="language-plaintext highlighter-rouge">graphiti_spec_helpers</code> and <code class="language-plaintext highlighter-rouge">responders</code>. See the
|
|
109
|
+
<a href="https://github.com/graphiti-api/employee_directory/blob/master/Gemfile">Sample App Gemfile</a>.</p>
|
|
110
|
+
|
|
111
|
+
<p>Move <code class="language-plaintext highlighter-rouge">spec/api</code> to <code class="language-plaintext highlighter-rouge">spec/legacy</code>.</p>
|
|
112
|
+
|
|
113
|
+
<p>Remove <code class="language-plaintext highlighter-rouge">config/initializers/strong_resources.rb</code>,
|
|
114
|
+
<code class="language-plaintext highlighter-rouge">config/initializers/jsonapi.rb</code>, <code class="language-plaintext highlighter-rouge">app/controllers/docs_controller.rb</code>,
|
|
115
|
+
and the Swagger UI that lives under <code class="language-plaintext highlighter-rouge">public</code>.</p>
|
|
116
|
+
|
|
117
|
+
<p>Remove swagger helpers from <code class="language-plaintext highlighter-rouge">Rakefile</code>.</p>
|
|
118
|
+
|
|
119
|
+
<p>Grep for <code class="language-plaintext highlighter-rouge">JsonapiErrorable</code> and change to <code class="language-plaintext highlighter-rouge">GraphitiErrors</code>.</p>
|
|
120
|
+
|
|
121
|
+
<p>Make <code class="language-plaintext highlighter-rouge">spec/rails_helper.rb</code> correct (though keep <code class="language-plaintext highlighter-rouge">jsonapi_spec_helpers</code>
|
|
122
|
+
for now). <a href="https://github.com/graphiti-api/employee_directory/blob/master/spec/rails_helper.rb">See sample</a>.</p>
|
|
123
|
+
|
|
124
|
+
<p>At this point, running your specs should give you a lot of errors like
|
|
125
|
+
<code class="language-plaintext highlighter-rouge">"index" not found</code>.</p>
|
|
126
|
+
|
|
127
|
+
<h3 id="upgrading">Upgrading</h3>
|
|
128
|
+
|
|
129
|
+
<p>Upgrade your <a href="https://github.com/graphiti-api/employee_directory/blob/master/app/controllers/application_controller.rb">ApplicationController</a>.</p>
|
|
130
|
+
|
|
131
|
+
<p>Upgrade your <a href="https://github.com/graphiti-api/employee_directory/blob/master/app/resources/application_resource.rb">ApplicationResource</a>.</p>
|
|
132
|
+
|
|
133
|
+
<ul>
|
|
134
|
+
<li>Note that this references <code class="language-plaintext highlighter-rouge">Rails.application.routes.default_url_options[:host]</code>. That’s set in <a href="https://github.com/graphiti-api/employee_directory/blob/master/config/application.rb#L22">config/application.rb</a>.</li>
|
|
135
|
+
<li>Note the <code class="language-plaintext highlighter-rouge">endpoint_namespace</code>. Make this match your current routes.</li>
|
|
136
|
+
<li>Reference <code class="language-plaintext highlighter-rouge">ApplicationResource.endpoint_namespace</code> <a href="https://github.com/graphiti-api/employee_directory/blob/master/config/routes.rb#L2">in your routes file</a>.</li>
|
|
137
|
+
</ul>
|
|
138
|
+
|
|
139
|
+
<p>Begin rewriting your Resources. Go through <code class="language-plaintext highlighter-rouge">spec/payloads</code> and add these
|
|
140
|
+
attributes/types to the Resource. Remember to mark these as <code class="language-plaintext highlighter-rouge">only:
|
|
141
|
+
[:readable]</code>, or <code class="language-plaintext highlighter-rouge">writable: false</code>, etc. Look at
|
|
142
|
+
<code class="language-plaintext highlighter-rouge">config/initializers/strong_resources.rb</code> to see if an attribute should
|
|
143
|
+
be writable.</p>
|
|
144
|
+
|
|
145
|
+
<p>Rewrite custom <code class="language-plaintext highlighter-rouge">allow_filters</code>. If it’s a one-liner, just make sure
|
|
146
|
+
there is a corresponding attribute. If there is custom logic:</p>
|
|
147
|
+
|
|
148
|
+
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="n">allow_filter</span> <span class="ss">:foo</span> <span class="k">do</span> <span class="o">|</span><span class="n">scope</span><span class="p">,</span> <span class="n">value</span><span class="o">|</span>
|
|
149
|
+
<span class="c1"># ... code ...</span>
|
|
150
|
+
<span class="k">end</span>
|
|
151
|
+
|
|
152
|
+
<span class="c1"># BECOMES</span>
|
|
153
|
+
|
|
154
|
+
<span class="n">filter</span> <span class="ss">:foo</span><span class="p">,</span> <span class="ss">:string</span><span class="p">,</span> <span class="ss">only: </span><span class="p">[</span><span class="ss">:eq</span><span class="p">],</span> <span class="ss">single: </span><span class="kp">true</span> <span class="k">do</span>
|
|
155
|
+
<span class="n">eq</span> <span class="k">do</span> <span class="o">|</span><span class="n">scope</span><span class="p">,</span> <span class="n">value</span><span class="o">|</span>
|
|
156
|
+
<span class="c1"># ... code ...</span>
|
|
157
|
+
<span class="k">end</span>
|
|
158
|
+
<span class="k">end</span></code></pre></figure>
|
|
159
|
+
|
|
160
|
+
<p>Two things about filters: by default, <code class="language-plaintext highlighter-rouge">value</code> is now always array. Pass
|
|
161
|
+
<code class="language-plaintext highlighter-rouge">single: true</code> if your logic only supports a single value. Also: a
|
|
162
|
+
filter with a given type now comes with operators - <code class="language-plaintext highlighter-rouge">string</code> gets
|
|
163
|
+
<code class="language-plaintext highlighter-rouge">prefix</code>, <code class="language-plaintext highlighter-rouge">suffix</code>, etc. If you don’t support these, limit operations
|
|
164
|
+
with <code class="language-plaintext highlighter-rouge">only:</code>.</p>
|
|
165
|
+
|
|
166
|
+
<p>Note that we now support multiple content types for read requests:
|
|
167
|
+
<code class="language-plaintext highlighter-rouge">.json</code> and <code class="language-plaintext highlighter-rouge">.xml</code>. If you have any clients explicitly putting <code class="language-plaintext highlighter-rouge">.json</code>
|
|
168
|
+
at the end of the URL, they are now going to get a simple JSON response
|
|
169
|
+
instead of JSONAPI. Avoid the responders gem if you don’t want this.</p>
|
|
170
|
+
|
|
171
|
+
<p>You may want to move some persistence logic to <a href="/1.13/guides/concepts/resources#side-effects">before_commit</a>.</p>
|
|
172
|
+
|
|
173
|
+
<p>Resources now have <a href="/1.13/guides/concepts/resources#basescope">#base_scope</a>. If you previously were using <code class="language-plaintext highlighter-rouge">default_filter</code> or passing in a custom scope in your controller, consider moving to <code class="language-plaintext highlighter-rouge">base_scope</code>:</p>
|
|
174
|
+
|
|
175
|
+
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="c1"># app/resources/post_resource.rb</span>
|
|
176
|
+
<span class="k">def</span> <span class="nf">base_scope</span>
|
|
177
|
+
<span class="no">Post</span><span class="p">.</span><span class="nf">active</span>
|
|
178
|
+
<span class="k">end</span></code></pre></figure>
|
|
179
|
+
|
|
180
|
+
<p>If you have manual sideloading logic with scope, it is <strong>highly
|
|
181
|
+
recommended</strong> you rewriting using <code class="language-plaintext highlighter-rouge">params</code> - see <a href="/1.13/guides/concepts/resources#relationships">relationship docs</a>. If you <strong>do</strong> still need <code class="language-plaintext highlighter-rouge">scope</code>, it now yields the parent ids as the first argument and the actual parent models as the second.</p>
|
|
182
|
+
|
|
183
|
+
<p>Finally, you are encouraged to avoid overriding <code class="language-plaintext highlighter-rouge">create/update/destroy</code>
|
|
184
|
+
directly. Instead, override <code class="language-plaintext highlighter-rouge">build</code>, <code class="language-plaintext highlighter-rouge">save</code>, and <code class="language-plaintext highlighter-rouge">delete</code>, and use
|
|
185
|
+
<a href="/1.13/guides/concepts/resources#persistence-lifecycle-hooks">Persistence Lifecycle
|
|
186
|
+
Hooks</a>.</p>
|
|
187
|
+
|
|
188
|
+
<p>At this point, get all your <code class="language-plaintext highlighter-rouge">spec/legacy</code> specs passing.</p>
|
|
189
|
+
|
|
190
|
+
<p>When you’re done, generate the new <a href="/1.13/guides/concepts/testing">Resource and API Specs</a>. Note that much of this is syntax changes, you can copy/paste large amounts of logic from <code class="language-plaintext highlighter-rouge">spec/legacy</code>. To ease this process, try <code class="language-plaintext highlighter-rouge">rails g graphiti:api_test PostResource</code> and <code class="language-plaintext highlighter-rouge">rails g graphiti:resource_test PostResource</code>.</p>
|
|
191
|
+
|
|
192
|
+
<p>You should now have the upgraded <strong>and</strong> legacy test suite working. We
|
|
193
|
+
can now remove the legacy specs:</p>
|
|
194
|
+
|
|
195
|
+
<ul>
|
|
196
|
+
<li>Remove <code class="language-plaintext highlighter-rouge">jsonapi_spec_helpers</code> gem</li>
|
|
197
|
+
<li><code class="language-plaintext highlighter-rouge">rm -rf spec/payloads</code></li>
|
|
198
|
+
<li><code class="language-plaintext highlighter-rouge">rm -rf spec/legacy</code></li>
|
|
199
|
+
</ul>
|
|
200
|
+
|
|
201
|
+
<p>And you’re done! Deploy to a staging environment and verify your API
|
|
202
|
+
supports all your real-world scenarios.</p>
|
|
203
|
+
|
|
204
|
+
<h3 id="persistence">Persistence</h3>
|
|
205
|
+
|
|
206
|
+
<p>Though you can get specs passing with your existing <code class="language-plaintext highlighter-rouge">create</code>, <code class="language-plaintext highlighter-rouge">update</code>,
|
|
207
|
+
etc, try to rewrite them using hooks. It’s no longer considered a best
|
|
208
|
+
practice to override these methods because you’ll be bypassing hooks.
|
|
209
|
+
Instead, add hooks and override <code class="language-plaintext highlighter-rouge">def save(model)</code> if you need to.</p>
|
|
210
|
+
|
|
211
|
+
<h3 id="gotchas">Gotchas</h3>
|
|
212
|
+
|
|
213
|
+
<p>We use <code class="language-plaintext highlighter-rouge">respond_with</code> in read operations and <code class="language-plaintext highlighter-rouge">render jsonapi:</code> in write
|
|
214
|
+
operations. This is because the <code class="language-plaintext highlighter-rouge">responders</code> gem bypasses renderers for
|
|
215
|
+
<code class="language-plaintext highlighter-rouge">PUT</code>, and a few other minor issues.</p>
|
|
216
|
+
|
|
217
|
+
<p><br />
|
|
218
|
+
<br /></p>
|
|
219
|
+
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
</main>
|
|
223
|
+
<div class="main-footer main-footer--dark">
|
|
224
|
+
<div class="container">
|
|
225
|
+
<div class="row">
|
|
226
|
+
<div class="col-sm-4 menu">
|
|
227
|
+
<h3>Overview</h3>
|
|
228
|
+
<ul>
|
|
229
|
+
<li>
|
|
230
|
+
<a href="/1.13/quickstart">Quickstart</a>
|
|
231
|
+
</li>
|
|
232
|
+
<li>
|
|
233
|
+
<a href="/1.13/tutorial">Tutorial</a>
|
|
234
|
+
</li>
|
|
235
|
+
<li>
|
|
236
|
+
<a href="/1.13/guides">Guides</a>
|
|
237
|
+
</li>
|
|
238
|
+
</ul>
|
|
239
|
+
</div>
|
|
240
|
+
<div class="col-sm-4 menu">
|
|
241
|
+
<h3>Contact</h3>
|
|
242
|
+
<ul>
|
|
243
|
+
<li>
|
|
244
|
+
<a target="_blank" href="https://discord.gg/wgqkMBsSRV">Discord Chat</a>
|
|
245
|
+
</li>
|
|
246
|
+
<li>
|
|
247
|
+
<a href="mailto:richmolj@gmail.com">Email</a>
|
|
248
|
+
</li>
|
|
249
|
+
</ul>
|
|
250
|
+
</div>
|
|
251
|
+
<div class="col-sm-4 menu">
|
|
252
|
+
<h3>Related</h3>
|
|
253
|
+
<ul>
|
|
254
|
+
<li>
|
|
255
|
+
<a target="_blank" href="http://jsonapi.org">JSONAPI Spec</a>
|
|
256
|
+
</li>
|
|
257
|
+
<li>
|
|
258
|
+
<a target="_blank" href="http://jsonapi-rb.org">jsonapi-rb</a>
|
|
259
|
+
</li>
|
|
260
|
+
<li>
|
|
261
|
+
<a target="_blank" href="https://vuejs.org/">VueJS</a>
|
|
262
|
+
</li>
|
|
263
|
+
</ul>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
<script type="text/javascript">
|
|
270
|
+
$(function () {
|
|
271
|
+
|
|
272
|
+
var flipTabs = function() {
|
|
273
|
+
var isTS = true;
|
|
274
|
+
if (localStorage.getItem('js-lang') === 'javascript') {
|
|
275
|
+
isTS = false;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
$('.code-tabs').each(function(index, el) {
|
|
279
|
+
if (isTS) {
|
|
280
|
+
console.log('hiding js');
|
|
281
|
+
$($(el).children()[1]).hide();
|
|
282
|
+
$($(el).children()[0]).show();
|
|
283
|
+
} else {
|
|
284
|
+
console.log('hiding ts');
|
|
285
|
+
$($(el).children()[0]).hide();
|
|
286
|
+
$($(el).children()[1]).show();
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
if (isTS) {
|
|
291
|
+
$('.tab.typescript').addClass('active');
|
|
292
|
+
$('.tab.javascript').removeClass('active');
|
|
293
|
+
} else {
|
|
294
|
+
$('.tab.typescript').removeClass('active');
|
|
295
|
+
$('.tab.javascript').addClass('active');
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
$('.tab').click(function() {
|
|
300
|
+
if ($(this).hasClass('typescript')) {
|
|
301
|
+
localStorage.setItem('js-lang', 'typescript');
|
|
302
|
+
} else {
|
|
303
|
+
localStorage.setItem('js-lang', 'javascript');
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
flipTabs();
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
flipTabs();
|
|
310
|
+
})
|
|
311
|
+
</script>
|
|
312
|
+
|
|
313
|
+
</body>
|
|
314
|
+
</html>
|
|
@@ -0,0 +1,282 @@
|
|
|
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
|
+
<h1 id="vandal">Vandal</h1>
|
|
84
|
+
|
|
85
|
+
<p>Vandal is the Graphiti UI. It’s helpful for exploring data, testing and
|
|
86
|
+
generating URLs. To take Vandal for a spin, <a href="https://jsonapi-employee-directory.herokuapp.com/vandal">view our sample app</a> (<em>initial load may take a second</em>).</p>
|
|
87
|
+
|
|
88
|
+
<p><br />
|
|
89
|
+
<img width="100%" src="https://user-images.githubusercontent.com/55264/50740077-61dbe880-11b7-11e9-8919-34e1a48dd630.png" /></p>
|
|
90
|
+
|
|
91
|
+
<div class="toc col-md-3">
|
|
92
|
+
|
|
93
|
+
<ul>
|
|
94
|
+
<li>1 <a href="#installation">Installation</a>
|
|
95
|
+
<ul>
|
|
96
|
+
<li><a href="#installing-via-template">Via the Template</a></li>
|
|
97
|
+
<li><a href="#installing-via-gem">Via the Gem</a></li>
|
|
98
|
+
<li><a href="#manual-installation">Manual</a></li>
|
|
99
|
+
</ul>
|
|
100
|
+
</li>
|
|
101
|
+
<li>2 <a href="#usage">Usage</a></li>
|
|
102
|
+
</ul>
|
|
103
|
+
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<div class="col-md-8">
|
|
107
|
+
|
|
108
|
+
<a class="anchor" id="installation" />
|
|
109
|
+
<a class="header" href="#installation">
|
|
110
|
+
<h2>
|
|
111
|
+
1 Installation
|
|
112
|
+
</h2>
|
|
113
|
+
</a>
|
|
114
|
+
|
|
115
|
+
<a class="anchor" id="installing-via-template" />
|
|
116
|
+
<a class="header" href="#installing-via-template">
|
|
117
|
+
<h3>
|
|
118
|
+
1.1 Installing via Template
|
|
119
|
+
</h3>
|
|
120
|
+
</a>
|
|
121
|
+
|
|
122
|
+
<p>If you ran our <a href="/1.13/guides/getting-started/installation">application template</a>,
|
|
123
|
+
you already have Vandal installed. Check your routes to see it mounted.</p>
|
|
124
|
+
|
|
125
|
+
<a class="anchor" id="installing-via-gem" />
|
|
126
|
+
<a class="header" href="#installing-via-gem">
|
|
127
|
+
<h3>
|
|
128
|
+
1.2 Installing via Gem
|
|
129
|
+
</h3>
|
|
130
|
+
</a>
|
|
131
|
+
|
|
132
|
+
<ul>
|
|
133
|
+
<li>Add the <code class="language-plaintext highlighter-rouge">vandal_ui</code> gem.</li>
|
|
134
|
+
<li>Run <code class="language-plaintext highlighter-rouge">rake vandal:install</code></li>
|
|
135
|
+
<li>Mount the engine:</li>
|
|
136
|
+
</ul>
|
|
137
|
+
|
|
138
|
+
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="c1"># config/routes.rb</span>
|
|
139
|
+
<span class="n">scope</span> <span class="ss">path: </span><span class="no">ApplicationResource</span><span class="p">.</span><span class="nf">endpoint_namespace</span><span class="p">,</span> <span class="ss">defaults: </span><span class="p">{</span> <span class="ss">format: :jsonapi</span> <span class="p">}</span> <span class="k">do</span>
|
|
140
|
+
<span class="c1"># ... routes ...</span>
|
|
141
|
+
<span class="n">mount</span> <span class="no">VandalUi</span><span class="o">::</span><span class="no">Engine</span><span class="p">,</span> <span class="ss">at: </span><span class="s1">'/vandal'</span>
|
|
142
|
+
<span class="k">end</span></code></pre></figure>
|
|
143
|
+
|
|
144
|
+
<p>That’s it! Vandal will dynamically generate a schema at <code class="language-plaintext highlighter-rouge"><api_namespace>/vandal/schema.json</code>, and you can view the UI at <code class="language-plaintext highlighter-rouge"><api_namespace>/vandal</code>.</p>
|
|
145
|
+
|
|
146
|
+
<a class="anchor" id="manual-installation" />
|
|
147
|
+
<a class="header" href="#manual-installation">
|
|
148
|
+
<h3>
|
|
149
|
+
1.3 Manual Installation
|
|
150
|
+
</h3>
|
|
151
|
+
</a>
|
|
152
|
+
|
|
153
|
+
<p><a href="https://github.com/graphiti-api/vandal">Vandal</a> is a VueJS
|
|
154
|
+
application. Just grab the <a href="https://github.com/graphiti-api/vandal/tree/master/dist">dist files</a> and put them anywhere you’d like.</p>
|
|
155
|
+
|
|
156
|
+
<p>Note that <code class="language-plaintext highlighter-rouge">index.html</code> has a placeholder, <code class="language-plaintext highlighter-rouge">__SCHEMA_PATH__</code>. Replace
|
|
157
|
+
this with a URL hosting your schema, and you’ll be good to go.</p>
|
|
158
|
+
|
|
159
|
+
<a class="anchor" id="usage" />
|
|
160
|
+
<a class="header" href="#usage">
|
|
161
|
+
<h2>
|
|
162
|
+
2 Usage
|
|
163
|
+
</h2>
|
|
164
|
+
</a>
|
|
165
|
+
|
|
166
|
+
<p>First, make sure your schema is being correctly generated. You should
|
|
167
|
+
see Vandal make a request something like <code class="language-plaintext highlighter-rouge">/vandal/schema.json</code> - make
|
|
168
|
+
sure that looks correct. If it doesn’t, you may need to bounce your
|
|
169
|
+
server.</p>
|
|
170
|
+
|
|
171
|
+
<p>After selecting an endpoint, use the left rail to configure your
|
|
172
|
+
request. Click a relationship once to include it in the response.
|
|
173
|
+
If a relationship is included, you can click any row in the table to
|
|
174
|
+
view related data.</p>
|
|
175
|
+
|
|
176
|
+
<p>Click a relationship twice and you can configure the deep query of
|
|
177
|
+
the associated Resource. In other words, if you’re fetching Posts and
|
|
178
|
+
Comments, click <code class="language-plaintext highlighter-rouge">comments</code> twice to say things like “only active
|
|
179
|
+
comments should be returned”.</p>
|
|
180
|
+
|
|
181
|
+
<p>When you hit ‘submit’, the top URL bar will change to reflect your query
|
|
182
|
+
and results will show in the center table.</p>
|
|
183
|
+
|
|
184
|
+
<p><br />
|
|
185
|
+
<br /></p>
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</main>
|
|
191
|
+
<div class="main-footer main-footer--dark">
|
|
192
|
+
<div class="container">
|
|
193
|
+
<div class="row">
|
|
194
|
+
<div class="col-sm-4 menu">
|
|
195
|
+
<h3>Overview</h3>
|
|
196
|
+
<ul>
|
|
197
|
+
<li>
|
|
198
|
+
<a href="/1.13/quickstart">Quickstart</a>
|
|
199
|
+
</li>
|
|
200
|
+
<li>
|
|
201
|
+
<a href="/1.13/tutorial">Tutorial</a>
|
|
202
|
+
</li>
|
|
203
|
+
<li>
|
|
204
|
+
<a href="/1.13/guides">Guides</a>
|
|
205
|
+
</li>
|
|
206
|
+
</ul>
|
|
207
|
+
</div>
|
|
208
|
+
<div class="col-sm-4 menu">
|
|
209
|
+
<h3>Contact</h3>
|
|
210
|
+
<ul>
|
|
211
|
+
<li>
|
|
212
|
+
<a target="_blank" href="https://discord.gg/wgqkMBsSRV">Discord Chat</a>
|
|
213
|
+
</li>
|
|
214
|
+
<li>
|
|
215
|
+
<a href="mailto:richmolj@gmail.com">Email</a>
|
|
216
|
+
</li>
|
|
217
|
+
</ul>
|
|
218
|
+
</div>
|
|
219
|
+
<div class="col-sm-4 menu">
|
|
220
|
+
<h3>Related</h3>
|
|
221
|
+
<ul>
|
|
222
|
+
<li>
|
|
223
|
+
<a target="_blank" href="http://jsonapi.org">JSONAPI Spec</a>
|
|
224
|
+
</li>
|
|
225
|
+
<li>
|
|
226
|
+
<a target="_blank" href="http://jsonapi-rb.org">jsonapi-rb</a>
|
|
227
|
+
</li>
|
|
228
|
+
<li>
|
|
229
|
+
<a target="_blank" href="https://vuejs.org/">VueJS</a>
|
|
230
|
+
</li>
|
|
231
|
+
</ul>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
<script type="text/javascript">
|
|
238
|
+
$(function () {
|
|
239
|
+
|
|
240
|
+
var flipTabs = function() {
|
|
241
|
+
var isTS = true;
|
|
242
|
+
if (localStorage.getItem('js-lang') === 'javascript') {
|
|
243
|
+
isTS = false;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
$('.code-tabs').each(function(index, el) {
|
|
247
|
+
if (isTS) {
|
|
248
|
+
console.log('hiding js');
|
|
249
|
+
$($(el).children()[1]).hide();
|
|
250
|
+
$($(el).children()[0]).show();
|
|
251
|
+
} else {
|
|
252
|
+
console.log('hiding ts');
|
|
253
|
+
$($(el).children()[0]).hide();
|
|
254
|
+
$($(el).children()[1]).show();
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
if (isTS) {
|
|
259
|
+
$('.tab.typescript').addClass('active');
|
|
260
|
+
$('.tab.javascript').removeClass('active');
|
|
261
|
+
} else {
|
|
262
|
+
$('.tab.typescript').removeClass('active');
|
|
263
|
+
$('.tab.javascript').addClass('active');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
$('.tab').click(function() {
|
|
268
|
+
if ($(this).hasClass('typescript')) {
|
|
269
|
+
localStorage.setItem('js-lang', 'typescript');
|
|
270
|
+
} else {
|
|
271
|
+
localStorage.setItem('js-lang', 'javascript');
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
flipTabs();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
flipTabs();
|
|
278
|
+
})
|
|
279
|
+
</script>
|
|
280
|
+
|
|
281
|
+
</body>
|
|
282
|
+
</html>
|