2020-01-26 19:34:25 +00:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.AddressType do
|
2019-01-14 16:48:08 +00:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Address
|
|
|
|
"""
|
2019-01-14 16:13:17 +00:00
|
|
|
use Absinthe.Schema.Notation
|
2020-01-26 19:34:25 +00:00
|
|
|
|
|
|
|
alias Mobilizon.GraphQL.Resolvers.Address
|
2019-01-14 16:13:17 +00:00
|
|
|
|
2020-11-20 14:24:04 +00:00
|
|
|
@desc """
|
|
|
|
An address object
|
|
|
|
"""
|
2019-03-22 14:51:23 +00:00
|
|
|
object :address do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :all)
|
2019-03-22 14:51:23 +00:00
|
|
|
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 16:06:28 +00: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 14:25:50 +00:00
|
|
|
field(:timezone, :string, description: "The (estimated) timezone of the location")
|
2022-07-12 08:55:28 +00:00
|
|
|
field(:picture_info, :picture_info, description: "A picture associated with the address")
|
2019-01-14 16:13:17 +00:00
|
|
|
end
|
|
|
|
|
2020-11-20 14:24:04 +00:00
|
|
|
@desc """
|
|
|
|
A phone address
|
|
|
|
"""
|
2019-01-14 16:13:17 +00:00
|
|
|
object :phone_address do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :all)
|
2020-11-19 16:06:28 +00:00
|
|
|
field(:phone, :string, description: "The phone number")
|
|
|
|
field(:info, :string, description: "Additional information about the phone number")
|
2019-01-14 16:13:17 +00:00
|
|
|
end
|
|
|
|
|
2020-11-20 14:24:04 +00:00
|
|
|
@desc """
|
|
|
|
An online address
|
|
|
|
"""
|
2019-01-14 16:13:17 +00:00
|
|
|
object :online_address do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :all)
|
2019-01-14 16:13:17 +00:00
|
|
|
field(:url, :string)
|
|
|
|
field(:info, :string)
|
|
|
|
end
|
|
|
|
|
2022-07-12 08:55:28 +00:00
|
|
|
object :picture_info_element do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :all)
|
2022-07-12 08:55:28 +00:00
|
|
|
field(:name, :string)
|
|
|
|
field(:url, :string)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
A picture associated with an address
|
|
|
|
"""
|
|
|
|
object :picture_info do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :all)
|
2022-07-12 08:55:28 +00:00
|
|
|
field(:url, :string)
|
|
|
|
field(:author, :picture_info_element)
|
|
|
|
field(:source, :picture_info_element)
|
|
|
|
end
|
|
|
|
|
2020-11-20 14:24:04 +00:00
|
|
|
@desc """
|
|
|
|
An address input
|
|
|
|
"""
|
2019-07-30 08:35:29 +00: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 16:06:28 +00: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 14:25:50 +00:00
|
|
|
field(:timezone, :string, description: "The (estimated) timezone of the location")
|
2019-07-30 08:35:29 +00:00
|
|
|
end
|
|
|
|
|
2021-02-12 17:19:49 +00: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 17:31:14 +00:00
|
|
|
object :address_queries do
|
|
|
|
@desc "Search for an address"
|
2019-03-22 14:51:23 +00:00
|
|
|
field :search_address, type: list_of(:address) do
|
2019-03-14 17:31:14 +00:00
|
|
|
arg(:query, non_null(:string))
|
2020-11-19 16:06:28 +00: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 17:31:14 +00:00
|
|
|
|
2021-02-12 17:19:49 +00:00
|
|
|
arg(:type, :address_search_type, description: "Filter by type of results")
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :all)
|
2020-01-26 19:34:25 +00:00
|
|
|
resolve(&Address.search/3)
|
2019-03-14 17:31:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Reverse geocode coordinates"
|
2019-03-22 14:51:23 +00:00
|
|
|
field :reverse_geocode, type: list_of(:address) do
|
2020-11-19 16:06:28 +00: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 17:31:14 +00:00
|
|
|
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :all)
|
2020-01-26 19:34:25 +00:00
|
|
|
resolve(&Address.reverse_geocode/3)
|
2019-03-14 17:31:14 +00:00
|
|
|
end
|
|
|
|
end
|
2019-01-14 16:13:17 +00:00
|
|
|
end
|