2019-01-14 17:13:17 +01:00
|
|
|
defmodule MobilizonWeb.Schema.AddressType do
|
2019-01-14 17:48:08 +01:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Address
|
|
|
|
"""
|
2019-01-14 17:13:17 +01:00
|
|
|
use Absinthe.Schema.Notation
|
2019-03-14 18:31:14 +01:00
|
|
|
alias MobilizonWeb.Resolvers
|
2019-01-14 17:13:17 +01:00
|
|
|
|
2019-03-22 15:51:23 +01:00
|
|
|
object :address do
|
|
|
|
field(:geom, :point, description: "The geocoordinates for the point where this address is")
|
|
|
|
field(:street, :string, description: "The address's street name (with number)")
|
|
|
|
field(:locality, :string, description: "The address's locality")
|
|
|
|
field(:postal_code, :string)
|
|
|
|
field(:region, :string)
|
|
|
|
field(:country, :string)
|
2019-01-14 17:13:17 +01:00
|
|
|
field(:description, :string)
|
2019-11-08 19:37:14 +01:00
|
|
|
field(:type, :string)
|
2019-07-30 10:35:29 +02:00
|
|
|
field(:url, :string)
|
2019-09-09 09:31:08 +02:00
|
|
|
field(:id, :id)
|
2019-08-22 15:57:44 +02:00
|
|
|
field(:origin_id, :string)
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
object :phone_address do
|
|
|
|
field(:phone, :string)
|
|
|
|
field(:info, :string)
|
|
|
|
end
|
|
|
|
|
|
|
|
object :online_address do
|
|
|
|
field(:url, :string)
|
|
|
|
field(:info, :string)
|
|
|
|
end
|
|
|
|
|
2019-07-30 10:35:29 +02:00
|
|
|
input_object :address_input do
|
|
|
|
# Either a full picture object
|
|
|
|
field(:geom, :point, description: "The geocoordinates for the point where this address is")
|
|
|
|
field(:street, :string, description: "The address's street name (with number)")
|
|
|
|
field(:locality, :string, description: "The address's locality")
|
|
|
|
field(:postal_code, :string)
|
|
|
|
field(:region, :string)
|
|
|
|
field(:country, :string)
|
|
|
|
field(:description, :string)
|
|
|
|
field(:url, :string)
|
2019-11-08 19:37:14 +01:00
|
|
|
field(:type, :string)
|
2019-09-09 09:31:08 +02:00
|
|
|
field(:id, :id)
|
2019-08-22 15:57:44 +02:00
|
|
|
field(:origin_id, :string)
|
2019-07-30 10:35:29 +02:00
|
|
|
end
|
|
|
|
|
2019-03-14 18:31:14 +01:00
|
|
|
object :address_queries do
|
|
|
|
@desc "Search for an address"
|
2019-03-22 15:51:23 +01:00
|
|
|
field :search_address, type: list_of(:address) do
|
2019-03-14 18:31:14 +01:00
|
|
|
arg(:query, non_null(:string))
|
2019-11-08 19:37:14 +01:00
|
|
|
arg(:locale, :string, default_value: "en")
|
2019-07-30 10:35:29 +02:00
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
2019-03-14 18:31:14 +01:00
|
|
|
|
|
|
|
resolve(&Resolvers.Address.search/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Reverse geocode coordinates"
|
2019-03-22 15:51:23 +01:00
|
|
|
field :reverse_geocode, type: list_of(:address) do
|
2019-03-14 18:31:14 +01:00
|
|
|
arg(:longitude, non_null(:float))
|
|
|
|
arg(:latitude, non_null(:float))
|
2019-11-08 19:37:14 +01:00
|
|
|
arg(:zoom, :integer, default_value: 15)
|
|
|
|
arg(:locale, :string, default_value: "en")
|
2019-03-14 18:31:14 +01:00
|
|
|
|
|
|
|
resolve(&Resolvers.Address.reverse_geocode/3)
|
|
|
|
end
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|