type.ex (4803B)
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.ResourceSpecification.Type do 19 @moduledoc false 20 21 use Absinthe.Schema.Notation 22 23 alias Zenflows.VF.ResourceSpecification.Resolv 24 25 @name """ 26 An informal or formal textual identifier for a type of resource. 27 Does not imply uniqueness. 28 """ 29 @images """ 30 The image files relevant to the entity, such as a photo, diagram, etc. 31 """ 32 @resource_classified_as """ 33 References a concept in a common taxonomy or other classification scheme 34 for purposes of categorization or grouping. 35 """ 36 @default_unit_of_resource "The default unit used for the resource itself." 37 @default_unit_of_resource_id "(`Unit`) #{@default_unit_of_resource}" 38 @default_unit_of_effort "The default unit used for use or work." 39 @default_unit_of_effort_id "(`Unit`) #{@default_unit_of_effort}" 40 @note "A textual description or comment." 41 42 @desc """ 43 Specification of a kind of resource. Could define a material item, 44 service, digital item, currency account, etc. Used instead of a 45 classification when more information is needed, particularly for recipes. 46 """ 47 object :resource_specification do 48 field :id, non_null(:id) 49 50 @desc @name 51 field :name, non_null(:string) 52 53 @desc @images 54 field :images, list_of(non_null(:file)), resolve: &Resolv.images/3 55 56 @desc @resource_classified_as 57 field :resource_classified_as, list_of(non_null(:uri)) 58 59 @desc @note 60 field :note, :string 61 62 @desc @default_unit_of_resource 63 field :default_unit_of_resource, :unit, 64 resolve: &Resolv.default_unit_of_resource/3 65 66 @desc @default_unit_of_effort 67 field :default_unit_of_effort, :unit, 68 resolve: &Resolv.default_unit_of_effort/3 69 end 70 71 input_object :resource_specification_create_params do 72 @desc @name 73 field :name, non_null(:string) 74 75 @desc @images 76 field :images, list_of(non_null(:ifile)) 77 78 @desc @resource_classified_as 79 field :resource_classified_as, list_of(non_null(:uri)) 80 81 @desc @note 82 field :note, :string 83 84 @desc @default_unit_of_resource_id 85 field :default_unit_of_resource_id, :id, name: "default_unit_of_resource" 86 87 @desc @default_unit_of_effort_id 88 field :default_unit_of_effort_id, :id, name: "default_unit_of_effort" 89 end 90 91 input_object :resource_specification_update_params do 92 field :id, non_null(:id) 93 94 @desc @name 95 field :name, :string 96 97 @desc @resource_classified_as 98 field :resource_classified_as, list_of(non_null(:uri)) 99 100 @desc @note 101 field :note, :string 102 103 @desc @default_unit_of_resource_id 104 field :default_unit_of_resource_id, :id, name: "default_unit_of_resource" 105 106 @desc @default_unit_of_effort_id 107 field :default_unit_of_effort_id, :id, name: "default_unit_of_effort" 108 end 109 110 object :resource_specification_response do 111 field :resource_specification, non_null(:resource_specification) 112 end 113 114 object :resource_specification_edge do 115 field :cursor, non_null(:id) 116 field :node, non_null(:resource_specification) 117 end 118 119 object :resource_specification_connection do 120 field :page_info, non_null(:page_info) 121 field :edges, non_null(list_of(non_null(:resource_specification_edge))) 122 end 123 124 object :query_resource_specification do 125 field :resource_specification, :resource_specification do 126 arg :id, non_null(:id) 127 resolve &Resolv.resource_specification/2 128 end 129 130 field :resource_specifications, :resource_specification_connection do 131 arg :first, :integer 132 arg :after, :id 133 arg :last, :integer 134 arg :before, :id 135 resolve &Resolv.resource_specifications/2 136 end 137 end 138 139 object :mutation_resource_specification do 140 field :create_resource_specification, non_null(:resource_specification_response) do 141 arg :resource_specification, non_null(:resource_specification_create_params) 142 resolve &Resolv.create_resource_specification/2 143 end 144 145 field :update_resource_specification, non_null(:resource_specification_response) do 146 arg :resource_specification, non_null(:resource_specification_update_params) 147 resolve &Resolv.update_resource_specification/2 148 end 149 150 field :delete_resource_specification, non_null(:boolean) do 151 arg :id, non_null(:id) 152 resolve &Resolv.delete_resource_specification/2 153 end 154 end 155 end