LoginSignup
0

More than 5 years have passed since last update.

[Elixir]absinthe_tutorialをmysqlで動かす

Last updated at Posted at 2018-07-14

ElixirのGraphQLライブラリ、absintheのtutorialをmysqlで動くようにする
(ectoがデフォルトではpostgresqlを使うようになっているので)

mix.exs の変更

depsに mariaex を追加

       {:argon2_elixir, "~> 1.2"},
+      {:mariaex, "~> 0.1"},
     ]

config/dev.exs の変更

接続先情報をmysqlのものに変更

 config :blog, Blog.Repo,
-  adapter: Ecto.Adapters.Postgres,
-  username: "postgres",
-  password: "postgres",
-  database: "blog_dev",
-  hostname: "localhost",
-  pool_size: 10
+adapter: Ecto.Adapters.MySQL,
+  database: "your database name",
+  username: "your user name",
+  password: "your password"

マイグレーション

まいぐれーしょんスクリプトを流してテーブルの作成

$ mix ecto.migrate

初期データの挿入

$ mix run priv/repo/seeds.exs

フェニックス起動

$ mix phoenix.server

http://localhost:4000/api/graphiql
にアクセスしたらブラウザ上でGraphQLを確認できる 😊
スクリーンショット 2018-07-14 14.04.50.png

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0