graphql-persisted_documents 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +9 -114
  4. data/Rakefile +37 -2
  5. data/app/controllers/graphql/persisted_documents/application_controller.rb +6 -0
  6. data/app/controllers/graphql/persisted_documents/persisted_documents_controller.rb +36 -0
  7. data/config/routes.rb +3 -0
  8. data/lib/graphql/persisted_documents/engine.rb +11 -0
  9. data/lib/graphql/persisted_documents/persister.rb +7 -6
  10. data/lib/graphql/persisted_documents/version.rb +1 -1
  11. data/lib/graphql/persisted_documents.rb +1 -4
  12. data/lib/tasks/graphql/persisted_documents_tasks.rake +4 -0
  13. data/spec/controllers/persisted_documents_controller_spec.rb +85 -0
  14. data/spec/dummy/Rakefile +6 -0
  15. data/spec/dummy/app/assets/config/manifest.js +5 -0
  16. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  17. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  18. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  19. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  20. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  21. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  22. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  23. data/spec/dummy/app/jobs/application_job.rb +2 -0
  24. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  25. data/spec/dummy/app/models/application_record.rb +3 -0
  26. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  27. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  28. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  29. data/spec/dummy/bin/bundle +3 -0
  30. data/spec/dummy/bin/rails +4 -0
  31. data/spec/dummy/bin/rake +4 -0
  32. data/spec/dummy/bin/setup +34 -0
  33. data/spec/dummy/bin/update +29 -0
  34. data/spec/dummy/config/application.rb +15 -0
  35. data/spec/dummy/config/boot.rb +5 -0
  36. data/spec/dummy/config/cable.yml +9 -0
  37. data/spec/dummy/config/database.yml +25 -0
  38. data/spec/dummy/config/environment.rb +5 -0
  39. data/spec/dummy/config/environments/development.rb +54 -0
  40. data/spec/dummy/config/environments/production.rb +86 -0
  41. data/spec/dummy/config/environments/test.rb +42 -0
  42. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  43. data/spec/dummy/config/initializers/assets.rb +11 -0
  44. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  45. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  46. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  47. data/spec/dummy/config/initializers/inflections.rb +16 -0
  48. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  49. data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
  50. data/spec/dummy/config/initializers/session_store.rb +3 -0
  51. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  52. data/spec/dummy/config/locales/en.yml +23 -0
  53. data/spec/dummy/config/puma.rb +47 -0
  54. data/spec/dummy/config/routes.rb +3 -0
  55. data/spec/dummy/config/secrets.yml +22 -0
  56. data/spec/dummy/config/spring.rb +6 -0
  57. data/spec/dummy/config.ru +5 -0
  58. data/spec/dummy/db/test.sqlite3 +0 -0
  59. data/spec/dummy/log/test.log +203 -0
  60. data/spec/dummy/public/404.html +67 -0
  61. data/spec/dummy/public/422.html +67 -0
  62. data/spec/dummy/public/500.html +66 -0
  63. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  64. data/spec/dummy/public/apple-touch-icon.png +0 -0
  65. data/spec/dummy/public/favicon.ico +0 -0
  66. data/spec/rails_helper.rb +15 -0
  67. data/spec/spec_helper.rb +10 -0
  68. data/spec/support/test_schema.rb +11 -0
  69. metadata +147 -51
  70. data/.gitignore +0 -9
  71. data/CODE_OF_CONDUCT.md +0 -49
  72. data/Gemfile +0 -4
  73. data/LICENSE.txt +0 -21
  74. data/bin/console +0 -14
  75. data/bin/setup +0 -8
  76. data/graphql-persisted_documents.gemspec +0 -28
  77. data/lib/graphql/persisted_documents/rack.rb +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4705b7ffafbf43fd6313d0dc28eab8bec977b5ce
4
- data.tar.gz: 9a90cfbd553bcc4d473afe7cd194bb0959519f9f
3
+ metadata.gz: 88182d39575df6439d1f3a31327b67747c2de106
4
+ data.tar.gz: 1a3f507675a50d2b07681c34dc50fc4936ada5ee
5
5
  SHA512:
