Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSS Gate Workshop: Tokyo: 2019-09-14: imaharu: graphql-ruby: Work log #1293

Closed
imaharu opened this issue Sep 14, 2019 · 21 comments
Closed

OSS Gate Workshop: Tokyo: 2019-09-14: imaharu: graphql-ruby: Work log #1293

imaharu opened this issue Sep 14, 2019 · 21 comments

Comments

@imaharu
Copy link
Contributor

imaharu commented Sep 14, 2019

This is a work log of a "OSS Gate workshop".
"OSS Gate workshop" is an activity to increase OSS developers.
Here's been discussed in Japanese. Thanks.

作業ログ作成時の説明

以下のテンプレートを埋めてタイトルに設定します。埋め方例はスクロールすると見えてきます。

OSS Gate Workshop: ${LOCATION}: ${YEAR}-${MONTH}-${DAY}: ${ACCOUNT_NAME}: ${OSS_NAME}: Work log

タイトル例↓:

OSS Gate Workshop: Tokyo: 2017-01-16: kou: Rabbit: Work log

OSS Gateワークショップ関連情報

  • スライド:ワークショップの進行に使っているスライドがあります。
  • チャット:OSS開発に関することならなんでも相談できます。ワークショップが終わった後もオンラインで相談しながら継続的にOSSの開発に参加しましょう!
  • シナリオ:ワークショップの目的・内容・進め方の詳細が書いています。
  • 過去のビギナーの作業ログ:他の人の作業ログから学べることがいろいろあるはずです。
@imaharu imaharu changed the title OSS Gate Workshop: ${Tokyo}: ${2019}-${09}-${14}: ${imaharu}: ${OSS_NAME}: Work log OSS Gate Workshop: ${Tokyo}: ${2019}-${09}-${14}: ${imaharu}: ${graphql-ruby}: Work log Sep 14, 2019
@imaharu imaharu changed the title OSS Gate Workshop: ${Tokyo}: ${2019}-${09}-${14}: ${imaharu}: ${graphql-ruby}: Work log OSS Gate Workshop: Tokyo: 2019-09-14: imaharu: graphql-ruby: Work log Sep 14, 2019
@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

まずは、graphql-rubyのGetting Started行います
https://graphql-ruby.org/getting_started#declare-types

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

各バージョンです

$ rails -v
Rails 5.2.3
$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin18]

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

初期のGemfileです
ここに、 gem "graphql" を追記します
特に規定がないので、groupは指定しません

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.5.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.3'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

# for oss gate
gem "graphql"

上記のように追加した後に、bundle installをします

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

その後、rails sを行うといつもの画面が出力されました

スクリーンショット 2019-09-14 14 07 16

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

macを利用しているので、.gitignoreに .DS_Store を追加した後に

git add & git commit を行いました

g add .
g commit -m "First commit rails new with graphql-ruby && bundle install"

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

Gemfile.lockの中身を見ると

graphql (1.9.12)がインストールされていました

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

Getting Startedページの
https://graphql-ruby.org/getting_started#declare-types から

GraphQL generatorsをクリックしたのち

https://graphql-ruby.org/schema/generators#graphqlinstall

Options段落に

  • --no-graphiql will exclude graphiql-rails from the setup
    とあったが、 graphql:install --help 実行するとないため rails g graphql:install --no-graphiqlと実行した
 $ rails g  graphql:install --help
Running via Spring preloader in process 62782
Usage:
  rails generate graphql:install [options]

Options:
  [--skip-namespace], [--no-skip-namespace]                    # Skip namespace (affects only isolated applications)
  [--directory=DIRECTORY]                                      # Directory where generated files should be saved
                                                               # Default: app/graphql
  [--schema=SCHEMA]                                            # Name for the schema constant (default: {app_name}Schema)
  [--skip-keeps], [--no-skip-keeps]                            # Skip .keep files for source control
  [--skip-graphiql], [--no-skip-graphiql]                      # Skip graphiql-rails installation
  [--skip-mutation-root-type], [--no-skip-mutation-root-type]  # Skip creation of the mutation root type
  [--relay], [--no-relay]                                      # Include GraphQL::Relay installation
  [--batch], [--no-batch]                                      # Include GraphQL::Batch installation
  [--api], [--no-api]                                          # Preconfigure smaller stack for API only apps

