type.ex (5250B)
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.RecipeResource.Type do 19 @moduledoc false 20 21 use Absinthe.Schema.Notation 22 23 alias Zenflows.VF.RecipeResource.Resolv 24 25 @name """ 26 An informal or formal textual identifier for a recipe resource. Does not 27 imply uniqueness. 28 """ 29 @image """ 30 The base64-encoded image binary relevant to the entity, such as a photo, diagram, etc. 31 """ 32 @unit_of_resource """ 33 The unit of inventory used for this resource in the recipe. 34 """ 35 @unit_of_resource_id "(`Unit`) #{@unit_of_resource}" 36 @unit_of_effort """ 37 The unit used for use action on this resource or work action in the 38 recipe. 39 """ 40 @unit_of_effort_id "(`Unit`) #{@unit_of_resource}" 41 @note "A textual description or comment." 42 @resource_conforms_to """ 43 The primary resource specification or definition of an existing or 44 potential economic resource. A resource will have only one, as this 45 specifies exactly what the resource is. 46 """ 47 @resource_conforms_to_id "(`ResourceSpecification`) #{@resource_conforms_to}" 48 @resource_classified_as """ 49 References a concept in a common taxonomy or other classification scheme 50 for purposes of categorization or grouping. 51 """ 52 @substitutable """ 53 Defines if any resource of that type can be freely substituted for any 54 other resource of that type when used, consumed, traded, etc. 55 """ 56 57 @desc """ 58 Specifies the resource as part of a recipe, for use in planning from 59 recipe. 60 """ 61 object :recipe_resource do 62 field :id, non_null(:id) 63 64 @desc @name 65 field :name, non_null(:string) 66 67 @desc @unit_of_resource 68 field :unit_of_resource, :unit, 69 resolve: &Resolv.unit_of_resource/3 70 71 @desc @unit_of_effort 72 field :unit_of_effort, :unit, 73 resolve: &Resolv.unit_of_effort/3 74 75 @desc @image 76 field :image, :base64 77 78 @desc @note 79 field :note, :string 80 81 @desc @resource_conforms_to 82 field :resource_conforms_to, :resource_specification, 83 resolve: &Resolv.resource_conforms_to/3 84 85 @desc @resource_classified_as 86 field :resource_classified_as, list_of(non_null(:uri)) 87 88 @desc @substitutable 89 field :substitutable, non_null(:boolean) 90 end 91 92 input_object :recipe_resource_create_params do 93 @desc @name 94 field :name, non_null(:string) 95 96 @desc @unit_of_resource_id 97 field :unit_of_resource_id, :id, name: "unit_of_resource" 98 99 @desc @unit_of_effort_id 100 field :unit_of_effort_id, :id, name: "unit_of_effort" 101 102 @desc @image 103 field :image, :base64 104 105 @desc @note 106 field :note, :string 107 108 @desc @resource_conforms_to_id 109 field :resource_conforms_to_id, :id, name: "resource_conforms_to" 110 111 @desc @resource_classified_as 112 field :resource_classified_as, list_of(non_null(:uri)) 113 114 @desc @substitutable 115 field :substitutable, :boolean 116 end 117 118 input_object :recipe_resource_update_params do 119 field :id, non_null(:id) 120 121 @desc @name 122 field :name, :string 123 124 @desc @unit_of_resource_id 125 field :unit_of_resource_id, :id, name: "unit_of_resource" 126 127 @desc @unit_of_effort_id 128 field :unit_of_effort_id, :id, name: "unit_of_effort" 129 130 @desc @image 131 field :image, :base64 132 133 @desc @note 134 field :note, :string 135 136 @desc @resource_conforms_to_id 137 field :resource_conforms_to_id, :id, name: "resource_conforms_to" 138 139 @desc @resource_classified_as 140 field :resource_classified_as, list_of(non_null(:uri)) 141 142 @desc @substitutable 143 field :substitutable, :boolean 144 end 145 146 object :recipe_resource_response do 147 field :recipe_resource, non_null(:recipe_resource) 148 end 149 150 object :recipe_resource_edge do 151 field :cursor, non_null(:id) 152 field :node, non_null(:recipe_resource) 153 end 154 155 object :recipe_resource_connection do 156 field :page_info, non_null(:page_info) 157 field :edges, non_null(list_of(non_null(:recipe_resource_edge))) 158 end 159 160 object :query_recipe_resource do 161 field :recipe_resource, :recipe_resource do 162 arg :id, non_null(:id) 163 resolve &Resolv.recipe_resource/2 164 end 165 166 field :recipe_resources, :recipe_resource_connection do 167 arg :first, :integer 168 arg :after, :id 169 arg :last, :integer 170 arg :before, :id 171 resolve &Resolv.recipe_resources/2 172 end 173 end 174 175 object :mutation_recipe_resource do 176 field :create_recipe_resource, non_null(:recipe_resource_response) do 177 arg :recipe_resource, non_null(:recipe_resource_create_params) 178 resolve &Resolv.create_recipe_resource/2 179 end 180 181 field :update_recipe_resource, non_null(:recipe_resource_response) do 182 arg :recipe_resource, non_null(:recipe_resource_update_params) 183 resolve &Resolv.update_recipe_resource/2 184 end 185 186 field :delete_recipe_resource, non_null(:boolean) do 187 arg :id, non_null(:id) 188 resolve &Resolv.delete_recipe_resource/2 189 end 190 end 191 end