Hi I am planning to use Phoenix with Absinthe without Ecto, because I am not planning to use an kind of ORM with MySQL. (Or is there another way of using Absinthe without using Ecto?)
I have been following the tutorial (http://absinthe-graphql.org/tutorial/our-first-query/), but in the resolver I got the issue:
I got the issue: Mysql.Repo.all/1 is undefined.
This is the Resolver:
defmodule Mysql.PostResolver do
def all(_args, _info) do
{:ok, Mysql.Repo.all(Post)}
end
end
I don't get what is Repo
I am using:
def application do
[mod: {Mysql, []},
applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext, :absinthe, :absinthe_plug, :poison]]
end
defp deps do
[{:phoenix, "~> 1.2.1"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_html, "~> 2.6"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"},
{:absinthe, "~> 1.2.0"},
{:absinthe_plug, "~> 1.1"},
{:poison, "~> 2.1.0"}]
end
And mysql installed locally.
"Repo" is an Ecto-related module. If you're not using Ecto, you need to make sure you return {:ok, the_data_you_retrieved_from_mysql_manually} yourself, however you decide on getting the data from MySQL.
The Absinthe package is generic and isn't tied to any specific method of retrieving data -- that's up to you.
@UnderFenex Just a suggestion, you should learn to use Ecto a little bit before proceeding if you don't want to use it long-term. I suspect you'll have a significantly more difficult time without it.
@mgwidmann Thanks for the advice, I finally used Ecto, I just wanted to not used an ORM like Ecto, but I am getting used to, and also I see that I brings more benefits over plain SQL.
Most helpful comment
@mgwidmann Thanks for the advice, I finally used Ecto, I just wanted to not used an ORM like Ecto, but I am getting used to, and also I see that I brings more benefits over plain SQL.