Merge branch 'feature/event-maps' into 'master'
Feature/event maps See merge request framasoft/mobilizon!105
This commit is contained in:
@@ -4,7 +4,7 @@ defmodule MobilizonWeb.Schema do
|
||||
"""
|
||||
use Absinthe.Schema
|
||||
|
||||
alias Mobilizon.{Actors, Events, Users}
|
||||
alias Mobilizon.{Actors, Events, Users, Addresses}
|
||||
alias Mobilizon.Actors.{Actor, Follower, Member}
|
||||
alias Mobilizon.Events.{Event, Comment, Participant}
|
||||
|
||||
@@ -107,6 +107,7 @@ defmodule MobilizonWeb.Schema do
|
||||
|> Dataloader.add_source(Actors, Actors.data())
|
||||
|> Dataloader.add_source(Users, Users.data())
|
||||
|> Dataloader.add_source(Events, Events.data())
|
||||
|> Dataloader.add_source(Addresses, Addresses.data())
|
||||
|
||||
Map.put(ctx, :loader, loader)
|
||||
end
|
||||
|
||||
@@ -5,49 +5,37 @@ defmodule MobilizonWeb.Schema.AddressType do
|
||||
use Absinthe.Schema.Notation
|
||||
alias MobilizonWeb.Resolvers
|
||||
|
||||
object :physical_address do
|
||||
field(:type, :address_type)
|
||||
field(:geom, :point)
|
||||
field(:floor, :string)
|
||||
field(:streetAddress, :string)
|
||||
field(:addressLocality, :string)
|
||||
field(:postalCode, :string)
|
||||
field(:addressRegion, :string)
|
||||
field(:addressCountry, :string)
|
||||
object :address do
|
||||
field(:geom, :point, description: "The geocoordinates for the point where this address is")
|
||||
field(:floor, :string, description: "The floor this event is at")
|
||||
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(:name, :string)
|
||||
end
|
||||
|
||||
object :phone_address do
|
||||
field(:type, :address_type)
|
||||
field(:phone, :string)
|
||||
field(:info, :string)
|
||||
end
|
||||
|
||||
object :online_address do
|
||||
field(:type, :address_type)
|
||||
field(:url, :string)
|
||||
field(:info, :string)
|
||||
end
|
||||
|
||||
@desc "The list of types an address can be"
|
||||
enum :address_type do
|
||||
value(:physical, description: "The address is physical, like a postal address")
|
||||
value(:url, description: "The address is on the Web, like an URL")
|
||||
value(:phone, description: "The address is a phone number for a conference")
|
||||
value(:other, description: "The address is something else")
|
||||
end
|
||||
|
||||
object :address_queries do
|
||||
@desc "Search for an address"
|
||||
field :search_address, type: list_of(:physical_address) do
|
||||
field :search_address, type: list_of(:address) do
|
||||
arg(:query, non_null(:string))
|
||||
|
||||
resolve(&Resolvers.Address.search/3)
|
||||
end
|
||||
|
||||
@desc "Reverse geocode coordinates"
|
||||
field :reverse_geocode, type: list_of(:physical_address) do
|
||||
field :reverse_geocode, type: list_of(:address) do
|
||||
arg(:longitude, non_null(:float))
|
||||
arg(:latitude, non_null(:float))
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
Schema representation for Event
|
||||
"""
|
||||
use Absinthe.Schema.Notation
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.{Actors, Addresses}
|
||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||
import_types(MobilizonWeb.Schema.AddressType)
|
||||
import_types(MobilizonWeb.Schema.Events.ParticipantType)
|
||||
@@ -27,7 +27,12 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
# TODO replace me with banner
|
||||
field(:large_image, :string, description: "A large picture for the event")
|
||||
field(:publish_at, :datetime, description: "When the event was published")
|
||||
field(:physical_address, :physical_address, description: "The type of the event's address")
|
||||
|
||||
field(:physical_address, :address,
|
||||
resolve: dataloader(Addresses),
|
||||
description: "The type of the event's address"
|
||||
)
|
||||
|
||||
field(:online_address, :online_address, description: "Online address of the event")
|
||||
field(:phone_address, :phone_address, description: "Phone address for the event")
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ defmodule MobilizonWeb.JsonLD.ObjectView do
|
||||
"name" => address.description,
|
||||
"address" => %{
|
||||
"@type" => "PostalAddress",
|
||||
"streetAddress" => address.streetAddress,
|
||||
"addressLocality" => address.addressLocality,
|
||||
"postalCode" => address.postalCode,
|
||||
"addressRegion" => address.addressRegion,
|
||||
"addressCountry" => address.addressCountry
|
||||
"streetAddress" => address.street,
|
||||
"addressLocality" => address.locality,
|
||||
"postalCode" => address.postal_code,
|
||||
"addressRegion" => address.region,
|
||||
"addressCountry" => address.country
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user