Runtime options:
  -f, [--force]                    # Overwrite files that already exist
  -p, [--pretend], [--no-pretend]  # Run but do not make any changes
  -q, [--quiet], [--no-quiet]      # Suppress status output
  -s, [--skip], [--no-skip]        # Skip files that already exist
oss-gate-graphql $ rails g  graphql:install --no-graphiql
Running via Spring preloader in process 67146
      create  app/graphql/types
      create  app/graphql/types/.keep
      create  app/graphql/oss_gate_graphql_schema.rb
      create  app/graphql/types/base_object.rb
      create  app/graphql/types/base_argument.rb
      create  app/graphql/types/base_field.rb
      create  app/graphql/types/base_enum.rb
      create  app/graphql/types/base_input_object.rb
      create  app/graphql/types/base_interface.rb
      create  app/graphql/types/base_scalar.rb
      create  app/graphql/types/base_union.rb
      create  app/graphql/types/query_type.rb
add_root_type  query
      create  app/graphql/mutations
      create  app/graphql/mutations/.keep
      create  app/graphql/types/mutation_type.rb
add_root_type  mutation
      create  app/controllers/graphql_controller.rb
       route  post "/graphql", to: "graphql#execute"
     gemfile  graphiql-rails
       route  graphiql-rails

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

すると、helpには存在しないコマンドが動いた

rails g graphql:install --no-graphiql

--no-graphiql がないコマンド

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

再度、 rails g graphql:install --help を実行すると

下記のようなエラー文が出力された

oss-gate-graphql $ rails g  graphql:install --help
Could not find gem 'graphiql-rails' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

次にbundle installを実行した
https://graphql-ruby.org/getting_started

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

これ以降、Gettingスタートをやります

ドキュメントはテンプレエンジンが変化してから更新されていない

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

@swamp09
Copy link
Member

swamp09 commented Sep 14, 2019

rails gで生成されるテンプレートファイルと、ドキュメントと違う部分があって、そこは直したほうが良いですね!という話をしました。
他に同じような問題でPRを出している人がいるか一緒に確認したところ、いないみたいなのでこのままいけそう!

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

NameSpace(テンプレートエンジン)に関するPRは以下のリンクです

rmosolgo/graphql-ruby@7279b5f#diff-a6f0315311fb9167ede5428eb5a574d3

rmosolgo/graphql-ruby#1591

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

PRヘ役立ちそうなリンク

類義語辞書
https://www.thesaurus.com/browse/

英英辞書

https://www.ldoceonline.com/dictionary/

@shioimm
Copy link
Contributor

shioimm commented Sep 14, 2019

@imaharu
知り合いの記事なのですが、OSSにPRを送るまでの流れがまとまっているので
紹介しておきます🐣
https://qiita.com/fuqda/items/a3e5270ff9cb4fbf31e2#%E7%9B%AE%E6%AC%A1

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

問題

Getting Started page が最新のテンプレートジェネレーターに追従していない

具体例

Getting Startedのドキュメントを参考にして rails g graphql:object Post title:String rating:Int comments:[Comment] を実行すると以下のコードが生成されます

# app/graphql/types/post_type.rb
module Types
  class PostType < Types::BaseObject
    # ...
  end
end

現在のドキュメントは、現状と異なっています

# app/graphql/types/post_type.rb
class Types::PostType < Types::BaseObject
 # ...
end

解決策

ドキュメントを修正し現状の状態と合うものにしました。

補足

調べて見ると、

@bary822さんが、rmosolgo/graphql-ruby#1591 を解決するために
コードを修正しました。

本PRは、この修正を反映したものです。

@bary822
Copy link

bary822 commented Sep 14, 2019

PR感謝です 🙏

@imaharu
Copy link
Contributor Author

imaharu commented Sep 14, 2019

ここ、PRに投げました

rmosolgo/graphql-ruby#2477

@oss-gate-issue-cleaner
Copy link

おつかれさまでした!

後日引き続きワークショップがある場合

後日のワークショップで再開する際に、issueタイトルの日付を更新してreopenしてください!

ワークショップ終了後に続きがしたい場合

issueはクローズしますが、その後も作業を続けていただいて大丈夫です!

是非このissueを活用なさってください。

今後のイベントの案内

現在以下のイベントの開催を予定しています。

参加をお待ちしてます!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants