2020-01-26 20:34:25 +01:00
|
|
|
defmodule Mobilizon.GraphQL.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
|
2020-01-26 20:34:25 +01:00
|
|
|
|
|
|
|
alias Mobilizon.GraphQL.Resolvers.Address
|
2019-01-14 17:13:17 +01:00
|
|
|
|
2020-11-20 15:24:04 +01:00
|
|
|
@desc """
|
|
|
|
An address object
|
|
|
|
"""
|
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")
|
2020-11-19 17:06:28 +01:00
|
|
|
field(:postal_code, :string, description: "The address's postal code")
|
|
|
|
field(:region, :string, description: "The address's region")
|
|
|
|
field(:country, :string, description: "The address's country")
|
|
|
|
field(:description, :string, description: "The address's description")
|
|
|
|
field(:type, :string, description: "The address's type")
|
|
|
|
field(:url, :string, description: "The address's URL")
|
|
|
|
field(:id, :id, description: "The address's ID")
|
|
|
|
field(:origin_id, :string, description: "The address's original ID from the provider")
|
2021-10-10 16:25:50 +02:00
|
|
|
field(:timezone, :string, description: "The (estimated) timezone of the location")
|
2022-07-12 10:55:28 +02:00
|
|
|
field(:picture_info, :picture_info, description: "A picture associated with the address")
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|
|
|
|
|
2020-11-20 15:24:04 +01:00
|
|
|
@desc """
|
|
|
|
A phone address
|
|
|
|
"""
|
2019-01-14 17:13:17 +01:00
|
|
|
object :phone_address do
|
2020-11-19 17:06:28 +01:00
|
|
|
field(:phone, :string, description: "The phone number")
|
|
|
|
field(:info, :string, description: "Additional information about the phone number")
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|
|
|
|
|
2020-11-20 15:24:04 +01:00
|
|
|
@desc """
|
|
|
|
An online address
|
|
|
|
"""
|
2019-01-14 17:13:17 +01:00
|
|
|
object :online_address do
|
|
|
|
field(:url, :string)
|
|
|
|
field(:info, :string)
|
|
|
|
end
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
object :picture_info_element do
|
|
|
|
field(:name, :string)
|
|
|
|
field(:url, :string)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
A picture associated with an address
|
|
|
|
"""
|
|
|
|
object :picture_info do
|
|
|
|
field(:url, :string)
|
|
|
|
field(:author, :picture_info_element)
|
|
|
|
field(:source, :picture_info_element)
|
|
|
|
end
|
|
|
|
|
2020-11-20 15:24:04 +01:00
|
|
|
@desc """
|
|
|
|
An address input
|
|
|
|
"""
|
2019-07-30 10:35:29 +02:00
|
|
|
input_object :address_input 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")
|
2020-11-19 17:06:28 +01:00
|
|
|
field(:postal_code, :string, description: "The address's postal code")
|
|
|
|
field(:region, :string, description: "The address's region")
|
|
|
|
field(:country, :string, description: "The address's country")
|
|
|
|
field(:description, :string, description: "The address's description")
|
|
|
|
field(:type, :string, description: "The address's type")
|
|
|
|
field(:url, :string, description: "The address's URL")
|
|
|
|
field(:id, :id, description: "The address's ID")
|
|
|
|
field(:origin_id, :string, description: "The address's original ID from the provider")
|
2021-10-10 16:25:50 +02:00
|
|
|
field(:timezone, :string, description: "The (estimated) timezone of the location")
|
2019-07-30 10:35:29 +02:00
|
|
|
end
|
|
|
|
|
2021-02-12 18:19:49 +01:00
|
|
|
@desc """
|
|
|
|
A list of possible values for the type option to search an address.
|
|
|
|
|
|
|
|
Results may vary depending on the geocoding provider.
|
|
|
|
"""
|
|
|
|
enum :address_search_type do
|
|
|
|
value(:administrative, description: "Administrative results (cities, regions,...)")
|
|
|
|
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))
|
2020-11-19 17:06:28 +01:00
|
|
|
|
|
|
|
arg(:locale, :string,
|
|
|
|
default_value: "en",
|
|
|
|
description: "The user's locale. Geocoding backends will make use of this value."
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:page, :integer,
|
|
|
|
default_value: 1,
|
|
|
|
description: "The page in the paginated search results list"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:limit, :integer, default_value: 10, description: "The limit of search results per page")
|
2019-03-14 18:31:14 +01:00
|
|
|
|
2021-02-12 18:19:49 +01:00
|
|
|
arg(:type, :address_search_type, description: "Filter by type of results")
|
|
|
|
|
2020-01-26 20:34:25 +01:00
|
|
|
resolve(&Address.search/3)
|
2019-03-14 18:31:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Reverse geocode coordinates"
|
2019-03-22 15:51:23 +01:00
|
|
|
field :reverse_geocode, type: list_of(:address) do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:longitude, non_null(:float), description: "Geographical longitude (using WGS 84)")
|
|
|
|
arg(:latitude, non_null(:float), description: "Geographical latitude (using WGS 84)")
|
|
|
|
arg(:zoom, :integer, default_value: 15, description: "Zoom level")
|
|
|
|
|
|
|
|
arg(:locale, :string,
|
|
|
|
default_value: "en",
|
|
|
|
description: "The user's locale. Geocoding backends will make use of this value."
|
|
|
|
)
|
2019-03-14 18:31:14 +01:00
|
|
|
|
2020-01-26 20:34:25 +01:00
|
|
|
resolve(&Address.reverse_geocode/3)
|
2019-03-14 18:31:14 +01:00
|
|
|
end
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|