From a409a15a1f39c376d69ed4af521e2065991b48be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Giroux?= Date: Tue, 7 Feb 2017 17:23:28 -0500 Subject: [PATCH 1/4] Add GraphQL Gem, Add Directory Structure --- Gemfile | 21 ++------------------- Gemfile.lock | 33 ++------------------------------- app/graph/mutations/.keep | 0 app/graph/query.rb | 6 ++++++ config/application.rb | 2 ++ 5 files changed, 12 insertions(+), 50 deletions(-) create mode 100644 app/graph/mutations/.keep create mode 100644 app/graph/query.rb diff --git a/Gemfile b/Gemfile index 1e57e0a..f95f567 100644 --- a/Gemfile +++ b/Gemfile @@ -5,31 +5,14 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end - # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.0.1' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use Puma as the app server gem 'puma', '~> 3.0' -# Use SCSS for stylesheets -gem 'sass-rails', '~> 5.0' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' -# Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.2' -# See https://github.com/rails/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby - -# Use jquery as the JavaScript library -gem 'jquery-rails' -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.5' -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' - -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development +# Use GraphQL! +gem 'graphql', '~> 1.4.2' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index 3588735..fa144d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,28 +41,14 @@ GEM arel (7.1.4) builder (3.2.3) byebug (9.0.6) - coffee-rails (4.2.1) - coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.2.x) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.12.2) concurrent-ruby (1.0.4) debug_inspector (0.0.2) erubis (2.7.0) - execjs (2.7.0) ffi (1.9.17) globalid (0.3.7) activesupport (>= 4.1.0) + graphql (1.4.2) i18n (0.8.0) - jbuilder (2.6.1) - activesupport (>= 3.0.0, < 5.1) - multi_json (~> 1.2) - jquery-rails (4.2.2) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -76,7 +62,6 @@ GEM mime-types-data (3.2016.0521) mini_portile2 (2.1.0) minitest (5.10.1) - multi_json (1.12.1) nio4r (1.2.1) nokogiri (1.7.0.1) mini_portile2 (~> 2.1.0) @@ -111,13 +96,6 @@ GEM rb-fsevent (0.9.8) rb-inotify (0.9.8) ffi (>= 0.5.0) - sass (3.4.23) - sass-rails (5.0.6) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) spring (2.0.1) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -133,11 +111,8 @@ GEM sqlite3 (1.3.13) thor (0.19.4) thread_safe (0.3.5) - tilt (2.0.6) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (3.0.4) - execjs (>= 0.3.0, < 3) web-console (3.4.0) actionview (>= 5.0) activemodel (>= 5.0) @@ -152,18 +127,14 @@ PLATFORMS DEPENDENCIES byebug - coffee-rails (~> 4.2) - jbuilder (~> 2.5) - jquery-rails + graphql (~> 1.4.2) listen (~> 3.0.5) puma (~> 3.0) rails (~> 5.0.1) - sass-rails (~> 5.0) spring spring-watcher-listen (~> 2.0.0) sqlite3 tzinfo-data - uglifier (>= 1.3.0) web-console (>= 3.3.0) BUNDLED WITH diff --git a/app/graph/mutations/.keep b/app/graph/mutations/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/graph/query.rb b/app/graph/query.rb new file mode 100644 index 0000000..a57f346 --- /dev/null +++ b/app/graph/query.rb @@ -0,0 +1,6 @@ +QueryType = GraphQL::ObjectType.define do + name "Query" + description "The query root of this schema" + + # ... complete this schema +end diff --git a/config/application.rb b/config/application.rb index 0d18ccc..a42786c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,5 +21,7 @@ class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + config.autoload_paths << Rails.root.join('app', 'graph') + config.autoload_paths << Rails.root.join('app', 'graph', 'mutations') end end From 70f280b44f98d8d6d5c5f1670a80ab4ac733901f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Giroux?= Date: Tue, 7 Feb 2017 17:29:02 -0500 Subject: [PATCH 2/4] Add Schema --- app/graph/query.rb | 2 +- app/graph/schema.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 app/graph/schema.rb diff --git a/app/graph/query.rb b/app/graph/query.rb index a57f346..b5281a2 100644 --- a/app/graph/query.rb +++ b/app/graph/query.rb @@ -1,4 +1,4 @@ -QueryType = GraphQL::ObjectType.define do +Query = GraphQL::ObjectType.define do name "Query" description "The query root of this schema" diff --git a/app/graph/schema.rb b/app/graph/schema.rb new file mode 100644 index 0000000..770b3ba --- /dev/null +++ b/app/graph/schema.rb @@ -0,0 +1,3 @@ +Schema = GraphQL::Schema.define do + query Query +end From d6ddb4d02d0ff8a9ef42cd5ce2ae788f8e190493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Giroux?= Date: Tue, 7 Feb 2017 17:39:27 -0500 Subject: [PATCH 3/4] Graph Namespace --- app/graph/query.rb | 10 ++++++---- app/graph/schema.rb | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/graph/query.rb b/app/graph/query.rb index b5281a2..df877ac 100644 --- a/app/graph/query.rb +++ b/app/graph/query.rb @@ -1,6 +1,8 @@ -Query = GraphQL::ObjectType.define do - name "Query" - description "The query root of this schema" +module Graph + Query = GraphQL::ObjectType.define do + name "Query" + description "The query root of this schema" - # ... complete this schema + # ... complete this schema + end end diff --git a/app/graph/schema.rb b/app/graph/schema.rb index 770b3ba..2d94691 100644 --- a/app/graph/schema.rb +++ b/app/graph/schema.rb @@ -1,3 +1,5 @@ -Schema = GraphQL::Schema.define do - query Query +module Graph + Schema = GraphQL::Schema.define do + query Query + end end From 282dc9e1bfac88e5e421762b2a0e79b2c694b47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Giroux?= Date: Tue, 7 Feb 2017 18:36:52 -0500 Subject: [PATCH 4/4] rm mutation autoload path --- config/application.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index a42786c..ae65bf9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,6 +22,5 @@ class Application < Rails::Application # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. config.autoload_paths << Rails.root.join('app', 'graph') - config.autoload_paths << Rails.root.join('app', 'graph', 'mutations') end end