6
- metadata.gz: be981aae45332255e1b938344c8612b3178a16c497d3c33ad788c7d788d6cb7125dec48093c353b1637ca7e48e4cef8dba5aaec609df1d634a636441fd383490
7
- data.tar.gz: df1dec550f99cc3231aadd5dcca47148da219a43ab97bdc66492ea8a6eec596d2d03013d67ad04278fd8d6aa17a3252e34023751550b810049262aad665abed5
6
+ metadata.gz: 5ede97c6586c9294ff780ea232f495dbd3f719e4958b6fae74c81d18947ee28da2a2fab9f8b06c4563e5da3054228aa5bbd626575745ed43304e52d701d00512
7
+ data.tar.gz: 8db10fd68a72ff0192cae40aa39dedcbe22b228f64c8ab6bb30347c497b28749a937a9f40e802b01345d08d8deb010e9100172fab7710eebcd8a88d3a052e7fb
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,19 +1,10 @@
1
1
  # Graphql::PersistedDocuments
2
+ Short description and motivation.
2
3
 
3
- ### What is a GraphQL Document ?
4
-
5
- From the GraphQL spec:
6
-
7
- > A GraphQL document is defined as a syntactic grammar where terminal symbols are tokens (indivisible lexical units). These tokens are defined in a lexical grammar which matches patterns of source characters (defined by a double‐colon ::)
8
-
9
- ### Persisted Documents
10
-
11
- In most client side applications, the GraphQL requests are static. There is a limited set of them in an app and they chances are they wont change during the lifetime of the app. If they are not going to change, why not cache them server side, and simply call them by an id instead of sending a potentially huge query server side each time ?
12
-
13
- This is what Graphql::PersistedDocuments allows you to do. At build time / deploy time, a client side can send all it's documents to a special endpoint, called `/persist` in this case. The GraphQL backend simply returns a `document_id` which allows every client side running application to call the server using an id instead of a full query_stirng.
4
+ ## Usage
5
+ How to use my plugin.
14
6
 
15
7
  ## Installation
16
-
17
8
  Add this line to your application's Gemfile:
18
9
 
19
10
  ```ruby
@@ -21,113 +12,17 @@ gem 'graphql-persisted_documents'
21
12
  ```
22
13
 
23
14
  And then execute:
