Work around Addresses to bring them properly through GraphQL

Got caught with https://github.com/absinthe-graphql/absinthe/issues/601
at some point, that's why fields are renamed

Fix tests

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-03-22 15:51:23 +01:00
parent 53458b16a2
commit 0c8d2f7e00
25 changed files with 200 additions and 145 deletions

View File

@@ -11,6 +11,16 @@ defmodule Mobilizon.Addresses do
@geom_types [:point]
@doc false
def data() do
Dataloader.Ecto.new(Repo, query: &query/2)
end
@doc false
def query(queryable, _params) do
queryable
end
@doc """
Returns the list of addresses.
@@ -168,7 +178,7 @@ defmodule Mobilizon.Addresses do
query =
if country = Keyword.get(options, :country, nil),
do: from(a in query, where: ilike(a.addressCountry, ^"%#{country}%")),
do: from(a in query, where: ilike(a.country, ^"%#{country}%")),
else: query
Repo.all(query)
@@ -198,7 +208,7 @@ defmodule Mobilizon.Addresses do
query =
if country,
do: from(a in query, where: ilike(a.addressCountry, ^"%#{country}%")),
do: from(a in query, where: ilike(a.country, ^"%#{country}%")),
else: query
Repo.all(query)