Skip to content

Commit a2722c2

Browse files
committed
first commit
0 parents  commit a2722c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1032
-0
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# See https://git-scm.com/docs/gitattributes for more about git attribute files.
2+
3+
# Mark the database schema as having been generated.
4+
db/schema.rb linguist-generated
5+
6+
# Mark any vendored files as having been vendored.
7+
vendor/* linguist-vendored

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore all logfiles and tempfiles.
11+
/log/*
12+
/tmp/*
13+
!/log/.keep
14+
!/tmp/.keep
15+
16+
# Ignore pidfiles, but keep the directory.
17+
/tmp/pids/*
18+
!/tmp/pids/
19+
!/tmp/pids/.keep
20+
21+
22+
# Ignore master key for decrypting credentials and more.
23+
/config/master.key

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.2.0

Gemfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
source "https://rubygems.org"
2+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3+
4+
ruby "3.2.0"
5+
6+
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
7+
gem "rails", "~> 7.0.5"
8+
9+
# Use mysql as the database for Active Record
10+
gem "mysql2", "~> 0.5"
11+
12+
# Use the Puma web server [https://github.com/puma/puma]
13+
gem "puma", "~> 5.0"
14+
15+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
16+
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
17+
18+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
19+
# gem "rack-cors"
20+
21+
group :development, :test do
22+
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
23+
gem "debug", platforms: %i[ mri mingw x64_mingw ]
24+
end
25+
26+
gem 'graphql'
27+
gem 'graphql-batch'
28+
29+
gem 'ridgepole'
30+
31+
group :development do
32+
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
33+
# gem "spring"
34+
end

Gemfile.lock

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actioncable (7.0.5)
5+
actionpack (= 7.0.5)
6+
activesupport (= 7.0.5)
7+
nio4r (~> 2.0)
8+
websocket-driver (>= 0.6.1)
9+
actionmailbox (7.0.5)
10+
actionpack (= 7.0.5)
11+
activejob (= 7.0.5)
12+
activerecord (= 7.0.5)
13+
activestorage (= 7.0.5)
14+
activesupport (= 7.0.5)
15+
mail (>= 2.7.1)
16+
net-imap
17+
net-pop
18+
net-smtp
19+
actionmailer (7.0.5)
20+
actionpack (= 7.0.5)
21+
actionview (= 7.0.5)
22+
activejob (= 7.0.5)
23+
activesupport (= 7.0.5)
24+
mail (~> 2.5, >= 2.5.4)
25+
net-imap
26+
net-pop
27+
net-smtp
28+
rails-dom-testing (~> 2.0)
29+
actionpack (7.0.5)
30+
actionview (= 7.0.5)
31+
activesupport (= 7.0.5)
32+
rack (~> 2.0, >= 2.2.4)
33+
rack-test (>= 0.6.3)
34+
rails-dom-testing (~> 2.0)
35+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
36+
actiontext (7.0.5)
37+
actionpack (= 7.0.5)
38+
activerecord (= 7.0.5)
39+
activestorage (= 7.0.5)
40+
activesupport (= 7.0.5)
41+
globalid (>= 0.6.0)
42+
nokogiri (>= 1.8.5)
43+
actionview (7.0.5)
44+
activesupport (= 7.0.5)
45+
builder (~> 3.1)
46+
erubi (~> 1.4)
47+
rails-dom-testing (~> 2.0)
48+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
49+
activejob (7.0.5)
50+
activesupport (= 7.0.5)
51+
globalid (>= 0.3.6)
52+
activemodel (7.0.5)
53+
activesupport (= 7.0.5)
54+
activerecord (7.0.5)
55+
activemodel (= 7.0.5)
56+
activesupport (= 7.0.5)
57+
activestorage (7.0.5)
58+
actionpack (= 7.0.5)
59+
activejob (= 7.0.5)
60+
activerecord (= 7.0.5)
61+
activesupport (= 7.0.5)
62+
marcel (~> 1.0)
63+
mini_mime (>= 1.1.0)
64+
activesupport (7.0.5)
65+
concurrent-ruby (~> 1.0, >= 1.0.2)
66+
i18n (>= 1.6, < 2)
67+
minitest (>= 5.1)
68+
tzinfo (~> 2.0)
69+
builder (3.2.4)
70+
concurrent-ruby (1.2.2)
71+
crass (1.0.6)
72+
date (3.3.3)
73+
debug (1.8.0)
74+
irb (>= 1.5.0)
75+
reline (>= 0.3.1)
76+
diffy (3.4.2)
77+
erubi (1.12.0)
78+
globalid (1.1.0)
79+
activesupport (>= 5.0)
80+
graphql (2.0.23)
81+
graphql-batch (0.5.3)
82+
graphql (>= 1.12.18, < 3)
83+
promise.rb (~> 0.7.2)
84+
i18n (1.14.1)
85+
concurrent-ruby (~> 1.0)
86+
io-console (0.6.0)
87+
irb (1.7.0)
88+
reline (>= 0.3.0)
89+
loofah (2.21.3)
90+
crass (~> 1.0.2)
91+
nokogiri (>= 1.12.0)
92+
mail (2.8.1)
93+
mini_mime (>= 0.1.1)
94+
net-imap
95+
net-pop
96+
net-smtp
97+
marcel (1.0.2)
98+
method_source (1.0.0)
99+
mini_mime (1.1.2)
100+
minitest (5.18.1)
101+
mysql2 (0.5.5)
102+
net-imap (0.3.6)
103+
date
104+
net-protocol
105+
net-pop (0.1.2)
106+
net-protocol
107+
net-protocol (0.2.1)
108+
timeout
109+
net-smtp (0.3.3)
110+
net-protocol
111+
nio4r (2.5.9)
112+
nokogiri (1.15.2-x86_64-darwin)
113+
racc (~> 1.4)
114+
promise.rb (0.7.4)
115+
puma (5.6.6)
116+
nio4r (~> 2.0)
117+
racc (1.7.1)
118+
rack (2.2.7)
119+
rack-test (2.1.0)
120+
rack (>= 1.3)
121+
rails (7.0.5)
122+
actioncable (= 7.0.5)
123+
actionmailbox (= 7.0.5)
124+
actionmailer (= 7.0.5)
125+
actionpack (= 7.0.5)
126+
actiontext (= 7.0.5)
127+
actionview (= 7.0.5)
128+
activejob (= 7.0.5)
129+
activemodel (= 7.0.5)
130+
activerecord (= 7.0.5)
131+
activestorage (= 7.0.5)
132+
activesupport (= 7.0.5)
133+
bundler (>= 1.15.0)
134+
railties (= 7.0.5)
135+
rails-dom-testing (2.0.3)
136+
activesupport (>= 4.2.0)
137+
nokogiri (>= 1.6)
138+
rails-html-sanitizer (1.6.0)
139+
loofah (~> 2.21)
140+
nokogiri (~> 1.14)
141+
railties (7.0.5)
142+
actionpack (= 7.0.5)
143+
activesupport (= 7.0.5)
144+
method_source
145+
rake (>= 12.2)
146+
thor (~> 1.0)
147+
zeitwerk (~> 2.5)
148+
rake (13.0.6)
149+
reline (0.3.5)
150+
io-console (~> 0.5)
151+
ridgepole (1.2.0)
152+
activerecord (>= 5.1, < 7.1)
153+
diffy
154+
thor (1.2.2)
155+
timeout (0.3.2)
156+
tzinfo (2.0.6)
157+
concurrent-ruby (~> 1.0)
158+
websocket-driver (0.7.5)
159+
websocket-extensions (>= 0.1.0)
160+
websocket-extensions (0.1.5)
161+
zeitwerk (2.6.8)
162+
163+
PLATFORMS
164+
x86_64-darwin-22
165+
166+
DEPENDENCIES
167+
debug
168+
graphql
169+
graphql-batch
170+
mysql2 (~> 0.5)
171+
puma (~> 5.0)
172+
rails (~> 7.0.5)
173+
ridgepole
174+
tzinfo-data
175+
176+
RUBY VERSION
177+
ruby 3.2.0p0
178+
179+
BUNDLED WITH
180+
2.4.8

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# README
2+
3+
This README would normally document whatever steps are necessary to get the
4+
application up and running.
5+
6+
Things you may want to cover:
7+
8+
* Ruby version
9+
10+
* System dependencies
11+
12+
* Configuration
13+
14+
* Database creation
15+
16+
* Database initialization
17+
18+
* How to run the test suite
19+
20+
* Services (job queues, cache servers, search engines, etc.)
21+
22+
* Deployment instructions
23+
24+
* ...

Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationController < ActionController::API
2+
end

app/controllers/concerns/.keep

Whitespace-only changes.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
class GraphqlController < ApplicationController
2+
# If accessing from outside this domain, nullify the session
3+
# This allows for outside API access while preventing CSRF attacks,
4+
# but you'll have to authenticate your user separately
5+
# protect_from_forgery with: :null_session
6+
7+
def execute
8+
variables = prepare_variables(params[:variables])
9+
query = params[:query]
10+
operation_name = params[:operationName]
11+
context = {
12+
# Query context goes here, for example:
13+
# current_user: current_user,
14+
}
15+
result = GraphqlUserRegistBackendSampleSchema.execute(query, variables: variables, context: context, operation_name: operation_name)
16+
render json: result
17+
rescue StandardError => e
18+
raise e unless Rails.env.development?
19+
handle_error_in_development(e)
20+
end
21+
22+
private
23+
24+
# Handle variables in form data, JSON body, or a blank value
25+
def prepare_variables(variables_param)
26+
case variables_param
27+
when String
28+
if variables_param.present?
29+
JSON.parse(variables_param) || {}
30+
else
31+
{}
32+
end
33+
when Hash
34+
variables_param
35+
when ActionController::Parameters
36+
variables_param.to_unsafe_hash # GraphQL-Ruby will validate name and type of incoming variables.
37+
when nil
38+
{}
39+
else
40+
raise ArgumentError, "Unexpected parameter: #{variables_param}"
41+
end
42+
end
43+
44+
def handle_error_in_development(e)
45+
logger.error e.message
46+
logger.error e.backtrace.join("\n")
47+
48+
render json: { errors: [{ message: e.message, backtrace: e.backtrace }], data: {} }, status: 500
49+
end
50+
end

0 commit comments

Comments
 (0)