24
-
25
- $ bundle
26
-
27
- Or install it yourself as:
28
-
29
- $ gem install graphql-persisted_documents
30
-
31
- ## Usage
32
-
33
- `GraphQL::PersistedDocuments` is simply a Rack Middleware defined as `Graphql::PersistedDocuments::Rack`. To use it in Rails for example:
34
-
35
- ```ruby
36
- module YourApp
37
- class Application < Rails::Application
38
-
39
- # ...
40
-
41
- # Rails 3/4
42
- config.middleware.insert_before 0, "Graphql::PersistedDocuments::Rack"
43
-
44
- # Rails 5
45
- config.middleware.insert_before 0, Rack::Cors
46
- end
47
- end
15
+ ```bash
16
+ $ bundle
48
17
  ```
49
18
 
50
- ## Configuring
51
-
52
- The middleware currently required two things to be defined in the config:
53
-
54
- - `config.schema`: A GraphQL Schema, defined by the `graphql` gem.
55
- - `config.persit_validated_document`: An object that responds to `call`, which returns an id in exchange of a parsed GraphQL Document.
56
-
57
- To configure, for example in a Rails app:
58
-
59
- ```ruby
60
- Graphql::PersistedDocuments.configure do |config|
61
- config.schema = ShopSchema
62
- config.persist_validated_document = lambda do |document|
63
- uuid = SecureRandom.uuid
64
- Rails.cache.write(uuid, document)
65
- uuid
66
- end
67
- end
68
- ```
69
-
70
- ## Using with Rails
71
-
72
- When using with `rails` and `graphql` gems. We can simply accept a `document_id` as a param, as well as the standard `query` param.
73
-
74
- If we receive a `document_id`, we can retrieve that id from a store, cache, database, depending on how you implemented `persist_validated_document`.
75
-
76
- Example controller:
77
-
78
-
79
- ```ruby
80
- class GraphqlController < ApplicationController
81
- def execute
82
- query_string = params[:query]
83
- document_id = params[:document_id]
84
- variables = params[:variables]
85
-
86
- raise SomeGraphQLError unless query_string || document_id
87
-
88
- if document_id
89
- result = execute_from_persisted_document(document_id, variables)
90
- else
91
- result = execute_from_query_string(query_string, variables)
92
- end
93
-
94
- render json: result
95
- end
96
-
97
- private
98
-
99
- def execute_from_query_string(query_string, variables)
100
- MySchema.execute(query_string, variables: variables)
101
- end
102
-
103
- def execute_from_persisted_document(document_id, variables)
104
- persisted_document = get_persisted_document(document_id)
105
- MySchema.execute(document: persisted_document, variables: variables)
106
- end
107
-
108
- def get_persisted_document(document_id)
109
- Rails.cache.fetch(document_id)
110
- end
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install graphql-persisted_documents
111
22
  ```
112
23
 
113
- ## Development
114
-
115
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
116
-
117
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
118
-
119
24
  ## Contributing
120
-
121
- Bug reports and pull requests are welcome on GitHub at https://github.com/xuorig/graphql-persisted_documents. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
122
-
123
- ## TODO
124
-
125
- - [ ] Better error messages
126
- - [ ] Allow custom path
127
- - [ ] Add unit tests for persister
128
-
25
+ Contribution directions go here.
129
26
 
130
27
  ## License
131
-
132
28
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
133
-
data/Rakefile CHANGED
@@ -1,2 +1,37 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Graphql::PersistedDocuments'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,6 @@
1
+ module Graphql
2
+ module PersistedDocuments
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,36 @@
1
+ module Graphql
2
+ module PersistedDocuments
3
+ class PersistedDocumentsController < ApplicationController
4
+ def persist
5
+ document = params[:document]
6
+
7
+ unless document
8
+ render_errors(['Missing required argument document'], status: 422)
9
+ return
10
+ end
11
+
12
+ persister = Persister.new(document)
13
+ document_id = persister.persist
14
+
15
+ render json: { document_id: document_id }, status: :ok
16
+
17
+ rescue Persister::ParseError
18
+ render_errors(['Unable to parse document'], status: 422)
19
+ rescue Persister::InvalidDocumentError
20
+ render_errors(persister.errors, status: 422)
21
+ rescue Persister::MissingPersistValidatedDocumentError
22
+ render_errors(['persist_validated_document must be defined in config'])
23
+ end
24
+
25
+ private
26
+
27
+ def render_errors(messages, status: 400)
28
+ response = {
29
+ errors: messages.map { |msg| { message: msg } }
30
+ }
31
+
32
+ render json: response, status: status
33
+ end
34
+ end
35
+ end
36
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Graphql::PersistedDocuments::Engine.routes.draw do
2
+ post '/persist', to: 'persisted_documents#persist'
3
+ end
@@ -0,0 +1,11 @@
1
+ module Graphql
2
+ module PersistedDocuments
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Graphql::PersistedDocuments
5
+
6
+ config.generators do |g|
7
+ g.test_framework :rspec
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,8 +1,8 @@
1
1
  module Graphql
2
2
  module PersistedDocuments
3
3
  class Persister
4
- InvalidDocument = Class.new(StandardError)
5
- MissingPersistValidatedDocument = Class.new(StandardError)
4
+ InvalidDocumentError = Class.new(StandardError)
5
+ MissingPersistValidatedDocumentError = Class.new(StandardError)
6
6
  ParseError = Class.new(StandardError)
7
7
 
8
8
  attr_reader :query_string, :errors
@@ -12,17 +12,17 @@ module Graphql
12
12
  @errors = []
13
13
  end
14
14
 
15
- def persist!
15
+ def persist
16
16
  document = GraphQL.parse(query_string)
17
17
  query = GraphQL::Query.new(config.schema, document: document)
18
18
  perform_validation(query)
19
19
 
20
- raise InvalidDocument unless errors.empty?
20
+ raise InvalidDocumentError unless errors.empty?
21
21
 
22
22
  user_persister = config.persist_validated_document
23
23
  return user_persister.call(document) if user_persister
24
24
 
25
- raise MissingPersistValidatedDocument
25
+ raise MissingPersistValidatedDocumentError
26
26
  rescue GraphQL::ParseError
27
27
  raise ParseError
28
28
  end
@@ -31,7 +31,8 @@ module Graphql
31
31
 
32
32
  def perform_validation(query)
33
33
  validation_result = validator.validate(query)
34
- @errors = validation_result[:errors]
34
+ validation_errors = validation_result[:errors] || []
35
+ @errors = validation_errors.map { |error| error["message"] }
35
36
  end
36
37
 
37
38
  def config
@@ -1,5 +1,5 @@
1
1
  module Graphql
2
2
  module PersistedDocuments
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1,8 +1,5 @@
1
- require "graphql"
2
-
3
1
  require "graphql/persisted_documents/configuration"
4
- require "graphql/persisted_documents/version"
5
- require "graphql/persisted_documents/rack"
2
+ require "graphql/persisted_documents/engine"
6
3
  require "graphql/persisted_documents/persister"
7
4
 
8
5
  module Graphql
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :graphql_persisted_documents do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,85 @@
1
+ require "rails_helper"
2
+
3
+ describe Graphql::PersistedDocuments::PersistedDocumentsController do
4
+ routes { Graphql::PersistedDocuments::Engine.routes }
5
+
6
+ describe "POST persist" do
7
+ before do
8
+ Graphql::PersistedDocuments.configure do |config|
9
+ config.schema = TestSchema
10
+ config.persist_validated_document = lambda do |document|
11
+ 'yolo-swag'
12
+ end
13
+ end
14
+ end
15
+
16
+ it "parses, validates and persists a document" do
17
+ post :persist, params: { document: 'query { validField }' }
18
+
19
+ expect(response.code).to eq("200")
20
+ expect(response.body).to eq({
21
+ document_id: 'yolo-swag'
22
+ }.to_json)
23
+ end
24
+
25
+
26
+ context "when no params are passed in" do
27
+ it "responds with an error" do
28
+ post :persist, params: {}
29
+
30
+ expect(response.code).to eq("422")
31
+ expect(response.body).to eq({
32
+ errors: [{
33
+ message: "Missing required argument document"
34
+ }]
35
+ }.to_json)
36
+ end
37
+ end
38
+
39
+ context "when the document is not parsable" do
40
+ it "responds with an error" do
41
+ post :persist, params: { document: "query {" }
42
+
43
+ expect(response.code).to eq("422")
44
+ expect(response.body).to eq({
45
+ errors: [{
46
+ message: "Unable to parse document"
47
+ }]
48
+ }.to_json)
49
+ end
50
+ end
51
+
52
+ context "when the document is invalid according to schema" do
53
+ it "responds with an error" do
54
+ post :persist, params: { document: "query { invalidField }" }
55
+
56
+ expect(response.code).to eq("422")
57
+ expect(response.body).to eq({
58
+ errors: [{
59
+ message: "Field 'invalidField' doesn't exist on type 'Query'"
60
+ }]
61
+ }.to_json)
62
+ end
63
+ end
64
+
65
+ context "when the persist_validated_document fn is not set" do
66
+ before do
67
+ Graphql::PersistedDocuments.configure do |config|
68
+ config.schema = TestSchema
69
+ config.persist_validated_document = nil
70
+ end
71
+ end
72
+
73
+ it "responds with an error" do
74
+ post :persist, params: { document: "query { validField }" }
75
+
76
+ expect(response.code).to eq("400")
77
+ expect(response.body).to eq({
78
+ errors: [{
79
+ message: "persist_validated_document must be defined in config"
80
+ }]
81
+ }.to_json)
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,5 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
5
+ //= link graphql_persisted_documents_manifest.js
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the rails generate channel command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
6
+
7
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9
+ </head>
10
+
11
+ <body>
12
+ <%= yield %>
13
+ </body>
14
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a starting point to setup your application.
15
+ # Add necessary setup steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ # puts "\n== Copying sample files =="
22
+ # unless File.exist?('config/database.yml')
23
+ # cp 'config/database.yml.sample', 'config/database.yml'
24
+ # end
25
+
26
+ puts "\n== Preparing database =="
27
+ system! 'bin/rails db:setup'
28
+
29
+ puts "\n== Removing old logs and tempfiles =="
30
+ system! 'bin/rails log:clear tmp:clear'
31
+
32
+ puts "\n== Restarting application server =="
33
+ system! 'bin/rails restart'
34
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a way to update your development environment automatically.
15
+ # Add necessary update steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ puts "\n== Updating database =="
22
+ system! 'bin/rails db:migrate'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system! 'bin/rails log:clear tmp:clear'
26
+
27
+ puts "\n== Restarting application server =="
28
+ system! 'bin/rails restart'
29
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'boot'
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "graphql/persisted_documents"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+ end
14
+ end
15
+