type.ex (4410B)
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.Organization.Type do 19 @moduledoc false 20 21 use Absinthe.Schema.Notation 22 23 alias Zenflows.VF.Organization.Resolv 24 25 @name "The name that this agent will be referred to by." 26 @images """ 27 The image files relevant to the agent, such as a logo, avatar, photo, etc. 28 """ 29 @primary_location """ 30 The main place an agent is located, often an address where activities 31 occur and mail can be sent. This is usually a mappable geographic 32 location. It also could be a website address, as in the case of agents 33 who have no physical location. 34 """ 35 @primary_location_id "(`SpatialThing`) #{@primary_location}" 36 @note "A textual description or comment." 37 @classified_as """ 38 References one or more concepts in a common taxonomy or other 39 classification scheme for purposes of categorization or grouping. 40 """ 41 42 @desc "A formal or informal group, or legal organization." 43 object :organization do 44 interface :agent 45 46 field :id, non_null(:id) 47 48 @desc @name 49 field :name, non_null(:string) 50 51 @desc @images 52 field :images, list_of(non_null(:file)) 53 54 @desc @primary_location 55 field :primary_location, :spatial_thing, 56 resolve: &Resolv.primary_location/3 57 58 @desc @note 59 field :note, :string 60 61 @desc @classified_as 62 field :classified_as, list_of(non_null(:string)) 63 end 64 65 input_object :organization_create_params do 66 @desc @name 67 field :name, non_null(:string) 68 69 @desc @images 70 field :images, list_of(non_null(:ifile)), resolve: &Resolv.images/3 71 72 @desc @note 73 field :note, :string 74 75 @desc @primary_location_id 76 field :primary_location_id, :id, name: "primary_location" 77 78 @desc @classified_as 79 field :classified_as, list_of(non_null(:string)) 80 end 81 82 input_object :organization_update_params do 83 field :id, non_null(:id) 84 85 @desc @name 86 field :name, :string 87 88 @desc @note 89 field :note, :string 90 91 @desc @primary_location_id 92 field :primary_location_id, :id, name: "primary_location" 93 94 @desc @classified_as 95 field :classified_as, list_of(non_null(:string)) 96 end 97 98 object :organization_response do 99 field :agent, non_null(:organization) 100 end 101 102 object :organization_edge do 103 field :cursor, non_null(:id) 104 field :node, non_null(:organization) 105 end 106 107 object :organization_connection do 108 field :page_info, non_null(:page_info) 109 field :edges, non_null(list_of(non_null(:organization_edge))) 110 end 111 112 input_object :organization_filter_params do 113 field :name, :string 114 end 115 116 object :query_organization do 117 @desc "Find an organization (group) agent by its ID." 118 field :organization, :organization do 119 arg :id, non_null(:id) 120 resolve &Resolv.organization/2 121 end 122 123 @desc """ 124 Loads all organizations publicly registered within this 125 collaboration space. 126 """ 127 field :organizations, :organization_connection do 128 arg :first, :integer 129 arg :after, :id 130 arg :last, :integer 131 arg :before, :id 132 arg :filter, :organization_filter_params 133 resolve &Resolv.organizations/2 134 end 135 end 136 137 object :mutation_organization do 138 @desc """ 139 Registers a new organization (group agent) with the 140 collaboration space. 141 """ 142 field :create_organization, non_null(:organization_response) do 143 arg :organization, non_null(:organization_create_params) 144 resolve &Resolv.create_organization/2 145 end 146 147 @desc "Update organization profile details." 148 field :update_organization, non_null(:organization_response) do 149 arg :organization, non_null(:organization_update_params) 150 resolve &Resolv.update_organization/2 151 end 152 153 @desc """ 154 Erase record of an organization and thus remove it from 155 the collaboration space. 156 """ 157 field :delete_organization, non_null(:boolean) do 158 arg :id, non_null(:id) 159 resolve &Resolv.delete_organization/2 160 end 161 end 162 end