zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

type.ex (3434B)


      1 # Zenflows is designed to implement the Valueflows vocabulary,
      2 # written and maintained by srfsh <info@dyne.org>.
      3 # Copyright (C) 2021-2023 Dyne.org foundation <foundation@dyne.org>.
      4 #
      5 # This program is free software: you can redistribute it and/or modify
      6 # it under the terms of the GNU Affero General Public License as published by
      7 # the Free Software Foundation, either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU Affero General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU Affero General Public License
     16 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     17 
     18 defmodule Zenflows.VF.SpatialThing.Type do
     19 @moduledoc false
     20 # Basically, a fancy name for (geo)location.  :P
     21 
     22 use Absinthe.Schema.Notation
     23 
     24 alias Zenflows.VF.SpatialThing.Resolv
     25 
     26 @name """
     27 An informal or formal textual identifier for a location.  Does not
     28 imply uniqueness.
     29 """
     30 @mappable_address """
     31 An address that will be recognized as mappable by mapping software.
     32 """
     33 @lat "Latitude."
     34 @long "Longitude."
     35 @alt "Altitude."
     36 @note "A textual description or comment."
     37 
     38 @desc "A physical mappable location."
     39 object :spatial_thing do
     40 	field :id, non_null(:id)
     41 
     42 	@desc @name
     43 	field :name, non_null(:string)
     44 
     45 	@desc @mappable_address
     46 	field :mappable_address, :string
     47 
     48 	@desc @lat
     49 	field :lat, :decimal
     50 
     51 	@desc @long
     52 	field :long, :decimal
     53 
     54 	@desc @alt
     55 	field :alt, :decimal
     56 
     57 	@desc @note
     58 	field :note, :string
     59 end
     60 
     61 input_object :spatial_thing_create_params do
     62 	@desc @name
     63 	field :name, non_null(:string)
     64 
     65 	@desc @mappable_address
     66 	field :mappable_address, :string
     67 
     68 	@desc @lat
     69 	field :lat, :decimal
     70 
     71 	@desc @long
     72 	field :long, :decimal
     73 
     74 	@desc @alt
     75 	field :alt, :decimal
     76 
     77 	@desc @note
     78 	field :note, :string
     79 end
     80 
     81 input_object :spatial_thing_update_params do
     82 	field :id, non_null(:id)
     83 
     84 	@desc @name
     85 	field :name, :string
     86 
     87 	@desc @mappable_address
     88 	field :mappable_address, :string
     89 
     90 	@desc @lat
     91 	field :lat, :decimal
     92 
     93 	@desc @long
     94 	field :long, :decimal
     95 
     96 	@desc @alt
     97 	field :alt, :decimal
     98 
     99 	@desc @note
    100 	field :note, :string
    101 end
    102 
    103 object :spatial_thing_response do
    104 	field :spatial_thing, non_null(:spatial_thing)
    105 end
    106 
    107 object :spatial_thing_edge do
    108 	field :cursor, non_null(:id)
    109 	field :node, non_null(:spatial_thing)
    110 end
    111 
    112 object :spatial_thing_connection do
    113 	field :page_info, non_null(:page_info)
    114 	field :edges, non_null(list_of(non_null(:spatial_thing_edge)))
    115 end
    116 
    117 object :query_spatial_thing do
    118 	field :spatial_thing, :spatial_thing do
    119 		arg :id, non_null(:id)
    120 		resolve &Resolv.spatial_thing/2
    121 	end
    122 
    123 	field :spatial_things, :spatial_thing_connection do
    124 		arg :first, :integer
    125 		arg :after, :id
    126 		arg :last, :integer
    127 		arg :before, :id
    128 		resolve &Resolv.spatial_things/2
    129 	end
    130 end
    131 
    132 object :mutation_spatial_thing do
    133 	field :create_spatial_thing, non_null(:spatial_thing_response) do
    134 		arg :spatial_thing, non_null(:spatial_thing_create_params)
    135 		resolve &Resolv.create_spatial_thing/2
    136 	end
    137 
    138 	field :update_spatial_thing, non_null(:spatial_thing_response) do
    139 		arg :spatial_thing, non_null(:spatial_thing_update_params)
    140 		resolve &Resolv.update_spatial_thing/2
    141 	end
    142 
    143 	field :delete_spatial_thing, non_null(:boolean) do
    144 		arg :id, non_null(:id)
    145 		resolve &Resolv.delete_spatial_thing/2
    146 	end
    147 end
    148 end